Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: "Maoming (maoming,
	Cloud Infrastructure Service Product Dept.)" 
	<maoming.maoming@huawei.com>
Cc: Hugh Dickins <hughd@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"Zhoujian (jay)" <jianjay.zhou@huawei.com>,
	"Huangweidong (C)" <weidong.huang@huawei.com>,
	"peterx@redhat.com" <peterx@redhat.com>,
	"aarcange@redhat.com" <aarcange@redhat.com>,
	wangyunjian <wangyunjian@huawei.com>
Subject: Re: 答复: [PATCH V3] vfio dma_map/unmap: optimized for hugetlbfs pages
Date: Tue, 1 Sep 2020 10:51:55 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.2009011040560.2984@eggly.anvils> (raw)
In-Reply-To: <8B561EC9A4D13649A62CF60D3A8E8CB28C2DC466@dggeml524-mbx.china.huawei.com>

On Tue, 1 Sep 2020, Maoming (maoming, Cloud Infrastructure Service Product Dept.) wrote:
> > 
> > > In the original process of dma_map/unmap pages for VFIO-devices, to
> > > make sure the pages are contiguous, we have to check them one by one.
> > > As a result, dma_map/unmap could spend a long time.
> > > Using the hugetlb pages, we can avoid this problem.
> > > All pages in hugetlb pages are contiguous.And the hugetlb page should
> > > not be split.So we can delete the for loops.
> > 
> > I know nothing about VFIO, but I'm surprised that you're paying such attention
> > to PageHuge hugetlbfs pages, rather than to PageCompound
> > pages: which would also include Transparent Huge Pages, of the traditional
> > anonymous kind, or the huge tmpfs kind, or the more general (not necessarily
> > pmd-sized) kind that Matthew Wilcox is currently working on.
> > 
> > It's true that hugetlbfs is peculiar enough that whatever you write for it may
> > need some tweaks to cover the THP case too, or vice versa; but wouldn't your
> > patch be a lot better for covering all cases?
> > 
> > You mention above that "the hugetlb page should not be split":
> > perhaps you have been worried that a THP could be split beneath you?
> > That used to be a possibility some years ago, but nowadays a THP cannot be
> > split while anyone is pinning it with an extra reference.
> > 
> > Hugh
> > 
> 
> 
> Thanks for your suggestions.
> You mention that a THP cannot be split while anyone is pinning it.
> Do you mean the check of can_split_huge_page()(in split_huge_page_to_list())?

Partly, yes: but that's just a racy check to avoid doing wasted work in
common cases; the more important check comes later in page_ref_freeze(),
which either fails, or prevents anyone else taking a new reference to
the THP (head or tails) while all the work on splitting is being done.

> When we want to pin pages, vfio_pin_pages_remote() always gets a normal page first.
> In this case, a THP cannot be split because of the increased reference.
> Is this right?

Yes.

> 
> Maybe I can optimize for hugetlb pages as a first step,
> and then cover all compound pages.

Okay.  That's definitely a good way to start out - but you may find
that the second step leads you to rewrite every line you wrote before!

Hugh

      reply	other threads:[~2020-09-01 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28  9:26 [PATCH V3] vfio dma_map/unmap: optimized for hugetlbfs pages Ming Mao
2020-08-31  6:54 ` Hugh Dickins
2020-09-01 12:09   ` 答复: " Maoming (maoming, Cloud Infrastructure Service Product Dept.)
2020-09-01 17:51     ` Hugh Dickins [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.2009011040560.2984@eggly.anvils \
    --to=hughd@google.com \
    --cc=aarcange@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maoming.maoming@huawei.com \
    --cc=peterx@redhat.com \
    --cc=wangyunjian@huawei.com \
    --cc=weidong.huang@huawei.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox