Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEDE6C43461 for ; Wed, 9 Sep 2020 13:05:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7AF6721D7F for ; Wed, 9 Sep 2020 13:05:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="pP83bq75" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AF6721D7F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B9C876B0055; Wed, 9 Sep 2020 09:05:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4C986B005A; Wed, 9 Sep 2020 09:05:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3BCC6B005C; Wed, 9 Sep 2020 09:05:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id 896A46B0055 for ; Wed, 9 Sep 2020 09:05:22 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2F26E2470 for ; Wed, 9 Sep 2020 13:05:22 +0000 (UTC) X-FDA: 77243544084.09.blow65_4b06fe4270dd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 09955180AD81A for ; Wed, 9 Sep 2020 13:05:22 +0000 (UTC) X-HE-Tag: blow65_4b06fe4270dd X-Filterd-Recvd-Size: 5049 Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Sep 2020 13:05:21 +0000 (UTC) Received: by mail-qv1-f67.google.com with SMTP id b13so1437949qvl.2 for ; Wed, 09 Sep 2020 06:05:21 -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; bh=SQiYBb9hIxC2l4xPBV67YXsRJO9uNM2atVYfM8q4ou8=; b=pP83bq75IxsdMCDo379I0Q+Yw0WLU7W25iHcm/NAdOU4dk/3KQeaVC5V+pfGTpmjXW Gpn5tif/F15CgHcQb4U7ql9Dz6Wmu3MthNL9mE6Cumt4rZu5TWxsRoclfaUIXgUocGbM pmL17BtjKqtlTBtdvZn7TcyXLDF6awGA3i0KZA5PSqV7XqaApbdVtQPFJ7lli/EiNHqR 9lx2zwT0jmis/pdIIn09cKsFEDH3+7X+NuQCodI5jqv2DcqEE+0DjriVNzLnm+xmdWOz PKMGEJCMwy2wkxLknBRVoL81kq6jouZ+wlEKsokwmO/lkusgjrBgLts5EXtZ2UQZWWFO Cc2g== 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; bh=SQiYBb9hIxC2l4xPBV67YXsRJO9uNM2atVYfM8q4ou8=; b=Xonjj1ktZ/7UF2QCPjHv/tHWYhTayv2eY4PARjnPX6o/c/fhFK2odOOlltr5ng3B8Q 2DtVCZWZAh931MI9AyLhNY94RMH89mQS/KFhWSp/2WqR6Hm3KY+Y8zM8CIwSXkfTJaQd zQyN11TBEdipFNx1oXnj3egEr44DSL7Cr6y5qEe3VZ3WO5a64D8M2q8x8swFOSFDGc4+ YWpZ+3NpuJ/qv2tg3c4HDeVvB6KfU+zNFdc9kAfaILLG1BLj9x9tLJoHEboyTxAql8YM hfVgl1M/lM9eHXb3kis6tz6YJ1KEOu/hCkbZ1/lGa1tSVFEndQx+G1+wsUqmX/r5xvs/ JpMA== X-Gm-Message-State: AOAM530Nvx3S4dhuIOPx/a4gFY5kt55wXHVPuj7T2SP+e/GKHn5KMsrR Hcb8Bq/jVC+Zkl3DsOMQCqslTA== X-Google-Smtp-Source: ABdhPJyyKUUZm4KYEm/R6Wux6480vc2XFPJDGKd9JoI86/628ERRBVCDKOZ5LZxRrcQzjhnpSrv3Ug== X-Received: by 2002:a05:6214:1045:: with SMTP id l5mr3984047qvr.110.1599656720625; Wed, 09 Sep 2020 06:05:20 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id 192sm2534880qkm.110.2020.09.09.06.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 06:05:19 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kFzmo-003JUV-UL; Wed, 09 Sep 2020 10:05:18 -0300 Date: Wed, 9 Sep 2020 10:05:18 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: 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, willy@infradead.org, jhubbard@nvidia.com Subject: Re: [PATCH V4 1/2] vfio dma_map/unmap: optimized for hugetlbfs pages Message-ID: <20200909130518.GE87483@ziepe.ca> References: <20200908133204.1338-1-maoming.maoming@huawei.com> <20200908133204.1338-2-maoming.maoming@huawei.com> <20200909080114.GA8321@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909080114.GA8321@infradead.org> X-Rspamd-Queue-Id: 09955180AD81A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 09, 2020 at 09:01:14AM +0100, Christoph Hellwig wrote: > I really don't think this approach is any good. You workaround > a deficiency in the pin_user_pages API in one particular caller for > one particular use case. RDMA has the same basic issues, this should should not be solved with workarounds in VFIO - a common API would be good > I think you'd rather want either: > > (1) a FOLL_HUGEPAGE flag for the pin_user_pages API family that returns > a single struct page for any kind of huge page, which would also > benefit all kinds of other users rather than adding these kinds of > hacks to vfio. 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. > (2) add a bvec version of the API that returns a variable size > "extent" This is the best one, I think.. The IOMMU setup can have multiple page sizes, so having largest contiguous blocks pre-computed should speed that up. vfio should be a win to use a sgl rather than a page list? Especially if we can also reduce the number of pages pinned by only pinning head pages.. > I had started on (2) a while ago, and here is branch with my code (which > is broken and fails test, but might be a start): > > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/gup-bvec > > But for now I wonder if (1) is the better start, which could still be > reused to (2) later. What about some 'pin_user_page_sgl' as a stepping stone? Switching from that point to bvec seems like a smaller step? Jason