From: Yan Zhao <yan.y.zhao@intel.com>
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: pbonzini@redhat.com, seanjc@google.com, stevensd@chromium.org,
Yan Zhao <yan.y.zhao@intel.com>
Subject: [PATCH] KVM: allow mapping of compound tail pages for IO or PFNMAP mapping
Date: Wed, 19 Jul 2023 16:33:32 +0800 [thread overview]
Message-ID: <20230719083332.4584-1-yan.y.zhao@intel.com> (raw)
Allow mapping of tail pages of compound pages for IO or PFNMAP mapping
by trying and getting ref count of its head page.
For IO or PFNMAP mapping, sometimes it's backed by compound pages.
KVM will just return error on mapping of tail pages of the compound pages,
as ref count of the tail pages are always 0.
So, rather than check and add ref count of a tail page, check and add ref
count of its folio (head page) to allow mapping of the compound tail pages.
This will not break the origial intention to disallow mapping of tail pages
of non-compound higher order allocations as the folio of a non-compound
tail page is the same as the page itself.
On the other side, put_page() has already converted page to folio before
putting page ref.
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 138292a86174..6f2b51ef20f7 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2551,7 +2551,7 @@ static int kvm_try_get_pfn(kvm_pfn_t pfn)
if (!page)
return 1;
- return get_page_unless_zero(page);
+ return folio_try_get(page_folio(page));
}
static int hva_to_pfn_remapped(struct vm_area_struct *vma,
base-commit: 24ff4c08e5bbdd7399d45f940f10fed030dfadda
--
2.17.1
next reply other threads:[~2023-07-19 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 8:33 Yan Zhao [this message]
2023-07-19 15:42 ` [PATCH] KVM: allow mapping of compound tail pages for IO or PFNMAP mapping Sean Christopherson
2023-07-20 2:03 ` Yan Zhao
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=20230719083332.4584-1-yan.y.zhao@intel.com \
--to=yan.y.zhao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=stevensd@chromium.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