From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Yury Norov <yury.norov@gmail.com>,
Lucas De Marchi <lucas.demarchi@intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org,
Andi Shyti <andi.shyti@linux.intel.com>,
David Laight <David.Laight@aculab.com>,
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
Jani Nikula <jani.nikula@intel.com>
Subject: Re: [PATCH v5 0/7] bits: Fixed-type GENMASK()/BIT()
Date: Thu, 6 Mar 2025 23:56:54 +0900 [thread overview]
Message-ID: <34c42bf9-a9e6-41db-9efb-a32bb253b4d2@wanadoo.fr> (raw)
In-Reply-To: <Z8mc8t_OJzUGFjH-@smile.fi.intel.com>
On 06/03/2025 at 22:02, Andy Shevchenko wrote:
> On Thu, Mar 06, 2025 at 08:29:51PM +0900, Vincent Mailhol via B4 Relay wrote:
>> Introduce some fixed width variant of the GENMASK() and the BIT()
>> macros in bits.h. Note that the main goal is not to get the correct
>> type, but rather to enforce more checks at compile time. For example:
>>
>> GENMASK_U16(16, 0)
>>
>> will raise a build bug.
>>
>> This series is a continuation of:
>>
>> https://lore.kernel.org/intel-xe/20240208074521.577076-1-lucas.demarchi@intel.com
>>
>> from Lucas De Marchi. Above series is one year old. I really think
>> that this was a good idea and I do not want this series to die. So I
>> am volunteering to revive it.
>>
>> Meanwhile, many changes occurred in bits.h. The most significant
>> change is that __GENMASK() was moved to the uapi headers.
>>
>> In v4 an onward, I introduce one big change: split the definition of
>> the asm and non-asm GENMASK(). I think this is controversial.
>> Especially, Yury commented that he did not want such split. So I
>> initially implemented a first draft in which both the asm and non-asm
>> version would rely on the same helper macro, i.e. adding this:
>>
>> #define __GENMASK_t(t, w, h, l) \
>
> I thought we agreed on renaming...
>
>> (((t)~_ULL(0) - ((t)1 << (l)) + 1) & \
>> ((t)~_ULL(0) >> (w - 1 - (h))))
>>
>> to uapi/bits.h. And then, the different GENMASK()s would look like
>> this:
>>
>> #define __GENMASK(h, l) __GENMASK_t(unsigned long, __BITS_PER_LONG, h, l)
>
> Ditto.
I forgot to update the cover letter, my bad…
>> and so on.
>>
>> I implemented it, and the final result looks quite ugly. Not only do
>> we need to manually provide the width each time, the biggest concern
>> is that adding this to the uapi is asking for trouble. Who knows how
>> people are going to use this? And once it is in the uapi, there is
>> virtually no way back.
>>
>> Finally, I do not think it makes sense to expose the fixed width
>> variants to the asm. The fixed width integers type are a C
>> concept. For asm, the long and long long variants seems sufficient.
>>
>> And so, after implementing both, the asm and non-asm split seems way
>> more clean and I think this is the best compromise. Let me know what
>> you think :)
>>
>> As requested, here are the bloat-o-meter stats:
>>
>> $ ./scripts/bloat-o-meter vmlinux_before.o vmlinux_after.o
>> add/remove: 0/0 grow/shrink: 4/2 up/down: 5/-4 (1)
>> Function old new delta
>> intel_psr_invalidate 666 668 +2
>> mst_stream_compute_config 1652 1653 +1
>> intel_psr_flush 977 978 +1
>> intel_dp_compute_link_config 1327 1328 +1
>> cfg80211_inform_bss_data 5109 5108 -1
>> intel_drrs_activate 379 376 -3
>> Total: Before=22723481, After=22723482, chg +0.00%
>>
>> (done with GCC 12.4.1 on a defconfig)
>
> What defconfig? x86_64_defconfig?
Yes, x86_64 defconfig.
Yours sincerely,
Vincent Mailhol
next prev parent reply other threads:[~2025-03-06 14:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 11:29 Vincent Mailhol via B4 Relay
2025-03-06 11:29 ` [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK() Vincent Mailhol via B4 Relay
2025-03-06 13:05 ` Andy Shevchenko
2025-03-06 15:07 ` Vincent Mailhol
2025-03-06 17:51 ` Andy Shevchenko
2025-03-06 14:34 ` Lucas De Marchi
2025-03-06 17:10 ` Vincent Mailhol
2025-03-13 4:16 ` Lucas De Marchi
2025-03-13 6:06 ` Vincent Mailhol
2025-03-06 19:23 ` David Laight
2025-03-07 9:58 ` Vincent Mailhol
2025-03-07 13:27 ` David Laight
2025-03-07 15:50 ` Vincent Mailhol
2025-03-09 1:58 ` David Laight
2025-03-09 10:23 ` David Laight
2025-03-10 10:46 ` Vincent Mailhol
2025-03-06 11:29 ` [PATCH v5 2/7] bits: introduce fixed-type genmasks Vincent Mailhol via B4 Relay
2025-03-06 13:08 ` Andy Shevchenko
2025-03-06 16:08 ` Vincent Mailhol
2025-03-06 17:53 ` Andy Shevchenko
2025-03-06 11:29 ` [PATCH v5 3/7] bits: introduce fixed-type BIT_U*() Vincent Mailhol via B4 Relay
2025-03-06 11:29 ` [PATCH v5 4/7] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*() Vincent Mailhol via B4 Relay
2025-03-06 11:29 ` [PATCH v5 5/7] test_bits: add tests for __GENMASK() and __GENMASK_ULL() Vincent Mailhol via B4 Relay
2025-03-13 4:13 ` Lucas De Marchi
2025-03-13 6:00 ` Vincent Mailhol
2025-03-13 13:15 ` Lucas De Marchi
2025-03-06 11:29 ` [PATCH v5 6/7] test_bits: add tests for GENMASK_U*() Vincent Mailhol via B4 Relay
2025-03-06 11:29 ` [PATCH v5 7/7] test_bits: add tests for BIT_U*() Vincent Mailhol via B4 Relay
2025-03-06 13:11 ` Andy Shevchenko
2025-03-06 16:08 ` Vincent Mailhol
2025-03-06 17:55 ` Andy Shevchenko
2025-03-07 10:11 ` Vincent Mailhol
2025-03-07 16:07 ` Andy Shevchenko
2025-03-07 16:47 ` Vincent Mailhol
2025-03-13 4:10 ` Lucas De Marchi
2025-03-06 13:02 ` [PATCH v5 0/7] bits: Fixed-type GENMASK()/BIT() Andy Shevchenko
2025-03-06 14:56 ` Vincent Mailhol [this message]
2025-03-06 13:12 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34c42bf9-a9e6-41db-9efb-a32bb253b4d2@wanadoo.fr \
--to=mailhol.vincent@wanadoo.fr \
--cc=David.Laight@aculab.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andi.shyti@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lucas.demarchi@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®