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: <20191028162955.GB32593@sultan-box.localdomain>
Date:   Mon, 28 Oct 2019 09:29:55 -0700
From:   Sultan Alsawaf <sultan@...neltoast.com>
To:     Jason Gunthorpe <jgg@...pe.ca>
Cc:     "Martin K. Petersen" <martin.petersen@...cle.com>,
        Thomas Hellstrom <thellstrom@...are.com>,
        Palmer Dabbelt <palmer@...ive.com>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Ming Lei <ming.lei@...hat.com>,
        Gal Pressman <galpress@...zon.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scatterlist: Speed up for_each_sg() loop macro

On Mon, Oct 28, 2019 at 01:23:20PM -0300, Jason Gunthorpe wrote:
> On Mon, Oct 28, 2019 at 09:18:48AM -0700, Sultan Alsawaf wrote:
> > On Mon, Oct 28, 2019 at 11:17:34AM -0300, Jason Gunthorpe wrote:
> > > This is a big change in the algorithm, why are you sure it is OK?
> > 
> > I'm sure it's OK because the test module I provided in the commit message
> > encapsulates all the possible edge cases of sg chaining:
> > -An sglist with >=1 && <=(SG_MAX_SINGLE_ALLOC-1) nents (no chaining, the last
> >  element in the array is unused)
> > -An sglist with SG_MAX_SINGLE_ALLOC nents (no chaining, the last element in the
> >  array isn't an sg chain link)
> > -An sglist with >SG_MAX_SINGLE_ALLOC && <=2*(SG_MAX_SINGLE_ALLOC-1) nents (there
> >  is one chain to another array, and the other array's last element is unused)
> > -An sglist with (2*SG_MAX_SINGLE_ALLOC)-1 nents (there is one chain to another
> >  array, and the other array's last element isn't an sg chain link)
> > -An sglist with 2*SG_MAX_SINGLE_ALLOC nents (there are two chains to other
> >  arrays, and the 3rd array contains 2 sgs & its last element is unused)
> > -An sglist with >2*SG_MAX_SINGLE_ALLOC && <(3*SG_MAX_SINGLE_ALLOC)-1 nents
> >  (there are two chains to other arrays, and the 3rd array's last element isn't
> >  an sg chain)
> 
> This testing is making assumptions about how 'nr' is used and the
> construction of the sgl though
> 
> If any chains are partially populated, or for some reason the driver
> starts at a different sgl, it will break. You'll need to somehow
> show none of those possibilities are happening.

I haven't personally witnessed any for_each_sg() use that starts at a different
sgl, but this is something I considered as well. The optimal solution would be
to alter for_each_sg() to replace the `sg` and `nr` arguments with a single
sg_table pointer argument instead. Users that genuinely need to start at a
different sgl can just craft their own for-loop with sg_next.

This would require changes to a lot of files though, and I wanted to see how the
mailing list felt about this change before embarking on that.

Sultan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ