From: Boqun Feng <boqun.feng@gmail.com>
To: Wei Liu <wei.liu@kernel.org>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
linux-hyperv@vger.kernel.org,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Dexuan Cui <decui@microsoft.com>,
Michael Kelley <mikelley@microsoft.com>,
David Hildenbrand <david@redhat.com>,
linux-kernel@vger.kernel.org, Boqun Feng <boqun.feng@gmail.com>
Subject: [RFC 1/2] Drivers: hv: balloon: Support status report for larger page sizes
Date: Wed, 23 Feb 2022 21:15:47 +0800 [thread overview]
Message-ID: <20220223131548.2234326-2-boqun.feng@gmail.com> (raw)
In-Reply-To: <20220223131548.2234326-1-boqun.feng@gmail.com>
DM_STATUS_REPORT expects the numbers of pages in the unit of 4k pages
(HV_HYP_PAGE) instead of guest pages, so to make it work when guest page
sizes are larger than 4k, convert the numbers of guest pages into the
numbers of HV_HYP_PAGEs.
Note that the numbers of guest pages are still used for tracing because
tracing is internal to the guest kernel.
Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
drivers/hv/hv_balloon.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index f2d05bff4245..062156b88a87 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -17,6 +17,7 @@
#include <linux/slab.h>
#include <linux/kthread.h>
#include <linux/completion.h>
+#include <linux/count_zeros.h>
#include <linux/memory_hotplug.h>
#include <linux/memory.h>
#include <linux/notifier.h>
@@ -1130,6 +1131,7 @@ static void post_status(struct hv_dynmem_device *dm)
struct dm_status status;
unsigned long now = jiffies;
unsigned long last_post = last_post_time;
+ unsigned long num_pages_avail, num_pages_committed;
if (pressure_report_delay > 0) {
--pressure_report_delay;
@@ -1154,16 +1156,21 @@ static void post_status(struct hv_dynmem_device *dm)
* num_pages_onlined) as committed to the host, otherwise it can try
* asking us to balloon them out.
*/
- status.num_avail = si_mem_available();
- status.num_committed = vm_memory_committed() +
+ num_pages_avail = si_mem_available();
+ num_pages_committed = vm_memory_committed() +
dm->num_pages_ballooned +
(dm->num_pages_added > dm->num_pages_onlined ?
dm->num_pages_added - dm->num_pages_onlined : 0) +
compute_balloon_floor();
- trace_balloon_status(status.num_avail, status.num_committed,
+ trace_balloon_status(num_pages_avail, num_pages_committed,
vm_memory_committed(), dm->num_pages_ballooned,
dm->num_pages_added, dm->num_pages_onlined);
+
+ /* Convert numbers of pages into numbers of HV_HYP_PAGEs. */
+ status.num_avail = num_pages_avail * NR_HV_HYP_PAGES_IN_PAGE;
+ status.num_committed = num_pages_committed * NR_HV_HYP_PAGES_IN_PAGE;
+
/*
* If our transaction ID is no longer current, just don't
* send the status. This can happen if we were interrupted
--
2.35.1
next prev parent reply other threads:[~2022-02-23 13:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 13:15 [RFC 0/2] Drivers: hv: balloon: Temporary fixes for ARM64 Boqun Feng
2022-02-23 13:15 ` Boqun Feng [this message]
2022-02-23 16:45 ` [RFC 1/2] Drivers: hv: balloon: Support status report for larger page sizes Michael Kelley (LINUX)
2022-02-23 13:15 ` [RFC 2/2] Drivers: hv: balloon: Disable balloon and hot-add accordingly Boqun Feng
2022-02-23 16:55 ` Michael Kelley (LINUX)
2022-02-24 2:44 ` Boqun Feng
2022-02-24 4:44 ` Michael Kelley (LINUX)
2022-02-25 2:17 ` [RFC v1.1] " Boqun Feng
2022-02-25 17:06 ` Michael Kelley (LINUX)
2022-02-26 1:30 ` Boqun Feng
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=20220223131548.2234326-2-boqun.feng@gmail.com \
--to=boqun.feng@gmail.com \
--cc=david@redhat.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.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