Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2886793pxy; Mon, 3 May 2021 10:10:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq9AWyJ7EuijpfQ3KmWvge2T6rpRhnC8LJt2U1uMIaXlQue+1spt4cvMW88s6cAQlxsyGH X-Received: by 2002:a05:6402:145:: with SMTP id s5mr20729361edu.221.1620061855217; Mon, 03 May 2021 10:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620061855; cv=none; d=google.com; s=arc-20160816; b=D/y69rT1NyUpgntvPv2+MFXPznENcYEoMSYlVo5XoFzUdazvz7qoTE3CusfTcyWeAx f+N7YSHxc6xmv8FSmI5LH2qHYYv+MzgYutkAduEPBbj6+iZsXVQV2lNlOwRB2EigiEhC +X0Cemx+lbDGMQq+Uw5FzmxhBINliG14CU2/J6XwINCoNkr2wcJhDMFhUNXBvD5rxAIf sR12QiKKMyC2dBvggz0E1ESxjKsLsJIQpIBAmCV5M1q/zIGFa2nJJkQ6Dq4ULa3doO9/ FHtuPN3YZukmWJULyqRtEiWB8TYNgcS/xy+yi1N+DYiwfVrhtOMRsybm/aHbMHl8FNvH UoHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:dkim-signature; bh=XIo5o0eZ2ybUTNprcEF2/49WtyCaykR1qXGIExijWsM=; b=mJ7x9i1LJz7c0aSy0zF0qHFli+asjzZvePCpAf5tigZheD7f+59FfQtFLev5Ao0TW8 GDps79UJvKhSQJv23PUOzUyufnX8pl3API+nlmxbnVDMDFbIszRidaCAuf5Bk50W2dEt MaAKa/kJrkyyVb4DnTzXtzym4flxsZwCM+GLR099qTg0J1fT3O9mqEE9uMaKCgCGZpGn jFJ1Uw1YLjDCYlEVw2ln8g2zgQ1Av2Lj62K8aTrnU2GoNFHUVCf5jlgkKaZ3iyxjpS6i Xybm66X0xHGWQOGzv4I/R3tVfyKt7VLGP9m1XbBS/Ml5olYm/sqI1gKtkbKF2YYtyToK Pc0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=A4opownL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op18si299015ejb.39.2021.05.03.10.10.29; Mon, 03 May 2021 10:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=A4opownL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234820AbhECRIr (ORCPT + 99 others); Mon, 3 May 2021 13:08:47 -0400 Received: from ale.deltatee.com ([204.191.154.188]:58096 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235939AbhECRF0 (ORCPT ); Mon, 3 May 2021 13:05:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=XIo5o0eZ2ybUTNprcEF2/49WtyCaykR1qXGIExijWsM=; b=A4opownLuMAvZjkxn/S5VlDlz4 qED8iUdb0jEoi6DzG3q5SA7kp8n+oxHLhbgsHmFUrOLUwQFlzg1FKL0fq5PkdsBhHJzqb0XviPegB kKRHngxYkYJ0UpPyjCO0lOMylnMndCw8cb5iA/v+hS3jma7ltHNInla8vLysBcmccx983fL/js4MY lPvFn13ECitpdcjFVe84V/mNNGwhgHPrgKLAxqbjwODcoPUPBoYb1uT61RMyXvJXAK4g98T3HsqhD FQzLgskh7qEpkiRSBuYU5Blwu7PNIvF93A+JxrLASdf+M6KJe0wh6+dC6naKCDSvBhDzOiFHiKtCi 3JIqatrw==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1ldbzZ-0004qY-4w; Mon, 03 May 2021 11:04:21 -0600 To: John Hubbard , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-10-logang@deltatee.com> <37fa46c7-2c24-1808-16e9-e543f4601279@nvidia.com> From: Logan Gunthorpe Message-ID: <8de928ab-2842-dac9-07ad-a098124f791f@deltatee.com> Date: Mon, 3 May 2021 11:04:18 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <37fa46c7-2c24-1808-16e9-e543f4601279@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: robin.murphy@arm.com, ira.weiny@intel.com, helgaas@kernel.org, jianxin.xiong@intel.com, dave.hansen@linux.intel.com, jason@jlekstrand.net, dave.b.minturn@intel.com, andrzej.jakowski@intel.com, daniel.vetter@ffwll.ch, willy@infradead.org, ddutile@redhat.com, christian.koenig@amd.com, jgg@ziepe.ca, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, jhubbard@nvidia.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH 09/16] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oops missed a comment: On 2021-05-02 5:28 p.m., John Hubbard wrote: >> int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, >> enum dma_data_direction dir, unsigned long attrs) >> { >> - int i; >> + struct pci_p2pdma_map_state p2pdma_state = {}; > > Is it worth putting this stuff on the stack--is there a noticeable > performance improvement from caching the state? Because if it's > invisible, then simplicity is better. I suspect you're right, and that > it *is* worth it, but it's good to know for real. I haven't measured it (it would be hard to measure), but I think it's fairly clear here. Without the state, xa_load() would need to be called on *every* page in an SGL that maps only P2PDMA memory from one device. With the state, it only needs to be called once. xa_load() is cheap, but it is not that cheap. There's essentially the same optimization in get_user_pages for ZONE_DEVICE pages. So, if it is necessary there, it should be necessary here. Logan