Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp141731pxk; Wed, 9 Sep 2020 01:03:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfs8qFEz2BXgnWWsngFRCH1lzxC5tYHV8uCP6Oo5S7FTu9zfDHRdstMJnCmtKroPnGTorS X-Received: by 2002:a05:6402:393:: with SMTP id o19mr2913535edv.34.1599638594468; Wed, 09 Sep 2020 01:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599638594; cv=none; d=google.com; s=arc-20160816; b=Wn7rk4q9WzsZWc0FVooYsipTrOVgf6JdZg9vs5tVIuiFPzukZl1D1o24w67P+KyPjY pHOmkVpV5yZbz+xGHZVJL2jlYlEhMzvj9H6ZjVTznKaSixmp3/hJn7VQgfjZNFCWMSSD qdfSNNtUxIXWRltuDnXBqLYQDXGso3r3MJORDHPheVMtVvvqVsnJJG1dTVlJZa6JXIp9 pRbIvH9QNPz/Wp42DEcymg751yPjKUCuJdnQhJesdnoperGrkdMpgnJztJIg7LH6veOg FP3VmkB5enh+8Q0hrPL9agcYJDqADySEeoEqeLGB0bE1TvMbG4TbpsU1iZkAu/rZJbXp 8IkQ== 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=h/s4AqYAVQDYIXG3Quzt4FuppGSCR6zLJa5OOsyHiFU=; b=bYA85RGUw/k5+x0u4JXO/i3M3co+Wd2giCwQ8fepSiAg89vNEk97YtQb9K/96G576s ceB5C58uvH5tIFMlrMS8o/or6fiMHOlv4OSrMy6gwjayIHL4DmDFlYI/zR4a3hJ2uodW /Lehxou6vGTfnm/OOv0va4TFCtVUFB4eu12SxcC2VNMyVv+ZECCq0BTVnQUt/GbCAcjC wsM4KamecsLHsvtI+s6QiOsRB1BDBe8zkzRk/Qq1xtstV51m7PeMHWWCOYT4bnojy+IZ FHaTe5rY8OssNG+/GaWMm7YyPhv8etMMV+ICFDAPXDdOzkI5+6ZN7vVXIwnqkQTmB8TD VRmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=v9QVN+ea; 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 a4si992409edt.550.2020.09.09.01.02.50; Wed, 09 Sep 2020 01:03:14 -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=v9QVN+ea; 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 S1730212AbgIIIBm (ORCPT + 99 others); Wed, 9 Sep 2020 04:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727820AbgIIIBj (ORCPT ); Wed, 9 Sep 2020 04:01:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E4E0C061573; Wed, 9 Sep 2020 01:01:39 -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=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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.