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: <ZN4tB7jkQrX/TKnh@yury-ThinkPad>
Date:   Thu, 17 Aug 2023 07:21:59 -0700
From:   Yury Norov <yury.norov@...il.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     linux-kernel@...r.kernel.org,
        Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: Re: [PATCH] bitmap: optimize bitmap_remap()

On Thu, Aug 17, 2023 at 12:38:28PM +0300, Andy Shevchenko wrote:
> On Thu, Aug 17, 2023 at 12:37:05PM +0300, Andy Shevchenko wrote:
> > On Tue, Aug 15, 2023 at 04:59:34PM -0700, Yury Norov wrote:
> 
> ...
> 
> > >  		int n = bitmap_pos_to_ord(old, oldbit, nbits);
> > >  
> > > +		bit = (n < 0) ? oldbit :	/* identity map */
> > 
> > Can't you also optimize this case?
> > 
> > Something like
> > 
> >   bitmap_xor(tmp, old, new) // maybe even better approach, dunno
> 
> >   bitmap_empty(tmp) // can be replaced by find first bit
> 
> Or reuse bitmap_weight()...

That way it wouldn't work, but I think something like this would:

         if (dst == src)         /* following doesn't handle inplace remaps */
                 return;

         w = bitmap_weight(new, nbits);
         if (w == 0) {
                 bitmap_copy(dst, src, nbits);
                 return;
         }

         /* Identity part */
         bitmap_andnot(dst, src, old, nbits);
         for_each_and_bit(oldbit, src, old, nbits) {
                 int n = bitmap_weight(old, oldbit);
                 __set_bit(find_nth_bit(new, nbits, n % w), dst);
         }

And it needs bitmap_weight_from() and find_nth_bit_from() to avoid
Schlemiel the Painter's problem.

You're right. This has a room for more optimizations. Thanks for
discussion. Need to give it a run.

Thanks,
Yury

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ