From nobody Sun May 21 22:13:26 2023 X-Original-To: dev-commits-src-main@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 4QPZbX4yD4z4CXbQ; Sun, 21 May 2023 22:13:28 +0000 (UTC) (envelope-from hselasky@freebsd.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (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 4QPZbW4XJQz4MmP; Sun, 21 May 2023 22:13:27 +0000 (UTC) (envelope-from hselasky@freebsd.org) Authentication-Results: mx1.freebsd.org; dkim=none; spf=softfail (mx1.freebsd.org: 88.99.82.50 is neither permitted nor denied by domain of hselasky@freebsd.org) smtp.mailfrom=hselasky@freebsd.org; dmarc=none Received: from [10.36.2.145] (unknown [46.212.121.255]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 8C5C12600DD; Mon, 22 May 2023 00:13:26 +0200 (CEST) Message-ID: <8f46512a-f086-6da0-2fdd-3ffc89f4dfdd@freebsd.org> Date: Mon, 22 May 2023 00:13:26 +0200 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: git: 805d759338a2 - main - mlx4: Move DEFINE_MUTEX() outside function body. Content-Language: en-US From: Hans Petter Selasky To: Jessica Clarke Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@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> <26465813-3B51-4E52-9E9D-F93A0F2AF6BD@freebsd.org> <2BF2F7CF-82E6-4D98-800D-C35D7C29E948@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-3.09 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.986]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MLMMJ_DEST(0.00)[dev-commits-src-all@FreeBSD.org,dev-commits-src-main@FreeBSD.org]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:24940, ipnet:88.99.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[hselasky]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DMARC_NA(0.00)[freebsd.org]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Queue-Id: 4QPZbW4XJQz4MmP X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N 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