[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191028141734.GD29652@ziepe.ca>
Date: Mon, 28 Oct 2019 11:17:34 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: Sultan Alsawaf <sultan@...neltoast.com>
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 Fri, Oct 25, 2019 at 02:33:58PM -0700, Sultan Alsawaf wrote:
>
> Signed-off-by: Sultan Alsawaf <sultan@...neltoast.com>
> include/linux/scatterlist.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 556ec1ea2574..73f7fd6702d7 100644
> +++ b/include/linux/scatterlist.h
> @@ -146,7 +146,10 @@ static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
> * Loop over each sg element, following the pointer to a new list if necessary
> */
> #define for_each_sg(sglist, sg, nr, __i) \
> - for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
> + for (__i = 0, sg = (sglist); __i < (nr); \
> + likely(++__i % (SG_MAX_SINGLE_ALLOC - 1) || \
> + (__i + 1) >= (nr)) ? sg++ : \
> + (sg = sg_chain_ptr(sg + 1)))
This is a big change in the algorithm, why are you sure it is OK?
Did you compare with just inlining sg_net?
Jason
Powered by blists - more mailing lists