* [PATCH 0/3] Allow order zero pages in page reporting
@ 2026-02-26 7:01 Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 1/3] mm/page_reporting: Allow zero page_reporting_order Yuvraj Sakshith
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Yuvraj Sakshith @ 2026-02-26 7:01 UTC (permalink / raw)
To: akpm, mst, david
Cc: vbabka, surenb, mhocko, jackmanb, hannes, ziy, linux-mm,
jasowang, xuanzhuo, eperezma, virtualization, kys, haiyangz,
wei.liu, decui, longli, linux-hyperv, linux-kernel
Today, page reporting sets page_reporting_order in two ways:
(1) page_reporting.page_reporting_order cmdline parameter
(2) Driver can pass order while registering itself.
In both cases, order zero is ignored by free page reporting
because it is used to set page_reporting_order to a default
value, like MAX_PAGE_ORDER.
In some cases we might want page_reporting_order to be zero.
For instance, when virtio-balloon runs inside a guest with
tiny memory (say, 16MB), it might not be able to find a order 1 page
(or in the worst case order MAX_PAGE_ORDER page) after some uptime.
Page reporting should be able to return order zero pages back for
optimal memory relinquishment.
This patch changes the default fallback value from '0' to '-1' in
all possible clients of free page reporting (hv_balloon and
virtio-balloon) together with allowing '0' as a valid order in
page_reporting_register().
Yuvraj Sakshith (3):
mm/page_reporting: Allow zero page_reporting_order
hv_balloon: Change default page reporting order
virtio_balloon: Set pr_dev.order to new default
drivers/hv/hv_balloon.c | 2 +-
drivers/virtio/virtio_balloon.c | 14 ++++++++++++++
mm/page_reporting.c | 2 +-
3 files changed, 16 insertions(+), 2 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] mm/page_reporting: Allow zero page_reporting_order
2026-02-26 7:01 [PATCH 0/3] Allow order zero pages in page reporting Yuvraj Sakshith
@ 2026-02-26 7:01 ` Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 2/3] hv_balloon: Change default page reporting order Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 3/3] virtio_balloon: Set pr_dev.order to new default Yuvraj Sakshith
2 siblings, 0 replies; 6+ messages in thread
From: Yuvraj Sakshith @ 2026-02-26 7:01 UTC (permalink / raw)
To: akpm, mst, david
Cc: vbabka, surenb, mhocko, jackmanb, hannes, ziy, linux-mm,
jasowang, xuanzhuo, eperezma, virtualization, kys, haiyangz,
wei.liu, decui, longli, linux-hyperv, linux-kernel
Some drivers might require page sized chunks to be
reported. This patch allows registering a driver with
order as zero.
Example use case: virtio-balloon driver running on a
guest with very small memory. After some time has passed,
the guest might not be able to find a chunk of 8KB.
Signed-off-by: Yuvraj Sakshith <yuvraj.sakshith@oss.qualcomm.com>
---
mm/page_reporting.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/page_reporting.c b/mm/page_reporting.c
index e4c428e61..fd7c5f0de 100644
--- a/mm/page_reporting.c
+++ b/mm/page_reporting.c
@@ -370,7 +370,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)
*/
if (page_reporting_order == -1) {
- if (prdev->order > 0 && prdev->order <= MAX_PAGE_ORDER)
+ if (prdev->order >= 0 && prdev->order <= MAX_PAGE_ORDER)
page_reporting_order = prdev->order;
else
page_reporting_order = pageblock_order;
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] hv_balloon: Change default page reporting order
2026-02-26 7:01 [PATCH 0/3] Allow order zero pages in page reporting Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 1/3] mm/page_reporting: Allow zero page_reporting_order Yuvraj Sakshith
@ 2026-02-26 7:01 ` Yuvraj Sakshith
2026-02-26 17:34 ` David Hildenbrand (Arm)
2026-02-26 7:01 ` [PATCH 3/3] virtio_balloon: Set pr_dev.order to new default Yuvraj Sakshith
2 siblings, 1 reply; 6+ messages in thread
From: Yuvraj Sakshith @ 2026-02-26 7:01 UTC (permalink / raw)
To: akpm, mst, david
Cc: vbabka, surenb, mhocko, jackmanb, hannes, ziy, linux-mm,
jasowang, xuanzhuo, eperezma, virtualization, kys, haiyangz,
wei.liu, decui, longli, linux-hyperv, linux-kernel
page_reporting_order used to fall back to default
value (passed as parameter or MAX_PAGE_ORDER) if
the driver wishes to not provide it.
The way the driver used to do this was by passing
the order as zero.
Now that zero is a valid order that can be passed by
a driver to page reporting, we use -1 to signal
default value to be used.
Signed-off-by: Yuvraj Sakshith <yuvraj.sakshith@oss.qualcomm.com>
---
drivers/hv/hv_balloon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 2b4080e51..e33d6e3b2 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1663,7 +1663,7 @@ static void enable_page_reporting(void)
* We let the page_reporting_order parameter decide the order
* in the page_reporting code
*/
- dm_device.pr_dev_info.order = 0;
+ dm_device.pr_dev_info.order = -1;
ret = page_reporting_register(&dm_device.pr_dev_info);
if (ret < 0) {
dm_device.pr_dev_info.report = NULL;
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] virtio_balloon: Set pr_dev.order to new default
2026-02-26 7:01 [PATCH 0/3] Allow order zero pages in page reporting Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 1/3] mm/page_reporting: Allow zero page_reporting_order Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 2/3] hv_balloon: Change default page reporting order Yuvraj Sakshith
@ 2026-02-26 7:01 ` Yuvraj Sakshith
2026-02-26 17:43 ` David Hildenbrand (Arm)
2 siblings, 1 reply; 6+ messages in thread
From: Yuvraj Sakshith @ 2026-02-26 7:01 UTC (permalink / raw)
To: akpm, mst, david
Cc: vbabka, surenb, mhocko, jackmanb, hannes, ziy, linux-mm,
jasowang, xuanzhuo, eperezma, virtualization, kys, haiyangz,
wei.liu, decui, longli, linux-hyperv, linux-kernel
Drivers registering with page reporting used zero
as a way to signal page_reporting_order to be set
as a default value (either passed as a param or
MAX_PAGE_ORDER).
Since page_reporting_order can now have zero as
valid order, default fallback value send by drivers
to page reporting is now -1.
Signed-off-by: Yuvraj Sakshith <yuvraj.sakshith@oss.qualcomm.com>
---
drivers/virtio/virtio_balloon.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 74fe59f5a..3cc3dc28a 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -1044,6 +1044,20 @@ static int virtballoon_probe(struct virtio_device *vdev)
goto out_unregister_oom;
}
+ /*
+ * page_reporting_register() takes the order either
+ * from the driver or the commandline. If neither
+ * are provided, it falls back to MAX_PAGE_ORDER.
+ *
+ * Order given by the driver is required to be in the
+ * range [0, MAX_PAGE_ORDER].
+ *
+ * One way for the driver to not provide any order
+ * is by setting it to -1.
+ */
+
+ vb->pr_dev_info.order = -1;
+
/*
* The default page reporting order is @pageblock_order, which
* corresponds to 512MB in size on ARM64 when 64KB base page
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] hv_balloon: Change default page reporting order
2026-02-26 7:01 ` [PATCH 2/3] hv_balloon: Change default page reporting order Yuvraj Sakshith
@ 2026-02-26 17:34 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-02-26 17:34 UTC (permalink / raw)
To: Yuvraj Sakshith, akpm, mst
Cc: vbabka, surenb, mhocko, jackmanb, hannes, ziy, linux-mm,
jasowang, xuanzhuo, eperezma, virtualization, kys, haiyangz,
wei.liu, decui, longli, linux-hyperv, linux-kernel
On 2/26/26 08:01, Yuvraj Sakshith wrote:
> page_reporting_order used to fall back to default
> value (passed as parameter or MAX_PAGE_ORDER) if
> the driver wishes to not provide it.
>
> The way the driver used to do this was by passing
> the order as zero.
>
> Now that zero is a valid order that can be passed by
> a driver to page reporting, we use -1 to signal
> default value to be used.
>
> Signed-off-by: Yuvraj Sakshith <yuvraj.sakshith@oss.qualcomm.com>
> ---
> drivers/hv/hv_balloon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index 2b4080e51..e33d6e3b2 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -1663,7 +1663,7 @@ static void enable_page_reporting(void)
> * We let the page_reporting_order parameter decide the order
> * in the page_reporting code
> */
> - dm_device.pr_dev_info.order = 0;
> + dm_device.pr_dev_info.order = -1;
> ret = page_reporting_register(&dm_device.pr_dev_info);
> if (ret < 0) {
> dm_device.pr_dev_info.report = NULL;
Logically, that patch must come before #1. And the patch description
should be rephrased to clarify that we want to change that behavior.
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] virtio_balloon: Set pr_dev.order to new default
2026-02-26 7:01 ` [PATCH 3/3] virtio_balloon: Set pr_dev.order to new default Yuvraj Sakshith
@ 2026-02-26 17:43 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-02-26 17:43 UTC (permalink / raw)
To: Yuvraj Sakshith, akpm, mst
Cc: vbabka, surenb, mhocko, jackmanb, hannes, ziy, linux-mm,
jasowang, xuanzhuo, eperezma, virtualization, kys, haiyangz,
wei.liu, decui, longli, linux-hyperv, linux-kernel
On 2/26/26 08:01, Yuvraj Sakshith wrote:
> Drivers registering with page reporting used zero
> as a way to signal page_reporting_order to be set
> as a default value (either passed as a param or
> MAX_PAGE_ORDER).
>
> Since page_reporting_order can now have zero as
> valid order, default fallback value send by drivers
> to page reporting is now -1.
>
> Signed-off-by: Yuvraj Sakshith <yuvraj.sakshith@oss.qualcomm.com>
> ---
> drivers/virtio/virtio_balloon.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 74fe59f5a..3cc3dc28a 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -1044,6 +1044,20 @@ static int virtballoon_probe(struct virtio_device *vdev)
> goto out_unregister_oom;
> }
>
> + /*
> + * page_reporting_register() takes the order either
> + * from the driver or the commandline. If neither
> + * are provided, it falls back to MAX_PAGE_ORDER.
> + *
> + * Order given by the driver is required to be in the
> + * range [0, MAX_PAGE_ORDER].
> + *
> + * One way for the driver to not provide any order
> + * is by setting it to -1.
> + */
> +
> + vb->pr_dev_info.order = -1;
That overly-long comment indicates that we can do better.
What about the following:
Patch #1: Introduce PAGE_REPORTING_DEFAULT_ORDER
diff --git a/include/linux/page_reporting.h b/include/linux/page_reporting.h
index fe648dfa3a7c..3e21bfbb49a4 100644
--- a/include/linux/page_reporting.h
+++ b/include/linux/page_reporting.h
@@ -8,6 +8,9 @@
/* This value should always be a power of 2, see page_reporting_cycle() */
#define PAGE_REPORTING_CAPACITY 32
+/* Specifying this value as minimal reporting order selects the default. */
+#define PAGE_REPORTING_DEFAULT_ORDER 0
+
struct page_reporting_dev_info {
/* function that alters pages to make them "reported" */
int (*report)(struct page_reporting_dev_info *prdev,
diff --git a/mm/page_reporting.c b/mm/page_reporting.c
index f0042d5743af..d5191cb6b31c 100644
--- a/mm/page_reporting.c
+++ b/mm/page_reporting.c
@@ -370,7 +370,8 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)
*/
if (page_reporting_order == -1) {
- if (prdev->order > 0 && prdev->order <= MAX_PAGE_ORDER)
+ if (prdev->order != PAGE_REPORTING_DEFAULT_ORDER &&
+ prdev->order <= MAX_PAGE_ORDER)
page_reporting_order = prdev->order;
else
page_reporting_order = pageblock_order;
Patch #2: Use the define in hyperv
Patch #3: Use the define in virtio-balloon
Patch #4: Change PAGE_REPORTING_DEFAULT_ORDER to "MAX_PAGE_ORDER + 1" or sth. like that.
Then I think you can just drop the comment in virtballoon_probe() completely.
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-26 17:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26 7:01 [PATCH 0/3] Allow order zero pages in page reporting Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 1/3] mm/page_reporting: Allow zero page_reporting_order Yuvraj Sakshith
2026-02-26 7:01 ` [PATCH 2/3] hv_balloon: Change default page reporting order Yuvraj Sakshith
2026-02-26 17:34 ` David Hildenbrand (Arm)
2026-02-26 7:01 ` [PATCH 3/3] virtio_balloon: Set pr_dev.order to new default Yuvraj Sakshith
2026-02-26 17:43 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox