From mboxrd@z Thu Jan 1 00:00:00 1970 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 60C30C43461 for ; Wed, 9 Sep 2020 08:01:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5F56208FE for ; Wed, 9 Sep 2020 08:01:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="v9QVN+ea" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5F56208FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0AE6D6B006E; Wed, 9 Sep 2020 04:01:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05E5E6B0071; Wed, 9 Sep 2020 04:01:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB6F16B007B; Wed, 9 Sep 2020 04:01:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id D6A316B006E for ; Wed, 9 Sep 2020 04:01:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9BF15181AEF0B for ; Wed, 9 Sep 2020 08:01:43 +0000 (UTC) X-FDA: 77242778886.29.moon64_4608a74270db Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 66435180868D2 for ; Wed, 9 Sep 2020 08:01:43 +0000 (UTC) X-HE-Tag: moon64_4608a74270db X-Filterd-Recvd-Size: 2809 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Sep 2020 08:01:43 +0000 (UTC) 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=h/s4AqYAVQDYIXG3Quzt4FuppGSCR6zLJa5OOsyHiFU=; b=v9QVN+eawzJkpdxGL8CneCQwJS VFd5Th/McBJ7QHsPpLIrhdwQtPI2jDu389eQqTScyd1q18tC50OOHr1nS8D/ojg/XkONVn7Oprs3n BEW6qMCI64DgfRPaplGOf/z6gHw49uPX/I0cl+GSk2R6tp/hs9s0WjOCYmGsZa9e/hvX3VRN3Qk4z GdhimEfxt4kQ/yRvmAb2y/ZwaKBBmnSyOhmgASg/mM+/CJnX2bvnEZCEJZiR8oZl8j/vGR8LwWqFl yoXUmV0fG0o6wMyXPmlj3/Bk0StbjU+M9i+g4voNHslymF/YL0V7KQwH/PmBxT0wvOJ6CWtumGHcG hkbTNrJQ==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFv2Y-0002p5-LE; Wed, 09 Sep 2020 08:01:16 +0000 Date: Wed, 9 Sep 2020 09:01:14 +0100 From: Christoph Hellwig To: Ming Mao Cc: 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: <20200909080114.GA8321@infradead.org> References: <20200908133204.1338-1-maoming.maoming@huawei.com> <20200908133204.1338-2-maoming.maoming@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200908133204.1338-2-maoming.maoming@huawei.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: 66435180868D2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: 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. 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. (2) add a bvec version of the API that returns a variable size "extent" 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.