From nobody Fri May 17 19:32:51 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 4VgxvB4V5dz5Lgdc; Fri, 17 May 2024 19:32:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vgxv96mWPz41ws; Fri, 17 May 2024 19:32:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715974373; 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=2BjnZDwQDLhH2GSL18fvxbszFQfOPxZ+D3PU3SYgOio=; b=pDEtcz4kcHhgoVp6DbHZhW7+VGJm83qV2FHIiBSU5wHw9+LI3GcQzeUmk58Ws8VRfcx6yS xh7n8yl7ShRFitT8Ss2d9gZlAqhNm7qhcpNr52bJtXIfUKlxRQ6PTP+eODvQAijeMWM5/p ob2hBIXRNzLL8W8Cv2xrG1Twvd5l61yUC6i01gQLlPzZ9uEQQyMm0JJQJfRffTgsBDKeHp UUzgpS1OEpURoXnktFUz6KBo5t6dTyqwIrPEN5Q+27GP93PqoB/RxWuMJ5acw4L2c+Ux2W OTVzFvuFqEyuuUMLnG8A1cKQkxsFexPFZqpgWIV/ow2q8qxA1bThlOu4mOz0bA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715974373; a=rsa-sha256; cv=none; b=WTFgDODoj31qEYoS4YDFgCFE+CuxcSsAyZ3PPNrHKTtpMIoIDNyibGsnbqx/23s/oJvNN9 0lIBI4j8Gv0R73FiGtkprvF+EDeuJyI0fZsiAQYgi9wFOfXxt+aUirkAn5k1Y0DNZkqLzf 9HD6FBRIr3zdsgzkwGO6kzP5x4xcVN34IC7yE4CENWfyPvRKbO6OnMaMn1ecJ+37bxNDCo 1zifgfre7NZyeO/oC9pwVqj/Di0fcmOkCZobdlDNVA+HgYuPOnTXtopIK65agqQ0mkPj08 xf0wxXit1DvFTiL+/0IeZxilFuidKVNUSMxaxlpfYdhsQnAGx3oYlJtqu+e6Wg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715974373; 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=2BjnZDwQDLhH2GSL18fvxbszFQfOPxZ+D3PU3SYgOio=; b=FoAjq4BzDZijDbCHSWKe+WuvVEmyFAm4IlekLeVzOObDTplXR8oZTtXf7q/SGzUl41CA7a utgMTEsVBZjg4UJMrR0mUZBKlmunTxEug7mZ4A7DJjLR0O6LAiKwut32rbfw9RhVOTF2gi NCb7cRsZY2VFxHm1ejSbiL3SRDOY3ZyKIEqeUlPc0zZ1xeoECU+yDovT5CEf3ZJjAEI+9A xFTA4I+T3dpWaoyO6nBTuipOA6X0MbcawoWSiQVu9K+qcs2KeKX6cXNu71pR3PohQ28sfO 6Y/LOrIVsR6n49ESpuvmoHiIEpgyWiLxFSGy1PmhSdfFqMEigKdyJ/j1eXJjVg== Received: from [IPV6:2601:644:937f:4c50:c0c0:cf11:cc26:3c0e] (unknown [IPv6:2601:644:937f:4c50:c0c0:cf11:cc26:3c0e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Vgxv92WgPzL9C; Fri, 17 May 2024 19:32:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <0f2c4189-e259-4bd8-ad31-212a8df0e1b5@FreeBSD.org> Date: Fri, 17 May 2024 12:32:51 -0700 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 User-Agent: Mozilla Thunderbird Subject: Re: git: cff79fd02636 - main - linuxkpi: Fix spin_lock_init Content-Language: en-US To: Emmanuel Vadot Cc: Emmanuel Vadot , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202405170559.44H5xD7d019861@gitrepo.freebsd.org> <2cd3e698-1b42-4e7f-93a0-aacccb55c8d6@FreeBSD.org> <20240517183350.e45f54df07f670980d5a51c3@bidouilliste.com> From: John Baldwin In-Reply-To: <20240517183350.e45f54df07f670980d5a51c3@bidouilliste.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/17/24 9:33 AM, Emmanuel Vadot wrote: > 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. You can use macro magic to add support for an optional second argument. #define _spin_lock_init2(lock, name) mtx_init(lock, name, NULL, MTX_DEF) #define _spin_lock_init1(lock) mtx_init(lock, spin_lock_name("lnxspin"), ...) #define _spin_lock_init_macro(lock, name, NAME, ...) NAME #define spin_lock_init(...) \ _spin_lock_init_macro(__VA_ARGS__, _spin_lock_init2, _spin_lock_init1)(__VA_ARGS__) Then you can choose to specifically annotate certain locks with a name instead in which case they will use WITNESS. -- John Baldwin