From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 471E6C369AB for ; Fri, 18 Apr 2025 15:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nFgOrlNyb8Ejkb43D/yIyVFJ/IzoXYakXUeU5QoZiuU=; b=3Zi2Qu0LxrWmCGC9YlftcFpScX 6oxRbqCMunt742NwAKDsH038agplaTsmz4c08eiY+IEbg+q9PvlXvydc4tpPxVhI3Fj+DcZgZmM/b NBPkPxry4UWnXyoTGvsC1Oteq9JGPia1kjU8Khq34BITQtvGJeohm8DMWZoO8mj+uT/wUs35uZy7s H06JknUG6y2H7DdGLHOQJhK9Dgx7FON7w8CHgqC14fa2keMJBD2+hJVuX5oHVYauxCdvpyW5HW7w0 hoNr3rNAfvi2iDzZcaKYzh2FY1baph5KGjMAu57WxVwyGx1YNHFzXJETnhirLbNCJ6dfiyOxUQZ6w xtrduAow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5nnI-0000000GkSq-3ev4; Fri, 18 Apr 2025 15:38:20 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5nkN-0000000GjfB-0bhZ for linux-arm-kernel@lists.infradead.org; Fri, 18 Apr 2025 15:35:20 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3920EA4B520; Fri, 18 Apr 2025 15:29:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1863CC4CEEA; Fri, 18 Apr 2025 15:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744990518; bh=7NHab62RZtPj0Np+h3D9F3dxP/sVC+/JnFk6D/PUpPQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uqzjTsEnt9rDe+ksBBlT3BLXDvD6oHj/oGnFMl4wzPOE/y7OsfkdibxQnus0m3BAT +Z2qaFSGhZq07whzJPZjt5WArxUXWXyOeLky4XMAa6ay+xm5WOX/17eKfxr4cxsuEX JaJTxU+shymgO6NAmDcbCDNuZZparjTo6TcQRUt+Sb6pylRsSYd1lK97CI4B93LuVb 3wxLctZljW/x2jALr2c/dFwan9BRHFdFT+eNLM/5Uv+63xjEL/CVdzt4hRIOCvcGvi 7ZeABxWyYURO/vSJMWJE1tAx4ebji6fO4/FNg7uqS7KtaVU7TgmWnY3r2xP107RcjZ kJ8+DBdQdreQA== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1u5nkJ-006krU-QT; Fri, 18 Apr 2025 16:35:15 +0100 Date: Fri, 18 Apr 2025 16:35:22 +0100 Message-ID: <87plh9xz2d.wl-maz@kernel.org> From: Marc Zyngier To: Yury Norov Cc: Andrew Lunn , Luo Jie , Rasmus Villemoes , Julia Lawall , Nicolas Palix , Catalin Marinas , Will Deacon , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org, cocci@inria.fr, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, quic_kkumarcs@quicinc.com, quic_linchen@quicinc.com, quic_leiwei@quicinc.com, quic_suruchia@quicinc.com, quic_pavir@quicinc.com Subject: Re: [PATCH v3 0/6] Add FIELD_MODIFY() helper In-Reply-To: References: <20250417-field_modify-v3-0-6f7992aafcb7@quicinc.com> <86sem7jb5t.wl-maz@kernel.org> <0c97c659-bd28-45e0-8537-d9be2637cb22@lunn.ch> <86mscek7h3.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yury.norov@gmail.com, andrew@lunn.ch, quic_luoj@quicinc.com, linux@rasmusvillemoes.dk, Julia.Lawall@inria.fr, nicolas.palix@imag.fr, catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-kernel@vger.kernel.org, cocci@inria.fr, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, quic_kkumarcs@quicinc.com, quic_linchen@quicinc.com, quic_leiwei@quicinc.com, quic_suruchia@quicinc.com, quic_pavir@quicinc.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250418_083519_316406_4602C740 X-CRM114-Status: GOOD ( 33.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 18 Apr 2025 16:08:38 +0100, Yury Norov wrote: > > On Thu, Apr 17, 2025 at 06:45:12PM +0100, Marc Zyngier wrote: > > On Thu, 17 Apr 2025 18:22:29 +0100, > > Andrew Lunn wrote: > > > > > > On Thu, Apr 17, 2025 at 12:10:54PM +0100, Marc Zyngier wrote: > > > > On Thu, 17 Apr 2025 11:47:07 +0100, > > > > Luo Jie wrote: > > > > > > > > > > Add the helper FIELD_MODIFY() to the FIELD_XXX family of bitfield > > > > > macros. It is functionally similar as xxx_replace_bits(), but adds > > > > > the compile time checking to catch incorrect parameter type errors. > > > > > > > > > > This series also converts the four instances of opencoded FIELD_MODIFY() > > > > > that are found in the core kernel files, to instead use the new > > > > > FIELD_MODIFY() macro. This is achieved with Coccinelle, by adding > > > > > the script field_modify.cocci. > > > > > > > > > > The changes are validated on IPQ9574 SoC which uses ARM64 architecture. > > > > > > > > We already have the *_replace_bits() functions (see > > > > include/linux/bitfield.h). > > > > > > > > Why do we need extra helpers? > > > > > > If you look at bitfield.h, the *_replace_bits() seem to be > > > undocumented internal macro magic, not something you are expected to > > > use. What you are expected to use in that file is however well > > > documented. The macro magic also means that cross referencing tools > > > don't find them. > > > > $ git grep _replace_bits| wc -l > > 1514 > > FIELD_PREP() only is used 10 times more. And? I'm sure that if you count "+", you'll find it to be yet a few order of magnitudes more. > > > I think a bunch of people have found them, tooling notwithstanding. > > > > As for the documentation, the commit message in 00b0c9b82663ac would > > be advantageously promoted to full-fledged kernel-doc. > > The FIELD_MODIFY() and uxx_replace_bits() are simply different things. > > FIELD_MODIFY() employs __BF_FIELD_CHECK(), which allows strict > parameters checking at compile time. And people like it. See > recent fixed-size GENMASK() series: > > https://patchwork.kernel.org/comment/26283604/ I don't care much for what people like or not. I don't see this FIELD_MODIFY() as a particular improvement on *_replace_bits(). > The _replace_bits() functions return fixed-width values, and intended > for: "manipulating bitfields both in host- and fixed-endian", as the > very first line in the commit message says. > > Those using _replace_bits() for something else abuse the API, and > should switch to FIELD_MODIFY(). Or not. M. -- Jazz isn't dead. It just smells funny.