Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3793099ybg; Mon, 28 Oct 2019 19:40:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCpzF2gvwRiRHTxAoU7yLlMSN8AkttLhYSSbaw6oRvoPaIMJnV8pdnFY86mJwFFgy+vR02 X-Received: by 2002:a17:906:edd7:: with SMTP id sb23mr996929ejb.168.1572316837015; Mon, 28 Oct 2019 19:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572316837; cv=none; d=google.com; s=arc-20160816; b=DoboH9iLdH4Dq4v7ycPLPa24XaiNntX5yFN2FdmCh89Aq/LHpOfX+AcJFe4pd31kvM YxFbG3ihvg1toHxzbMpRgcgzfUTPuKdWFTXkBuHjY4uKM9L+gtG2swMIhG/F4GCJe99j dEE2mGSzE2FqV8smcj+MVoYGwsE+d5sQsb47ptfAxfNqvfPIr3o4pJj3Y4IPL7hg4k1C bC9967fQE1+9c602Aot6c7ooseG3M+//BnNY52uEHWzPuFcn2n15qESjAaJqvn1DFZt/ cBiszn1i2QRjkAcLg0fSVD7LPAhuq4VlsG7mLGhSxI7RaGs5AD0xh8qpRA0xtxypTPuj 1/Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KcIXjOVnUdM4ahq3ItI2UTdzBoJ7szBep3RUJgsKNMg=; b=FiGsMkxAEkOc9980o8UU5XsBN8qjAtqdrKbhTgFUgs/ef04Kf6pnChDdP0JUOn/0gT MJCOdk6fRxzYXs6Rpj3uNytNYoHqW3WoJf//LYfQqt55+4Ia/hnOFEhALqyQpfjmKhLe qLLtRRjVn6FCR3lUqpVd/BkpOnuBmzPt3Se66SCuRmVOpbDAMYmlG/WDqyjbpk0XU3Ge +AqH0M9Fve4kW20nZeK8B5qZOhNqwTJhjp/EC3p5T34kjr7FTG8909iWPapxIFUFKLQb /s+B4/XQYjM+evnetmal1wtvsZCZMVD2vMC3KM8yilU64v9PasNhq5BFHL/XudMIzq5y ft3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="OPLLBr/Y"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x91si6261114ede.344.2019.10.28.19.40.13; Mon, 28 Oct 2019 19:40:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="OPLLBr/Y"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390014AbfJ1ORh (ORCPT + 99 others); Mon, 28 Oct 2019 10:17:37 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:38388 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730033AbfJ1ORg (ORCPT ); Mon, 28 Oct 2019 10:17:36 -0400 Received: by mail-qk1-f194.google.com with SMTP id e2so41292qkn.5 for ; Mon, 28 Oct 2019 07:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KcIXjOVnUdM4ahq3ItI2UTdzBoJ7szBep3RUJgsKNMg=; b=OPLLBr/YxqYbXp/yOBTapSj2Gj52cx4piu3vrs1Y/lc0X7F4kDzY+M4E2vhAKVGS6S /WrEccktrTLtpBkA2Pd2cXzjV3ulDJGMapESqu2bf6khkLCKMUlxJvMGiR+LQIAYsPYN kp+yo6uK0Xe1gswA3folr0aaWwLUJpwYuG9eoQS1VjxjiFr1tRIh3wFhF5oCwRNvoA4D dWYpKDG5VDo7JYx0YoiHOYS6q+uCbacxgtrU9TrBkcDblok81ZW14aBlabgJ8HzisBq7 9NaGzXpwpOvMjz+vTEETSwSHuHyThBgeEu1jv6D7GayHPkIiWvEnUTaVnJ8sA55GBgsa NOZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KcIXjOVnUdM4ahq3ItI2UTdzBoJ7szBep3RUJgsKNMg=; b=kXMmnF8rfPiHDo1VljIDpki0sLbnJPv1k6qj8a03PyHQGFTLUMVjahW2j+1P8LSD3M c/pgRWYq27IA9/K7vdKYhV5WhTf5q49jUVdycFp0VjYGaET2cs26JW0snn+FI9O81WmT ObMrcDbpOVr0h1uTfHJgEXct68MH6VjgM/Qic/rucw1YowhlcpU2OQztMJOH2olRhsWD KmEeec2JuWQvqWfkaxQIVcV+VfZFyLP7Lgp/ICeFRwo5nDmW9WQbgw9xwGKKZCkqKsyL fup9NDdD5sBGQhAybhH2jPcLKXPCqNxPIx4kVcGTD1ACvc1cLWuX7XJeHrb6Vqo4sg2f jwxw== X-Gm-Message-State: APjAAAVU28Ic1Gofot/23p/ifqFh0LCj7i0twtibbweYRF1n73aan0BF 0OWWxypbfLJpoxUALP7UgWOlNQ== X-Received: by 2002:a37:9b50:: with SMTP id d77mr16266180qke.349.1572272255692; Mon, 28 Oct 2019 07:17:35 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-180.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.180]) by smtp.gmail.com with ESMTPSA id f11sm5243892qkk.76.2019.10.28.07.17.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Oct 2019 07:17:35 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1iP5pu-0002Me-Jm; Mon, 28 Oct 2019 11:17:34 -0300 Date: Mon, 28 Oct 2019 11:17:34 -0300 From: Jason Gunthorpe To: Sultan Alsawaf Cc: "Martin K. Petersen" , Thomas Hellstrom , Palmer Dabbelt , Sakari Ailus , Ming Lei , Gal Pressman , linux-kernel@vger.kernel.org Subject: Re: [PATCH] scatterlist: Speed up for_each_sg() loop macro Message-ID: <20191028141734.GD29652@ziepe.ca> References: <20191025213359.7538-1-sultan@kerneltoast.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191025213359.7538-1-sultan@kerneltoast.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 25, 2019 at 02:33:58PM -0700, Sultan Alsawaf wrote: > > Signed-off-by: Sultan Alsawaf > 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