From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 646333B2FD6 for ; Mon, 27 Apr 2026 09:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777282977; cv=none; b=SFl+pHKQzfKYz9QjLcLC6MYHS6bw1jiUqujCwTI8yhwoeuASm2rUly61F/FTTLs0nxfAMCmQFssmZIOVtVskwbUX/3Si2PbpCCIhG550zvZ6zyoJlGhgixljRSxh2EqFI5jkGZeU7Eo099yHMQJa3p2OfXGg9D4Qsuiw5cSa4co= 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.49 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-f49.google.com with SMTP id ffacd0b85a97d-43d7badbd7dso4893024f8f.2 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=BL5YU7OR2Knu0vdUXGBT9j4A84A7a24RmOagho5exfrMoGxLMdn94uN49r0rbvT+iB //zZ+XcHN4vjZ4UdCTNFePzFwrtKaVgEEazb/yT3b78MasSZzgGDr7iK+Ol7WG5yxctI jO5bv7Q8ANOtfKmu5CEWQDbPYH11Ydkd2PapXEsa4kI2z3y+4a3VNn5hapGeU/g/aXCc r+3rPK0/YUTkIW9IKtwEa5OoYp1IiMvjonWstnw3qlHhWcXXZINkM2ZDPPEMhkn5AFh0 wBYLVm4AYbkqRU5+fl9HZ453qCUx7TQizCG46xLsMjsFAjhzc+yPZAbdaGBd/0OqVBde BARQ== X-Forwarded-Encrypted: i=1; AFNElJ/SsC3wwJyfuQWO4b6pwCEsWkTt5Lza5xn7zwrLMv8ahWuLb4160P4Fv96xcA6+owbZ8S5vSODei8M=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1LbVus6KNs8hWe4/M07p0fkvBTHYANlcby4jFDeMXQ2qRqyou nePMq/1sQ++jlMVBEZJ2/jbTJ2i7vQRRbg6o8L3gZbRb9G++LI0wT4Ds X-Gm-Gg: AeBDietp9pXJ3uUSIphQoio3MWd/umlBs6D1KVtSEhhwE3g64pX+SGZGioCR7MR8uY4 i7N557KtcN9rMqnKBkp6+XJxhiJTqQGSf2OllVG0tQw/1B6V5dGyeI15fBEF2fMOLI150gxmFpo 5gsU2MNgjl+R9XTB9vwufGH4xg48CksjENJLRfl5H60N0mEU2jJW3pa7Z7dB2WJC0rvKOD7X5Eo 4p3KbVrPBxF851X7SHhaBIJikiXNMp5Iw+vvlJbR6tEAYcEA4yg7myFpADweOMcSLzzxOPHX494 j9qsb4VU6e4Ue50lJfKdGAFpAh3r/SXRmpjhP44oFOCXkStk+6Zn1ZGnkGZVC4dbslkZ3Jryw0t ya+5LBzeo5GjyVEfogDUyJ62gCN0gVVaKwJ6r+my7VEqFWLE1X124kFrfS044P0aQLn3XAAcMUQ uOJI2Kj+n2HFw84BrFmMI+1w52Jm2B/6CgtstapzZiTZPSqkZkN4MjGHZfBK8NGMGcDKVPxBZ14 W0= 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: linux-iio@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 >