[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfrA7S033=mKkUj-SnWWyM9pwEiM_Umrrd4arpf1SNw6Q@mail.gmail.com>
Date: Wed, 24 Aug 2022 20:45:01 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Yury Norov <yury.norov@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Guenter Roeck <linux@...ck-us.net>,
Dennis Zhou <dennis@...nel.org>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Alexey Klimov <aklimov@...hat.com>,
Kees Cook <keescook@...omium.org>,
Andy Whitcroft <apw@...onical.com>
Subject: Re: [PATCH v2 1/3] lib/find_bit: introduce FIND_FIRST_BIT() macro
On Wed, Aug 24, 2022 at 4:19 PM Yury Norov <yury.norov@...il.com> wrote:
> On Wed, Aug 24, 2022 at 12:10:02PM +0300, Andy Shevchenko wrote:
> > On Wed, Aug 24, 2022 at 4:51 AM Yury Norov <yury.norov@...il.com> wrote:
...
> > > +#define FIND_FIRST_BIT(EXPRESSION, size) \
> > > +({ \
> > > + unsigned long idx, val, sz = (size); \
> > > + \
> > > + for (idx = 0; idx * BITS_PER_LONG < sz; idx++) { \
> >
> > I think we can do slightly better:
> >
> > for (unsigned long idx = 0; idx < sz; idx += BITS_PER_LONG) {
> > unsigned long val;
>
> This will blow up the EXPRESSION. We can mitigate it on user side:
I'm not sure I understand how EXPRESSION is involved in all this. What
I proposed is to replace the for-loop one-by-one to
one-by-BITS_PER_LONG. But okay, I have re-read the above patch and now
I see what you are doing, basically you use internal variables of the
macro in the EXPRESSION. Hmm...
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists