Date: Mon, 22 May 2023 00:13:26 +0200 From: Hans Petter Selasky <hselasky@freebsd.org> To: Jessica Clarke <jrtc27@freebsd.org> Cc: "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org> Subject: Re: git: 805d759338a2 - main - mlx4: Move DEFINE_MUTEX() outside function body. Message-ID: <8f46512a-f086-6da0-2fdd-3ffc89f4dfdd@freebsd.org> In-Reply-To: <ac11ff8e-eeb9-a7e6-28d3-da5c9fad6567@freebsd.org> References: <202305211621.34LGLsup059861@gitrepo.freebsd.org> <54EF67D8-2A79-4EAB-8EFB-232F14FFE792@freebsd.org> <21c9532e-4ca7-a7fe-1ff6-07a94cbad6ab@freebsd.org> <3066464F-E4C6-4B84-ADFF-E578AFAFE622@freebsd.org> <e802dfc0-0a16-add1-cf5d-a8811b3bd3e6@freebsd.org> <26465813-3B51-4E52-9E9D-F93A0F2AF6BD@freebsd.org> <ffb3f6ea-ef74-ebe3-884d-da567defd2e6@freebsd.org> <2BF2F7CF-82E6-4D98-800D-C35D7C29E948@freebsd.org> <ac11ff8e-eeb9-a7e6-28d3-da5c9fad6567@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 5/21/23 23:37, Hans Petter Selasky wrote: > DEFINE_MUTEX is Linux’s API, implemented in LinuxKPI. So Linux’s > behaviour is absolutely relevant. Any deviation from Linux’s semantics > is an incompatibility that requires patching any sources that are built > for FreeBSD using LinuxKPI. It is generally best to minimise that. Jess, listen: Probably at some point, there could be an initialization macro for the SX locks used in the LinuxKPI, being of type SX_NOWITNESS, simply plotting in the constants needed in the sx structure, exactly like they do under Linux. Then neither SYSINITs, nor my patch will be needed for the sake of DEFINE_MUTEX(). Can we wait for that? The reason for this is Linux has a bad habit of not destroying locks, so FreeBSD cannot add any WITNESS objects for locks that are not destroyed anyway. Most of the work done by sx_init() is putting a few constants into various SX structure fields. Only the WITNESS part needs execution, if you get what I mean. This change is made so I can let others easily test another patchset. Also this change is harmless as such. Looking at the whole Linux tree, the most common way is to use DEFINE_MUTEX() outside macros and functions: # grep -r DEFINE_MUTEX * | grep -vE ":static " | grep -vE ":DEFINE_MUTEX" | wc -l 57 # grep -r DEFINE_MUTEX * | wc -l 1293 --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8f46512a-f086-6da0-2fdd-3ffc89f4dfdd>