From: David Hildenbrand <david@redhat.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
Alex Williamson <alex.williamson@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lpivarc@redhat.com" <lpivarc@redhat.com>,
"Liu, Jingqi" <jingqi.liu@intel.com>,
"Lu, Baolu" <baolu.lu@intel.com>
Subject: Re: [PATCH] vfio/type1: Unpin zero pages
Date: Wed, 7 Sep 2022 11:00:21 +0200 [thread overview]
Message-ID: <b365f30b-da58-39c0-08e9-c622cc506afa@redhat.com> (raw)
In-Reply-To: <YxfX+kpajVY4vWTL@ziepe.ca>
On 07.09.22 01:30, Jason Gunthorpe wrote:
> On Fri, Sep 02, 2022 at 10:32:01AM +0200, David Hildenbrand wrote:
>
>>> So I wonder instead of continuing to fix trickiness around the zero
>>> page whether it is a better idea to pursue allocating a normal
>>> page from the beginning for pinned RO mappings?
>>
>> That's precisely what I am working. For example, that's required to get
>> rid of FOLL_FORCE|FOLL_WRITE for taking a R/O pin as done by RDMA:
>
> And all these issues are exactly why RDMA uses FOLL_FORCE and it is,
> IMHO, a simple bug that VFIO does not.
I consider the BUG that our longterm page pinning behaves the way it
currently does, not that we're not using the FOLL_FORCE flag here.
But it doesn't matter, I'm working on fixing/cleaning it up.
>
>> I do wonder if that's a real issue, though. One approach would be to
>> warn the VFIO users and allow for slightly exceeding the MEMLOCK limit
>> for a while. Of course, that only works if we assume that such pinned
>> zeropages are only extremely rarely longterm-pinned for a single VM
>> instance by VFIO.
>
> I'm confused, doesn't vfio increment the memlock for every page of VA
> it pins? Why would it matter if the page was COW'd or not? It is
> already accounted for today as though it was a unique page.
>
> IOW if we add FOLL_FORCE it won't change the value of the memlock.
I only briefly skimmed over the code Alex might be able to provide more
details and correct me if I'm wrong:
vfio_pin_pages_remote() contains a comment:
"Reserved pages aren't counted against the user, externally pinned pages
are already counted against the user."
is_invalid_reserved_pfn() should return "true" for the shared zeropage
and prevent us from accounting it via vfio_lock_acct(). Otherwise,
vfio_find_vpfn() seems to be in place to avoid double-accounting pages.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-09-07 9:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 3:05 Alex Williamson
2022-08-30 5:34 ` Sean Christopherson
2022-08-30 7:59 ` David Hildenbrand
2022-08-30 15:11 ` Alex Williamson
2022-08-30 15:43 ` David Hildenbrand
2022-09-02 0:53 ` Jason Gunthorpe
2022-09-02 8:24 ` Tian, Kevin
2022-09-02 8:32 ` David Hildenbrand
2022-09-02 9:09 ` Tian, Kevin
2022-09-06 23:30 ` Jason Gunthorpe
2022-09-07 9:00 ` David Hildenbrand [this message]
2022-09-07 12:48 ` Jason Gunthorpe
2022-09-07 15:55 ` Alex Williamson
2022-09-07 16:40 ` Jason Gunthorpe
2022-09-07 18:56 ` Alex Williamson
2022-09-07 19:14 ` David Hildenbrand
2022-09-07 19:55 ` Jason Gunthorpe
2022-09-07 20:24 ` Alex Williamson
2022-09-07 23:07 ` Jason Gunthorpe
2022-09-08 1:10 ` Alex Williamson
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=b365f30b-da58-39c0-08e9-c622cc506afa@redhat.com \
--to=david@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@intel.com \
--cc=jgg@ziepe.ca \
--cc=jingqi.liu@intel.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpivarc@redhat.com \
/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
all inboxes | Powered by JetHome®