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]
Date:	Tue, 24 Mar 2015 15:53:03 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Yury Norov <yury.norov@...il.com>
Cc:	linux@...izon.com, klimov.linux@...il.com,
	linux@...musvillemoes.dk, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib: bitmap_[empty,full]: remove code duplication

On Mon, 16 Mar 2015 20:56:39 +0300 Yury Norov <yury.norov@...il.com> wrote:

> Function 'bitmap_empty' has it's own implementation.
> But it's clearly as simple as:
> 	"find_first_bit(src, nbits) == nbits"
> The same is true for 'bitmap_full'.
> 
> Underscored versions of 'bitmap_[empty,full]' are not
> needed anymore and so removed too.
> 
> Boot-tested on Core i7-2630QM.
> 
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -285,18 +285,12 @@ static inline int bitmap_subset(const unsigned long *src1,
>  
>  static inline int bitmap_empty(const unsigned long *src, unsigned nbits)
>  {
> -	if (small_const_nbits(nbits))
> -		return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
> -	else
> -		return __bitmap_empty(src, nbits);
> +	return find_first_bit(src, nbits) == nbits;
>  }

But we lost the small_const_nbits() optimization, and that will be a
common case.

Would it be better to do

	if (small_const_nbits(...))
		...
	else
		find_first_bit(...);

?

--
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