Messages in this thread | | | Date | Mon, 28 Oct 2019 09:18:48 -0700 | From | Sultan Alsawaf <> | Subject | Re: [PATCH] scatterlist: Speed up for_each_sg() loop macro |
| |
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)
I just made my module test nents >=1 && <=3*SG_MAX_SINGLE_ALLOC for simplicity. My proposed for_each_sg() also handles nents==0 the same as before by doing nothing.
> Did you compare with just inlining sg_net?
Yes. Forcefully inlining sg_next() had no impact on performance.
Sultan
| |