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: <YAlYwZOO6QyaR6UZ@smile.fi.intel.com>
Date:   Thu, 21 Jan 2021 12:34:41 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Yury Norov <yury.norov@...il.com>
Cc:     linux-m68k@...ts.linux-m68k.org, linux-kernel@...r.kernel.org,
        linux-sh@...r.kernel.org, linux-arch@...r.kernel.org,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        Yoshinori Sato <ysato@...rs.sourceforge.jp>,
        Rich Felker <dalias@...c.org>, Arnd Bergmann <arnd@...db.de>,
        Dennis Zhou <dennis@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Wolfram Sang <wsa+renesas@...g-engineering.com>,
        David Sterba <dsterba@...e.com>,
        Stefano Brivio <sbrivio@...hat.com>,
        "Ma, Jianpeng" <jianpeng.ma@...el.com>,
        Wei Yang <richard.weiyang@...ux.alibaba.com>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Rasmus Villemoes <rasmus.villemoes@...vas.dk>
Subject: Re: [PATCH 5/6] lib: add fast path for find_next_*_bit()

On Wed, Jan 20, 2021 at 04:06:29PM -0800, Yury Norov wrote:
> Similarly to bitmap functions, find_next_*_bit() users will benefit
> if we'll handle a case of bitmaps that fit into a single word. In the
> very best case, the compiler may replace a function call with a
> single ffs or ffz instruction.

> +	if (small_const_nbits(size)) {
> +		unsigned long val;
> +
> +		if (unlikely(offset >= size))
> +			return size;

> +		val = *addr & BITMAP_FIRST_WORD_MASK(offset)
> +				& BITMAP_LAST_WORD_MASK(size);

Seems like a new helper can be introduced (BITS or BITMAP namespace depending
on the decision):

#define	_OFFSET_SIZE_MASK(o,s)					\
	(BITMAP_FIRST_WORD_MASK(o) & BITMAP_LAST_WORD_MASK(s))

		val = *addr & BITMAP_OFFSET_SIZE_MASK(offset, size);

And so on below.

> +		return val ? __ffs(val) : size;
> +	}

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ