From nobody Fri May 17 16:33:50 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vgswg1Yhmz5LQhX; Fri, 17 May 2024 16:33:55 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mx.blih.net [212.83.155.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vgswf2zSFz4TwC; Fri, 17 May 2024 16:33:54 +0000 (UTC) (envelope-from manu@bidouilliste.com) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1715963631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FLo7VuCwGQoehKsM3Gmr75CNnvIxE1qN5ayzyIPV7LQ=; b=P6QqP9OLxCBuA7U5MfY29Fx6Vc0PtWatbpq+x5xZcP/yyLMwEzCn6OF/eiQWcE1WCIUzbB jzsAFPK3m/3prWuClMc5bQQqZ9bwRhAAiwihMy9WLjzKBAL/TvLbvLwP0rfQN81oBIGA7B 4yN/RH6DJpyZrMKjf29SNVzUFRmsnpI= Received: from skull.home.blih.net (lfbn-lyo-1-2174-135.w90-66.abo.wanadoo.fr [90.66.97.135]) by mx.blih.net (OpenSMTPD) with ESMTPSA id 745ecdcb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 17 May 2024 16:33:51 +0000 (UTC) Date: Fri, 17 May 2024 18:33:50 +0200 From: Emmanuel Vadot To: John Baldwin Cc: Emmanuel Vadot , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: cff79fd02636 - main - linuxkpi: Fix spin_lock_init Message-Id: <20240517183350.e45f54df07f670980d5a51c3@bidouilliste.com> In-Reply-To: <2cd3e698-1b42-4e7f-93a0-aacccb55c8d6@FreeBSD.org> References: <202405170559.44H5xD7d019861@gitrepo.freebsd.org> <2cd3e698-1b42-4e7f-93a0-aacccb55c8d6@FreeBSD.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd15.0) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:12876, ipnet:212.83.128.0/19, country:FR] X-Rspamd-Queue-Id: 4Vgswf2zSFz4TwC On Fri, 17 May 2024 09:07:53 -0700 John Baldwin wrote: > On 5/16/24 10:59 PM, Emmanuel Vadot wrote: > > The branch main has been updated by manu: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=cff79fd02636f34010d8b835cc9e55401fa76e74 > > > > commit cff79fd02636f34010d8b835cc9e55401fa76e74 > > Author: Emmanuel Vadot > > AuthorDate: 2024-05-17 04:52:53 +0000 > > Commit: Emmanuel Vadot > > CommitDate: 2024-05-17 05:58:59 +0000 > > > > linuxkpi: Fix spin_lock_init > > > > Some linux code re-init some spinlock so add MTX_NEW to mtx_init. > > > > Reported by: David Wolfskill > > Fixes: ae38a1a1bfdf ("linuxkpi: spinlock: Simplify code") > > --- > > sys/compat/linuxkpi/common/include/linux/spinlock.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h > > index 3f6eb4bb70f6..2992e41c9c02 100644 > > --- a/sys/compat/linuxkpi/common/include/linux/spinlock.h > > +++ b/sys/compat/linuxkpi/common/include/linux/spinlock.h > > @@ -140,7 +140,7 @@ typedef struct mtx spinlock_t; > > #define spin_lock_name(name) _spin_lock_name(name, __FILE__, __LINE__) > > > > #define spin_lock_init(lock) mtx_init(lock, spin_lock_name("lnxspin"), \ > > - NULL, MTX_DEF | MTX_NOWITNESS) > > + NULL, MTX_DEF | MTX_NOWITNESS | MTX_NEW) > > > > #define spin_lock_destroy(_l) mtx_destroy(_l) > > This is only ok because of MTX_NOWITNESS. Reiniting locks without destroying > them corrupts the internal linked lists in WITNESS for locks using witness. > That may warrant a comment here explaining why we disable witness. I'll try to look at what linux expect for spinlocks, it could also be that we need to do this because some drivers via linuxkpi does weird things ... > It might be nice to add an extension to the various lock inits for code that > wants to opt-int to using WITNESS where a name can be passed. Using those would > be relatively small diffs in the client code and let select locks opt into > using WITNESS. You could make it work by adding an optional second argument > to spin_lock_init, etc. that takes the name. We can't change spin_lock_init, we need to follow linux api here. > -- > John Baldwin > -- Emmanuel Vadot