* [PATCH] hv_balloon: Fix committed value in post_status() if dynamic memory is disabled
@ 2022-11-04 6:52 Shradha Gupta
2022-11-11 16:50 ` Wei Liu
0 siblings, 1 reply; 2+ messages in thread
From: Shradha Gupta @ 2022-11-04 6:52 UTC (permalink / raw)
To: linux-kernel, linux-hyperv
Cc: Shradha Gupta, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger,
Wei Liu, Dexuan Cui, Long Li, Michael Kelley
If Dynamic memory is disabled for VM, the committed value reported by the
post_status() call by hv_balloon driver includes compute_balloon_floor().
This is not needed if balloon_up operations or hot_add operations were
never requested on the VM(or if Dynamic memory was disabled for the VM)
Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
---
drivers/hv/hv_balloon.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index fdf6decacf06..a6f5321d4a2e 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1129,11 +1129,23 @@ static unsigned long compute_balloon_floor(void)
static unsigned long get_pages_committed(struct hv_dynmem_device *dm)
{
- return 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();
+ unsigned long pages_committed;
+
+ pages_committed = vm_memory_committed();
+
+ /*
+ * If no balloon_up or hot_add operation was performed do not add
+ * num_pages_ballooned, number of pages offline or
+ * compute_balloon_floor() to the pages_committed value
+ */
+ if (dm->num_pages_ballooned || dm->num_pages_added) {
+ pages_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();
+ }
+
+ return pages_committed;
}
/*
--
2.37.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hv_balloon: Fix committed value in post_status() if dynamic memory is disabled
2022-11-04 6:52 [PATCH] hv_balloon: Fix committed value in post_status() if dynamic memory is disabled Shradha Gupta
@ 2022-11-11 16:50 ` Wei Liu
0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2022-11-11 16:50 UTC (permalink / raw)
To: Shradha Gupta
Cc: linux-kernel, linux-hyperv, K. Y. Srinivasan, Haiyang Zhang,
Stephen Hemminger, Wei Liu, Dexuan Cui, Long Li, Michael Kelley
On Thu, Nov 03, 2022 at 11:52:50PM -0700, Shradha Gupta wrote:
> If Dynamic memory is disabled for VM, the committed value reported by the
> post_status() call by hv_balloon driver includes compute_balloon_floor().
> This is not needed if balloon_up operations or hot_add operations were
> never requested on the VM(or if Dynamic memory was disabled for the VM)
>
> Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
Can you put a Fixes: tag here?
You can use git-blame to find out the culprit.
Thanks,
Wei.
> ---
> drivers/hv/hv_balloon.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index fdf6decacf06..a6f5321d4a2e 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -1129,11 +1129,23 @@ static unsigned long compute_balloon_floor(void)
>
> static unsigned long get_pages_committed(struct hv_dynmem_device *dm)
> {
> - return 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();
> + unsigned long pages_committed;
> +
> + pages_committed = vm_memory_committed();
> +
> + /*
> + * If no balloon_up or hot_add operation was performed do not add
> + * num_pages_ballooned, number of pages offline or
> + * compute_balloon_floor() to the pages_committed value
> + */
> + if (dm->num_pages_ballooned || dm->num_pages_added) {
> + pages_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();
> + }
> +
> + return pages_committed;
> }
>
> /*
> --
> 2.37.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-11 16:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-04 6:52 [PATCH] hv_balloon: Fix committed value in post_status() if dynamic memory is disabled Shradha Gupta
2022-11-11 16:50 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).