Thread (37 messages) 37 messages, 4 authors, 2023-07-20

Re: [PATCH v3 1/5] lib/bitmap: add bitmap_{set,get}_value()

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2023-07-18 14:04:41
Also in: lkml

On Tue, Jul 18, 2023 at 11:30:00AM +0200, Alexander Potapenko wrote:
On Mon, Jul 17, 2023 at 5:51 PM Yury Norov [off-list ref] wrote:
quoted
On Mon, Jul 17, 2023 at 01:37:04PM +0200, Alexander Potapenko wrote:
...
quoted
When nbits == 0, copy-like functions shouldn't touch any memory. See how
other bitmap and find_bit functions hold it.
I think this is different from what other bitmap functions do, but it
should be enough to bail out on !nbits, i.e.:

    if (!nbits)
        return 0;

You probably meant adding a __builtin_constant_p() (which is used all
over the place in bitmap.h), but:
 - the compiler won't have problem optimizing away the code for a
constant nbits=0;
 - we anyway need a dynamic check for the case nbits is not constant
(for both bitmap_get_value() and bitmap_set_value(), I assume).

What do you think?
The idea behind is to eliminate the code completely for the cases nbits != 0.
In your case the dynamic check will be there. That's what we want to avoid.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help