lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdXd4BC7mqmKU-qA3KpVUVS1gPRw8OTu0Mi=aEUJxcd+KA@mail.gmail.com>
Date:	Fri, 20 Nov 2015 09:52:29 +0100
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Jia He <hejianet@...il.com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Linux-Arch <linux-arch@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Denys Vlasenko <dvlasenk@...hat.com>,
	Kyungmin Park <kyungmin.park@...sung.com>,
	Michal Nazarewicz <mina86@...a86.com>,
	Yury Norov <yury.norov@...il.com>, Tejun Heo <tj@...nel.org>,
	Martin Kepplinger <martink@...teo.de>,
	George Spelvin <linux@...izon.com>,
	Ingo Molnar <mingo@...nel.org>, Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH 2/3] lib: Introduce 2 find bit api: all_is_bit_{one,zero}

On Thu, Nov 19, 2015 at 3:31 AM, Jia He <hejianet@...il.com> wrote:
> --- a/lib/find_bit.c
> +++ b/lib/find_bit.c
> @@ -131,6 +131,56 @@ unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
>  EXPORT_SYMBOL(find_last_bit);
>  #endif
>
> +#ifndef all_bit_is_zero
> +/*
> + * return val: 1 means all bit is zero
> + */
> +unsigned int all_bit_is_zero(const unsigned long *addr, unsigned size)
> +{
> +       unsigned long idx;
> +       unsigned long mask = size;
> +
> +       if (unlikely(size == 0))
> +               return 1;
> +
> +       if (size > BITS_PER_LONG) {
> +               for (idx = 0; idx * BITS_PER_LONG < size; idx++)

Please move the multiplication (yes, a shift) out of the loop. Not all CPUs
have barrel shifters.

> +                       if (addr[idx])
> +                               return 0;
> +
> +               mask = size - (idx - 1) * BITS_PER_LONG;
> +       }
> +
> +       return !(*addr & BITMAP_LAST_WORD_MASK(mask));
> +}
> +EXPORT_SYMBOL(all_bit_is_zero);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ