Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3937232ybg; Mon, 28 Oct 2019 23:00:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzflPhPwY+I6wQ3ngaOaJrGmC2wGWYTeFqUdBF2Bdhp+sh4mOCnI4fivAgdeB/RIz+lAzNR X-Received: by 2002:a17:906:e86:: with SMTP id p6mr871400ejf.52.1572328829901; Mon, 28 Oct 2019 23:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572328829; cv=none; d=google.com; s=arc-20160816; b=EK0hzr4W5XvF1CGf6eIpoWmJHuezJa1LjW8gUW5g4IHMVUbW18uAkC+z27zUuv03UL etoXGvqXKQpXkceNl8VhzlP7+Nsr122gpwKaEFCb643Ai6e7AVdHIEnvqxRsLWepzg5h 1+aYiFGXrpJK1sEhxpZHOmWBvW6JoqtaVJva98SH1eASEp3FSCnFPTrFXOhcMcHjSEtT avj8EkMr8qVbK2fWL6WYsELemBgKE1XERqWEbWzdu9zoQ/5pBNGDXdvsRM7e/gnmgwrd lLzlh6OEgYaWfqtEPf0VXHyXg1IcDtWfm4S3uXDj5fYJbzv4C1CYac7e0hyi1TpoiTnR PE0Q== 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; bh=QpmthTIEs+c5yGXXMTwUSatMm4+bH1uRyJfRSy9ZDhk=; b=KDZyEel4R8nE5yGdVRGWJj+uQHxpFxnMtHctdJCvT//5fWkUw//hz1RXzKYFYWQXUZ FbAYUTNnFA9M6u2Nf/D7a2Pj6BCnV9ecqp7Q0d2lJaKEn2YmrB8JT+JG5hY2LPDBrMMs 2ARXYCeNWTZykLdedpasUtQSyCLiEJ/QksVCW9BPKt6cwlF4DwBQkQ6DPgWwMABjzixu 1WqBoQnuQj5tZ5b7crixA13SVyzVgGaC37mM+7JtSp+JyTtllKgHGBO6FsrgiAZ6G89t jLIE/Tq/LVOvXIq7/k8pQVcqv8XfOUWS/kEgfOtwJVJq0YgNgz1g6vQjtss9egn4yv0O 8nHg== ARC-Authentication-Results: i=1; mx.google.com; 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 u18si7423018ejk.105.2019.10.28.23.00.06; Mon, 28 Oct 2019 23:00:29 -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; 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 S2390874AbfJ1QSw (ORCPT + 99 others); Mon, 28 Oct 2019 12:18:52 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38805 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732236AbfJ1QSv (ORCPT ); Mon, 28 Oct 2019 12:18:51 -0400 Received: by mail-pg1-f193.google.com with SMTP id w3so7197377pgt.5 for ; Mon, 28 Oct 2019 09:18:51 -0700 (PDT) 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=QpmthTIEs+c5yGXXMTwUSatMm4+bH1uRyJfRSy9ZDhk=; b=HpqRDQZrqVt9EqHu3x4UZ/uRUFpcNYunB8IUXcgGqTiG9mzrJumjlcjS5uKhFIpt81 9hYfz2Rj7M5vP6PK3Mr8Uzimp1xbq0Mppt6lC7tDDTGQ7wGt1S4bBNUTyEU91oX0tVKS 7yJiJsdFMQY1vvZCiYDXuojPj9iMisFHR+yi5CZMAm/eYpAP0OVsxA8CWOjpqJyB9x+d cF3ynxxAgLySJEADmovRM8nlosAWEpbiKIKtvMIi/UW1G0zibTLkcnW+JWQPzub8spQy S5nf+QXiPb03UcDdmI1CmFqQwg6n3BBfL9rjxWQnkYx2J6h6e+YXeZuN3oRzVYo2eFrQ QqeA== X-Gm-Message-State: APjAAAU5k4lo8EpSvVqbGoQvQtoAvSj+12/CaxQUdQiZe5h3GrvlgDlm pRGD1js20UZje+E9ZPVLeyp5+79DS+k= X-Received: by 2002:a62:1c08:: with SMTP id c8mr21981759pfc.212.1572279531274; Mon, 28 Oct 2019 09:18:51 -0700 (PDT) Received: from sultan-box.localdomain ([104.200.129.62]) by smtp.gmail.com with ESMTPSA id f26sm5206592pgf.22.2019.10.28.09.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:18:50 -0700 (PDT) Date: Mon, 28 Oct 2019 09:18:48 -0700 From: Sultan Alsawaf To: Jason Gunthorpe 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: <20191028161848.GA32593@sultan-box.localdomain> References: <20191025213359.7538-1-sultan@kerneltoast.com> <20191028141734.GD29652@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191028141734.GD29652@ziepe.ca> User-Agent: Mutt/1.12.2 (2019-09-21) 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 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