From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B23F3B27D1 for ; Mon, 27 Apr 2026 09:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777282977; cv=none; b=JMu0moo9eAqwaCcEyvhJ7yyoSq0FeyOyBXg+IOM0zyaqaEpvnvb0acrshkTdsOE6FMtwz5bfRDavOgq4k1g8mCR+Xj6IB7ZLxsMOOHuCvdz21/3cCtTzwKFltSxNUX300ZXjtsrz1pfCU595nBLXzsdV4oRRyedzfYLs6pIiOKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777282977; c=relaxed/simple; bh=1edNpC1S3o1g8pijgXBuglaFSA/F3emKEDJN0MbLjX4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qZZ2B2FjotlE5t/XaiwlmJibqMJv8tWt6hqTs7H1zhC9W3KQ2UOguC5wp2fEGBAwOnRpOd2z8+6CuiwRLKhvIoreXilFxVZTuUp4yJFc0dR+jG0j1O5vhMWKHvXDz16OvrDiAYAOStkgZRFNwBrp2rUxWKINp/5FpIxKqsqooSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=p5kYFP3v; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p5kYFP3v" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43eb05b1875so5840666f8f.3 for ; Mon, 27 Apr 2026 02:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777282975; x=1777887775; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=SOSv4lT2swKkfFsu6N1e/4a2DMIWqM0T1MQJCs7ue+I=; b=p5kYFP3vdy0eLJt3Atr16/wsoN+QPC1oDEvDBq8lVmTQIibc7A7FKjTVGZoyWU3BdI FgUUz2XxmGtxDPwXkvs+TS4mWllYNGhdMkaGZ9yvimW0WJ0/UnhQHLNQ+ZJdpg3HrAGA 4kvBJI6I49f4fjO/RH086B7G5faL/9zf9XbUB8+EfV9lfMD294S41vuEf9zQU0WDtE94 cMiQdS2JCJ6U8zN81GxJCR8Hv/VqfAeSFATws9j97QsxD99t2tD9Zm4xIbIjxz51KhnE E4d6ixveIZ+D2sLN8EjGk0a/x0j2OaWGxMt0jYj023Ud53HtiAhkD5PbNxWNJAzMQFUu Ngbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777282975; x=1777887775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SOSv4lT2swKkfFsu6N1e/4a2DMIWqM0T1MQJCs7ue+I=; b=pOrezDBYqHX6+MYRIGmLOMSdmUXNagTwJrT+42x/aNjw9svjrOqUkG9IWtrnScdEgc rqudEtx5BoEM4WyORYCkDAZxAQK8Hu5ko1lYCNogxQ14xnO0UXkFwv3UV/SMa+nXpzIW 1L7NYJ5+uLd09PKVtmYG6bOooMXzgi+BvTPoz6pZzcaB8YrnBF2kYTdmip8MsP9TXv4G wKaO2k/0SQCRMNwR1zcYEJv0fShSotU9meaKU463FLjI3+4YBVSUjDDK4k9GpJiFgevD bT0i/KFzhw83rzs05S6iKJFsvqLxgtFTqIl1dCCXGwLGXviX+ShIwchP90smL3rQL7HM WumQ== X-Forwarded-Encrypted: i=1; AFNElJ+167rioCNxv/TtZU5N15SWJXfG6ma9ABnqoM3PynpBQSWNrHukpe6aY5L2+vaqCPwop851ZcE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1aYevCE5jsagim//yTTbbGwJ6Y19DZ1V9j+CvlpmuEfBlr9ME CzVySzC4FIALQmSTuggU5MJu96lxLp37gJsgW4iMbNsVWI3+p28LEQCc X-Gm-Gg: AeBDies/22uj2AenZNuvdil3YC+dNrYwbj5UOsCf1XOZs92ccustl/00p7caoy+vc1i Tn/vPbnz9Z/4qhITsdiv/8+k+w2+fBfoizXAnJzMdJQWToGyhJLb5p8xqxFLRE9dLpPl91NHTYE J09JkLR6KAQp4tugPn5Ej2G0TpiByDkD9QsZVfKAsSlDC5JadLCVHFQVhvUmy1eqLsFJNCz/gat DwhC/tjWLvyiYNlKJwGQ/Delw4GjxAU2Thrq2gtfZ4XItfr+C/CAD0H+FbmZhMb6DxpeyZWCTs8 JWEG7tQmZmXofZ3Z4CS0kYKUm93eAEg2UjeyEl3XOtVWDULVPUKYkQoCEH5SyyHpm3DqdkhC1Sz aSz6spRe6H9krpBGSt5qrtwRoUBATyuQKl8960IvPDYRjEmVbaSdTKhSHlM9u3wOO8TuniHxD8z zASQSn8zyrBeEa8yfQ7uqg1chANLAAVp+L3PahGamcYUmUTQU3cmvXvDBKEkzR+79Nj0+RUEZCG MM= X-Received: by 2002:a05:6000:250f:b0:43d:68ad:3b7f with SMTP id ffacd0b85a97d-43fe3dd397dmr66949426f8f.21.1777282974651; Mon, 27 Apr 2026 02:42:54 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4411c9f4f03sm48891743f8f.1.2026.04.27.02.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 02:42:54 -0700 (PDT) Date: Mon, 27 Apr 2026 10:42:52 +0100 From: David Laight To: Johannes Berg Cc: Yury Norov , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin\" , Andy Lutomirski , Peter Zijlstra , Jonathan Cameron , David Lechner , Nuno =?UTF-8?B?U8Oh?= , Andy Shevchenko , Ping-Ke Shih , Richard Cochran , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexandre Belloni , Yury Norov , Rasmus Villemoes , Hans de Goede , Linus Walleij , Sakari Ailus , Salah Triki , Achim Gratz , Ben Collins , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-rtc@vger.kernel.org Subject: Re: [PATCH 1/9] bitfield: add FIELD_GET_SIGNED() Message-ID: <20260427104252.5203a50e@pumpkin> In-Reply-To: References: <20260417173621.368914-1-ynorov@nvidia.com> <20260417173621.368914-2-ynorov@nvidia.com> <6170788fcab2ec835597e3d7411928d36850c20a.camel@sipsolutions.net> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 27 Apr 2026 10:29:21 +0200 Johannes Berg wrote: > On Fri, 2026-04-24 at 12:35 -0400, Yury Norov wrote: > > > I (personally) tend to prefer the "__MAKE_OP" versions (*_get_bits() > > > etc.), in particular because WiFi and firmware interfaces deal a lot > > > with fixed endian fields. > > > > I don't like that __MAKE_OP magic because whatever it generates is not > > greppable. And because we disable strict type checks for kernel, but > > this API claims to typecheck the parameters for the user. So, the > > following compiles well: > > > > u64 val = 0; > > ret = le16_get_bits(val, GENMASK(15, 10)); > > > > I don't like autogeneration in general. We generate, for example, > > be32_get_bits(), but never use it. > > That's a lot of "I don't like", but whatever. > > > > We don't even know the level of the bloat. > > These are static inlines so there's no binary cost, and given that > you're complaining about them being generated you can't really *also* > complain about too much code... There is a measurable compile-time cost for processing the definitions of static inlines even when they aren't used. While processing the definitions of #defines is cheap, processing the expansions can be measurable. Particularly when expansions get nested as often happens when GENMASK() is used as an argument to FIELD_xxx(). Even trivial #defines can affect compile times. The 'size' check in READ_ONCE() (etc) costs about 1%. (1% may not sound much, but find 10 of them and it becomes significant.) I suspect a lot of that is adding the extra external function to hold the error message. David > > > > Any chance it'd be simple to generate u32_get_bits_signed() etc.? Could > > > be especially useful for le32_get_bits_signed() for example, to have the > > > endian conversion built-in unlike FIELD_GET_SIGNED(). > > > > Maybe this: > > > > FIELD_GET_SIGNED(mask, le32_to_cpu(reg)) > > Awful. "I don't like". But we rarely deal with bit-packed signed values > anyway. > > johannes >