Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1642059
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] sched: remove sched_find_first_bit() |
| Date | 2017-05-15 23:10 +0200 |
| Message-ID | <tHvpD-4RT-25@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <tHqJk-1Wb-11@gated-at.bofh.it> <tHqJj-1Wb-9@gated-at.bofh.it> <tHuWC-4t8-29@gated-at.bofh.it> <tHuWC-4t8-27@gated-at.bofh.it> <tHvpD-4RT-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, May 15, 2017 at 10:58 PM, Yury Norov <ynorov@caviumnetworks.com> wrote:
> On Mon, May 15, 2017 at 10:31:17PM +0200, Arnd Bergmann wrote:
>> On Mon, May 15, 2017 at 6:17 PM, Yury Norov <ynorov@caviumnetworks.com> wrote:
>>
> Yes, something like this. But size is not the multiple of BITS_PER_LONG in
> general. This should work better:
>
> switch (round_up(size), BITS_PER_LONG) {
> case BITS_PER_LONG * 4:
> if (addr[0])
> goto ret;
> addr++;
> idx += BITS_PER_LONG;
> case BITS_PER_LONG * 3:
> if (addr[0])
> goto ret;
> addr++;
> idx += BITS_PER_LONG;
> case BITS_PER_LONG * 2:
> if (addr[0])
> goto ret;
> addr++;
> idx += BITS_PER_LONG;
> case BITS_PER_LONG * 1:
> if (addr[0])
> goto ret;
> addr++;
> idx += BITS_PER_LONG;
> return idx;
> }
>
> return __find_first_bit(addr, size);
>
> ret:
> return idx + min(__ffs(addr[0]), size % BITS_PER_LONG;
> }
>
> (I didn't test it yet though)
>
>> However, on architectures that rely on
>> include/asm-generic/bitops/__ffs.h or something
>> similarly verbose, this would just add needless bloat
>> to the size rather than actually making a difference
>> in performance.
I tried something along these lines earlier and couldn't
get it to produce the comparable object code in the
common case.
For sched_find_first_bit() I was able to cheat and
pass 128 as the length (along with a comment), and
most others are either multiples of BITS_PER_LONG,
or they are not constant.
Arnd
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] sched: remove sched_find_first_bit() Ingo Molnar <mingo@kernel.org> - 2017-05-14 20:10 +0200
Re: [PATCH] sched: remove sched_find_first_bit() Arnd Bergmann <arnd@arndb.de> - 2017-05-15 18:10 +0200
Re: [PATCH] sched: remove sched_find_first_bit() Arnd Bergmann <arnd@arndb.de> - 2017-05-15 22:40 +0200
Re: [PATCH] sched: remove sched_find_first_bit() Arnd Bergmann <arnd@arndb.de> - 2017-05-15 23:10 +0200
Re: [PATCH] sched: remove sched_find_first_bit() Ingo Molnar <mingo@kernel.org> - 2017-05-16 10:40 +0200
Re: [PATCH] sched: remove sched_find_first_bit() Ingo Molnar <mingo@kernel.org> - 2017-05-18 09:20 +0200
csiph-web