Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp481284pxk; Wed, 9 Sep 2020 10:15:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz67vLEl5A34N4DefrRC0cv3dsjXx0QI1TTb2IlPpev6smWJWuWNqRhJQ08Nr32/ObN9pFN X-Received: by 2002:a17:906:5205:: with SMTP id g5mr4538806ejm.488.1599671723070; Wed, 09 Sep 2020 10:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599671723; cv=none; d=google.com; s=arc-20160816; b=VT6B72Rwr16tpDT1BIM4pQcuXO+BiahEjIrI3JY+S4kH97fxbT7J1V5/hlzUBwWYTs 10B2hi+kvTxXxUlgyZg1eRRoqvPimpnkcY94zoPc18xe3YrkJW5Ly5bXM9Fp/5VmnbiD VjO45dGO8+QJKxDheH2cWfRNcUGSj0B0CO7YX+VWbuX+bN/F4gQwL9DKY97HFMyOcRJ3 sS2edMScLRmHVmbWMv87ZwjroIQw36xkPLZH8aSomc0nHt2ITegNgQCZntCdUTaBtdny 5lgaHnnlk3FrcSoh49b4BOqm+xMCL63LfJhqLwOLBFrj665CSU/GTEdrNU+4saOw5bd3 uZLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MVAeHe5FDtxLkhCRtWl5/1qAQHWmRELNofFvInrKy68=; b=Foi7IXVrvV6uZRMVmv2evn5rfDPa37MrZ/igRPL5bImWsTEU/eL8a74tC/YM/vn5nB l0LUgQz2ommOoO/+6zGXyh60lGpoFkfokNXhjKNDfZ86u2/SRgg0QawrQjfqMUgx7T/T wiwHgvgIpnFf5UlxCd0qMoMJmDbEcVPGPao5IFgUXB7Vy2ZorSseHU8VpapFSvcFKKCm K5yPhloR+KJOkk8mK7STD/+9STL6EYqXpD46bTkdh02YG/0+dYHTf6TpBWB6UNq4WCKh lwuI8ymArKkooWUyh2HjVdIPfQGU/sOKQVTxRIkpU2hCRWDfNqsjRZD0PTF62tcorjuW J2jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=BztXimA7; 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 h13si1819483edq.83.2020.09.09.10.14.59; Wed, 09 Sep 2020 10:15:23 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=BztXimA7; 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 S1731269AbgIIRM2 (ORCPT + 99 others); Wed, 9 Sep 2020 13:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730287AbgIIPcg (ORCPT ); Wed, 9 Sep 2020 11:32:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1CDCC06123A; Wed, 9 Sep 2020 08:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=MVAeHe5FDtxLkhCRtWl5/1qAQHWmRELNofFvInrKy68=; b=BztXimA7lzcj8i0a7Hfb2iCsRV 8Jbc1EgSgRrX823PDBzAnIPcQVx1llIRGOg31njOV1ZiixejTgKPCIhqyh0B3oBbBpMbZyUaKkipa d4wtX8Tb7QBsK4SVuh/xnFcyvlxnCr+IByHYj0nmLwfWMfGltfZbuzMnMWoJeOLvLdSKJ+UMBXkA0 AYMCECsJvVfCxvGEGhvsd0I849jKePnGGTbkI4Rwm/zWQNSCbCnBDFhthuvRhbgd4wdm8mwYwkLpO SyGu2Y7hhxmqb35g1sqzEm9EVWr3ddpLrMPlUOkGm4u0F1TiB2CThO7OMYC3vv78PrfGZDG1i91d4 tR/q5t7w==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kG1a3-0007u9-24; Wed, 09 Sep 2020 15:00:15 +0000 Date: Wed, 9 Sep 2020 16:00:15 +0100 From: Matthew Wilcox To: Christoph Hellwig Cc: Jason Gunthorpe , Ming Mao , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, alex.williamson@redhat.com, akpm@linux-foundation.org, cohuck@redhat.com, jianjay.zhou@huawei.com, weidong.huang@huawei.com, peterx@redhat.com, aarcange@redhat.com, wangyunjian@huawei.com, jhubbard@nvidia.com Subject: Re: [PATCH V4 1/2] vfio dma_map/unmap: optimized for hugetlbfs pages Message-ID: <20200909150015.GI6583@casper.infradead.org> References: <20200908133204.1338-1-maoming.maoming@huawei.com> <20200908133204.1338-2-maoming.maoming@huawei.com> <20200909080114.GA8321@infradead.org> <20200909130518.GE87483@ziepe.ca> <20200909142941.GA23553@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909142941.GA23553@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 09, 2020 at 03:29:41PM +0100, Christoph Hellwig wrote: > On Wed, Sep 09, 2020 at 10:05:18AM -0300, Jason Gunthorpe wrote: > > How to use? The VMAs can have mixed page sizes so the caller would > > have to somehow switch and call twice? Not sure this is faster. > > We can find out the page size based on the page. Right now it is > rather cumbersome, but one of willys pending series has a nicer helper > for that. Actually already merged. There's page_size() which went into 5.4, and is the one you'd want to use (also page_shift() and compound_nr()). The thp_* equivalents (merged in 5.9) compile away to nothing if you don't have CONFIG_TRANSPARENT_HUGEPAGE enabled, but since there are many ways of getting a compound page mapped into userspace, page_size() is the helper to use for VFIO.