Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3938441ybg; Mon, 28 Oct 2019 23:01:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHDkGYEemOE/vWtAc/Sz4kgn/V/pfu3D6XSEi2jhId7UTvy0Ik5S76/jL5hpYqYgq9zE5q X-Received: by 2002:aa7:cd64:: with SMTP id ca4mr16171940edb.121.1572328903005; Mon, 28 Oct 2019 23:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572328902; cv=none; d=google.com; s=arc-20160816; b=zHRSvvzQc4g3BxiMoxWkT9XO8OEvHzDl+PkFHTNiLVd1+xCxQsspi0ffPtlG8IX+V5 YDlIdsLosmAcP260GXUsSF0QSU0+9HXoGeT0/DNTqzyRx0kxwBDj8JP22OKfHr4mSbfJ CUbTfTD/B8w1WySVylumbOJAwDflWpgyAFN0T9WZ6lT/LulD4ZGvbOGrPpK2TvkYsWQ5 Y0HpvOTeEbJhP/DecrVmsOuvcc+IVOAcNvhu4G1MqRX6FfdFpXD8nWBlM7zXzHonPKN3 0RTpnSlNH0fPG7l485C7/qZIaXFFkPc6hkonjCQ57qayW7jDfEtWTIgNq2+8oB7rEzcW JrpQ== 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=ghgZezvv9fwHiSgWNtPdvDWZAZD8rMK2AMplAo4xWgQ=; b=X9KccG0eZ3HceGI2fj6re1eK1WSoNcWZRUjMiSneWvQTdHU72oFFbfy9tflVMF9fIg A8xjyT8U2TWid3JeD4O9k2ISyPD8FQQZNE6D43Itb5nAb2pvpRIaG0VtnKM3wWCplJRG apiOYpEbWHH/w0VNOqvYtLn7rjbI9oGRl1iXEEScQJdBA1zXDjgC9rpAQqr38oMGX948 CpvTlkt7FpnL3K6k/nj0JBrNpkiLqludtUGCNP/D4hLi3q6Gn8l6nFB0/UUi+J3SpeVR 3KxHMvyjJhGRYRmmzAAJMoAHsZ+5C4n/38XW14mlSlI8mqd5rs6/cuTyWK2Nu5TDyS3b fWiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=PRb1nelP; 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 17si7365230ejx.213.2019.10.28.23.01.12; Mon, 28 Oct 2019 23:01:42 -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=PRb1nelP; 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 S2390887AbfJ1QXX (ORCPT + 99 others); Mon, 28 Oct 2019 12:23:23 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:46724 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbfJ1QXW (ORCPT ); Mon, 28 Oct 2019 12:23:22 -0400 Received: by mail-qt1-f194.google.com with SMTP id u22so15342613qtq.13 for ; Mon, 28 Oct 2019 09:23:22 -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=ghgZezvv9fwHiSgWNtPdvDWZAZD8rMK2AMplAo4xWgQ=; b=PRb1nelPzdzhqbUuPITp7umzHmdI68Zlolt1BBrgB6GP9NL0KGRvLz+3qb8eRT7sgi OnzvEuEuTXR0/GSe8sCghrBNWKc1BE0vZOh9Ugt1zlB78YHk9GbQI+mMlOnv4/InT2Gc dte4+zTmWDAh21qVBIyDbqItXzczpEpLDTA5nvTOr/0ISA5bhi3RUOnAETK5XIwUzKoA iSelJESpTEO7fEBr8KzHAnJOYlrrB6xKMaexUuZf60QplGn+1Fh53yygF2wWlNXb2+kc 2nv/4nlI/1AFQfS1YVxhUY6qQKavwhbdZi6jTwnL7PJ0SQU2ZGfvVaHctZmktjhmN3fw ERhA== 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=ghgZezvv9fwHiSgWNtPdvDWZAZD8rMK2AMplAo4xWgQ=; b=JxHufhZPmSMLW08D/qp6kIFE+kQ/kx3UDF+nNz2RRZsXuscB85POR7b8GbyGUR6wCQ XGahRZlGQXmFnSmBEj38TCyrIii3YjdnrSkyAbA69QbwSPFWxEPwLLEeW6+djbNSwA0z NIIPpSk8lbN1l74y3glvNu9UBWIJmXPfNNzE9dpYt371wDODnahBjDIRM5Z70TE/CAyt r40Qvcogy72C5wf4P5azagvBPKphk3MZoFWa6nEI1LiIpUF1k8dPa9vEWZiwu6LH7UEC GwS7FkOsBTYLxNPfrNY6Ha2p79EgtZPzNBTxDgPJriIcnDuvF+v8wHIbHR0oIz3rhdzE gS/g== X-Gm-Message-State: APjAAAXfar5bXJmKn2bcKnGrmK4b+tjsyPx1Op13KKVFPbHzF86TWRnu 4QcJmW3PK5MTuMqf0avFDvYA3w== X-Received: by 2002:aed:21c4:: with SMTP id m4mr18180174qtc.342.1572279801690; Mon, 28 Oct 2019 09:23:21 -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 q44sm8258257qtk.16.2019.10.28.09.23.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Oct 2019 09:23:21 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1iP7nc-0004Ff-IA; Mon, 28 Oct 2019 13:23:20 -0300 Date: Mon, 28 Oct 2019 13:23:20 -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: <20191028162320.GF29652@ziepe.ca> References: <20191025213359.7538-1-sultan@kerneltoast.com> <20191028141734.GD29652@ziepe.ca> <20191028161848.GA32593@sultan-box.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191028161848.GA32593@sultan-box.localdomain> 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 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. Jason