mm/page_reporting: Add page_reporting_delay_ms module parameter
Subsystems (3)
PATCH v4 1/1 mm/page_reporting: Add page_reporting_delay_ms module parameter
From: Pratyush Mallick <[email protected]>
Free page reporting currently hardcodes a 2-second interval between reports. This rigid delay cannot accommodate diverse guest workloads.
This patch introduces a module parameter, page_reporting_delay_ms (default: 2000), allowing users to tune the reporting rate:
- Lower values enable aggressive memory reclamation by returning unused pages to the host immediately.
- Higher values help batch pages during spiky allocation/free churn, reducing hypercalls and nested page fault overheads.
Setting the delay to 0 is safe and execution is strictly gated by:
- reporting is only triggered by high-order page frees.
- expensive hypercalls are bounded by a slot capacity watermark check before proceeding.
---
v4:
- Added a helper function for schedule_delayed_work().
- Updated the commit message.
- v3: https://lore.kernel.org/linux-mm/amiPTPKfTOEpgetH@lucifer/T/#t
v3:
- Converted page_reporting_delay_ms from a sysctl to a module parameter.
- Dropped the max value cap (PAGE_REPORTING_DELAY_MS_MAX).
- Documented page_reporting.page_reporting_delay_ms in Documentation/admin-guide/kernel-parameters.txt.
- Updated code comments in mm/page_reporting.c to reflect dynamic parameterization.
- v2: https://lore.kernel.org/linux-mm/[email protected]/T/#t
v2:
- Documented page_reporting_delay_ms in Documentation/admin-guide/sysctl/vm.rst.
- v1: https://lore.kernel.org/linux-mm/[email protected]/T/#u
v1: Fixed feedback from RFC.
- Added lower and upper cap to sysctl value.
- Reverted the reordering on page_reporting_delay_ms.
- Dropped the mod_delayed_work() change.
- RFC: https://lore.kernel.org/linux-mm/[email protected]/T/#u
.../admin-guide/kernel-parameters.txt | 6 +++++ mm/page_reporting.c | 26 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -4810,6 +4810,12 @@ Kernel parameters Adjust the minimal page reporting order. The page reporting is disabled when it exceeds MAX_PAGE_ORDER. + page_reporting.page_reporting_delay_ms= + [KNL] Free page reporting delay in milliseconds + Format: <unsigned integer> + Adjust the delay in milliseconds between free page + reporting intervals. Default is 2000 (2 seconds). + panic= [KNL] Kernel behaviour on panic: delay <timeout> timeout > 0: seconds before rebooting timeout = 0: wait forever
mm/page_reporting.c +18 -8
@@ -47,7 +47,11 @@ MODULE_PARM_DESC(page_reporting_order, "Set page reporting order");*/ EXPORT_SYMBOL_GPL (page_reporting_order); -#define PAGE_REPORTING_DELAY (2 * HZ) +static unsigned int page_reporting_delay_ms =2 *MSEC_PER_SEC ; +module_param (page_reporting_delay_ms, uint,0644 ); +MODULE_PARM_DESC (page_reporting_delay_ms, +"Set page reporting delay in milliseconds" ); +static struct page_reporting_dev_info __rcu *pr_dev_info__read_mostly ;enum {
@@ -56,6 +60,13 @@ enum { PAGE_REPORTING_ACTIVE }; +/* schedule work for page reporting */ +static void page_reporting_schedule_work (struct page_reporting_dev_info *prdev) +{ +schedule_delayed_work (&prdev->work, +msecs_to_jiffies (page_reporting_delay_ms)); +} +/* request page reporting */ static void __page_reporting_request (struct page_reporting_dev_info *prdev)
@@ -76,11 +87,10 @@ __page_reporting_request(struct page_reporting_dev_info *prdev)return ;/* -* Delay the start of work to allow a sizable queue to build. For -* now we are limiting this to running no more than once every -* couple of seconds. +* Delay the start of work to allow a sizable queue to build. +* We limit this based on page_reporting_delay_ms. */ -schedule_delayed_work (&prdev->work,PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }/* notify prdev of free page reporting request */
@@ -335,12 +345,12 @@ static void page_reporting_process(struct work_struct *work) err_out:/* * If the state has reverted back to requested then there may be -* additional pages to be processed. We will defer for 2s to allow -* more pages to accumulate. +* additional pages to be processed. We will defer by +* page_reporting_delay_ms to allow more pages to accumulate. */ state =atomic_cmpxchg (&prdev->state, state,PAGE_REPORTING_IDLE );if (state ==PAGE_REPORTING_REQUESTED ) -schedule_delayed_work (&prdev->work,PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }static DEFINE_MUTEX (page_reporting_mutex);
Signature · 1 line
2.55.0.508.g3f0d502094-goog
Andrew Morton
maintainerQuoted 10 lines · On Fri, 31 Jul 2026 19:37:05 +0000 [email protected] wrote:
Free page reporting currently hardcodes a 2-second interval between reports. This rigid delay cannot accommodate diverse guest workloads.
This patch introduces a module parameter,
page_reporting_delay_ms(default: 2000), allowing users to tune the reporting rate:
- Lower values enable aggressive memory reclamation by returning unused pages to the host immediately.
- Higher values help batch pages during spiky allocation/free churn, reducing hypercalls and nested page fault overheads.
Quoted 4 lines
Setting the delay to 0 is safe and execution is strictly gated by:
- reporting is only triggered by high-order page frees.
- expensive hypercalls are bounded by a slot capacity watermark check before proceeding.
This conflcits with the just-upstreamed 0b45f6927a1 ("mm/page_reporting: use system_freezable_wq to fix UAF during suspend")
(https://lore.kernel.org/[email protected]).
Please review my resolution:
mm/page_reporting.c renamed from mm/page_reporting.c~mm-page_reporting-add-page_reporting_delay_ms-module-parameter +18 -10
@@ -48,7 +48,11 @@ MODULE_PARM_DESC(page_reporting_order, "*/ EXPORT_SYMBOL_GPL (page_reporting_order); -#define PAGE_REPORTING_DELAY (2 * HZ) +static unsigned int page_reporting_delay_ms =2 *MSEC_PER_SEC ; +module_param (page_reporting_delay_ms, uint,0644 ); +MODULE_PARM_DESC (page_reporting_delay_ms, +"Set page reporting delay in milliseconds" ); +static struct page_reporting_dev_info __rcu *pr_dev_info__read_mostly ;enum {
@@ -57,6 +61,13 @@ enum { PAGE_REPORTING_ACTIVE }; +/* schedule work for page reporting */ +static void page_reporting_schedule_work (struct page_reporting_dev_info *prdev) +{ +queue_delayed_work (system_freezable_wq, &prdev->work, +msecs_to_jiffies (page_reporting_delay_ms)); +} +/* request page reporting */ static void __page_reporting_request (struct page_reporting_dev_info *prdev)
@@ -77,12 +88,10 @@ __page_reporting_request(struct page_repreturn ;/* -* Delay the start of work to allow a sizable queue to build. For -* now we are limiting this to running no more than once every -* couple of seconds. +* Delay the start of work to allow a sizable queue to build. +* We limit this based on page_reporting_delay_ms. */ -queue_delayed_work (system_freezable_wq, &prdev->work, -PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }/* notify prdev of free page reporting request */
@@ -337,13 +346,12 @@ static void page_reporting_process(struc err_out:/* * If the state has reverted back to requested then there may be -* additional pages to be processed. We will defer for 2s to allow -* more pages to accumulate. +* additional pages to be processed. We will defer by +* page_reporting_delay_ms to allow more pages to accumulate. */ state =atomic_cmpxchg (&prdev->state, state,PAGE_REPORTING_IDLE );if (state ==PAGE_REPORTING_REQUESTED ) -queue_delayed_work (system_freezable_wq, &prdev->work, -PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }static DEFINE_MUTEX (page_reporting_mutex);
_
Sorry I forgot to update it in v4. Resolution looks good to me. Thanks Again!
Regards,
Pratyush
Quoted 89 lines · Andrew Morton
Quoted 10 lines · On Fri, 31 Jul 2026 19:37:05 +0000 [email protected] wrote:
Free page reporting currently hardcodes a 2-second interval between reports. This rigid delay cannot accommodate diverse guest workloads.
This patch introduces a module parameter,
page_reporting_delay_ms(default: 2000), allowing users to tune the reporting rate:
- Lower values enable aggressive memory reclamation by returning unused pages to the host immediately.
- Higher values help batch pages during spiky allocation/free churn, reducing hypercalls and nested page fault overheads.Quoted 4 lines
Setting the delay to 0 is safe and execution is strictly gated by:
- reporting is only triggered by high-order page frees.
- expensive hypercalls are bounded by a slot capacity watermark check before proceeding.This conflcits with the just-upstreamed
0b45f6927a1("mm/page_reporting: usesystem_freezable_wqto fix UAF during suspend")
(https://lore.kernel.org/[email protected]).Please review my resolution:
mm/page_reporting.c renamed from mm/page_reporting.c~mm-page_reporting-add-page_reporting_delay_ms-module-parameter +18
-10@@ -48,7 +48,11 @@ MODULE_PARM_DESC(page_reporting_order, "*/ EXPORT_SYMBOL_GPL (page_reporting_order); -#define PAGE_REPORTING_DELAY (2 * HZ) +static unsigned int page_reporting_delay_ms =2 *MSEC_PER_SEC ; +module_param (page_reporting_delay_ms, uint,0644 ); +MODULE_PARM_DESC (page_reporting_delay_ms, +"Set page reporting delay in milliseconds" ); +static struct page_reporting_dev_info __rcu *pr_dev_info__read_mostly ;enum {@@ -57,6 +61,13 @@ enum { PAGE_REPORTING_ACTIVE }; +/* schedule work for page reporting */ +static void page_reporting_schedule_work (struct page_reporting_dev_info *prdev) +{ +queue_delayed_work (system_freezable_wq, &prdev->work, +msecs_to_jiffies (page_reporting_delay_ms)); +} +/* request page reporting */ static void __page_reporting_request (struct page_reporting_dev_info *prdev)@@ -77,12 +88,10 @@ __page_reporting_request(struct page_repreturn ;/* -* Delay the start of work to allow a sizable queue to build. For -* now we are limiting this to running no more than once every -* couple of seconds. +* Delay the start of work to allow a sizable queue to build. +* We limit this based on page_reporting_delay_ms. */ -queue_delayed_work (system_freezable_wq, &prdev->work, -PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }/* notify prdev of free page reporting request */ @@ -337,13 +346,12 @@ static void page_reporting_process(struc err_out:/* * If the state has reverted back to requested then there may be -* additional pages to be processed. We will defer for 2s to allow -* more pages to accumulate. +* additional pages to be processed. We will defer by +* page_reporting_delay_ms to allow more pages to accumulate. */ state =atomic_cmpxchg (&prdev->state, state,PAGE_REPORTING_IDLE );if (state ==PAGE_REPORTING_REQUESTED ) -queue_delayed_work (system_freezable_wq, &prdev->work, -PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }static DEFINE_MUTEX (page_reporting_mutex);_
David Hildenbrand (Arm)
Acked-byQuoted 40 lines · Andrew Morton
Quoted 10 lines · On Fri, 31 Jul 2026 19:37:05 +0000 [email protected] wrote:
Free page reporting currently hardcodes a 2-second interval between reports. This rigid delay cannot accommodate diverse guest workloads.
This patch introduces a module parameter,
page_reporting_delay_ms(default: 2000), allowing users to tune the reporting rate:
- Lower values enable aggressive memory reclamation by returning unused pages to the host immediately.
- Higher values help batch pages during spiky allocation/free churn, reducing hypercalls and nested page fault overheads.Quoted 4 lines
Setting the delay to 0 is safe and execution is strictly gated by:
- reporting is only triggered by high-order page frees.
- expensive hypercalls are bounded by a slot capacity watermark check before proceeding.This conflcits with the just-upstreamed
0b45f6927a1("mm/page_reporting: usesystem_freezable_wqto fix UAF during suspend")
(https://lore.kernel.org/[email protected]).Please review my resolution:
mm/page_reporting.c renamed from mm/page_reporting.c~mm-page_reporting-add-page_reporting_delay_ms-module-parameter +5
-1@@ -48,7 +48,11 @@ MODULE_PARM_DESC(page_reporting_order, "*/ EXPORT_SYMBOL_GPL (page_reporting_order); -#define PAGE_REPORTING_DELAY (2 * HZ) +static unsigned int page_reporting_delay_ms =2 *MSEC_PER_SEC ; +module_param (page_reporting_delay_ms, uint,0644 ); +MODULE_PARM_DESC (page_reporting_delay_ms, +"Set page reporting delay in milliseconds" ); +static struct page_reporting_dev_info __rcu *pr_dev_info__read_mostly ;enum {
mm/page_reporting.c enum { · line 68
Quoted 8 lines
mm/page_reporting.c renamed from mm/page_reporting.c~mm-page_reporting-add-page_reporting_delay_ms-module-parameter +5
-0@@ -57,6 +61,13 @@ enum { PAGE_REPORTING_ACTIVE }; +/* schedule work for page reporting */ +static void page_reporting_schedule_work (struct page_reporting_dev_info *prdev) +{ +queue_delayed_work (system_freezable_wq, &prdev->work, +msecs_to_jiffies (page_reporting_delay_ms));
^ just double checking whether that is indented properly .
Signature · 3 lines
Cheers, David
Brendan changed his mail address [1]. I added him to the recipient list.
Quoted 12 lines · On Fri, 31 Jul 2026 19:37:05 +0000 [email protected] wrote:
From: Pratyush Mallick <[email protected]>
Free page reporting currently hardcodes a 2-second interval between reports. This rigid delay cannot accommodate diverse guest workloads.
This patch introduces a module parameter,
page_reporting_delay_ms(default: 2000), allowing users to tune the reporting rate:
- Lower values enable aggressive memory reclamation by returning unused pages to the host immediately.
- Higher values help batch pages during spiky allocation/free churn, reducing hypercalls and nested page fault overheads.
Quoted 4 lines
Setting the delay to 0 is safe and execution is strictly gated by:
- reporting is only triggered by high-order page frees.
- expensive hypercalls are bounded by a slot capacity watermark check before proceeding.
Looks good and making sense to me.
Quoted 2 lines
Signed-off-by Pratyush Mallick <[email protected]>
[1] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]
Quoted 12 lines · On Fri, Jul 31, 2026 at 07:37:05PM +0000, [email protected] wrote:
From: Pratyush Mallick <[email protected]>
Free page reporting currently hardcodes a 2-second interval between reports. This rigid delay cannot accommodate diverse guest workloads.
This patch introduces a module parameter,
page_reporting_delay_ms(default: 2000), allowing users to tune the reporting rate:
- Lower values enable aggressive memory reclamation by returning unused pages to the host immediately.
- Higher values help batch pages during spiky allocation/free churn, reducing hypercalls and nested page fault overheads.
Quoted 4 lines
Setting the delay to 0 is safe and execution is strictly gated by:
- reporting is only triggered by high-order page frees.
- expensive hypercalls are bounded by a slot capacity watermark check before proceeding.
Thanks!
Quoted 2 lines
Signed-off-by Pratyush Mallick <[email protected]>
LGTM so:
Quoted 103 lines
---
v4:
- Added a helper function forschedule_delayed_work().
- Updated the commit message.
- v3: https://lore.kernel.org/linux-mm/amiPTPKfTOEpgetH@lucifer/T/#t
v3:
- Convertedpage_reporting_delay_msfrom a sysctl to a module parameter.
- Dropped the max value cap (PAGE_REPORTING_DELAY_MS_MAX).
- Documented page_reporting.page_reporting_delay_ms inDocumentation/admin-guide/kernel-parameters.txt.
- Updated code comments inmm/page_reporting.cto reflect dynamic parameterization.
- v2: https://lore.kernel.org/linux-mm/[email protected]/T/#t
v2:
- Documentedpage_reporting_delay_msinDocumentation/admin-guide/sysctl/vm.rst.
- v1: https://lore.kernel.org/linux-mm/[email protected]/T/#u
v1: Fixed feedback from RFC.
- Added lower and upper cap to sysctl value.
- Reverted the reordering onpage_reporting_delay_ms.
- Dropped themod_delayed_work()change.
- RFC: https://lore.kernel.org/linux-mm/[email protected]/T/#u.../admin-guide/kernel-parameters.txt | 6 +++++ mm/page_reporting.c | 26 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-)Documentation/admin-guide/kernel-parameters.txt +6
-0@@ -4810,6 +4810,12 @@ Kernel parameters Adjust the minimal page reporting order. The page reporting is disabled when it exceeds MAX_PAGE_ORDER. + page_reporting.page_reporting_delay_ms= + [KNL] Free page reporting delay in milliseconds + Format: <unsigned integer> + Adjust the delay in milliseconds between free page + reporting intervals. Default is 2000 (2 seconds). + panic= [KNL] Kernel behaviour on panic: delay <timeout> timeout > 0: seconds before rebooting timeout = 0: wait forevermm/page_reporting.c +18
-9@@ -47,7 +47,11 @@ MODULE_PARM_DESC(page_reporting_order, "Set page reporting order");*/ EXPORT_SYMBOL_GPL (page_reporting_order); -#define PAGE_REPORTING_DELAY (2 * HZ) +static unsigned int page_reporting_delay_ms =2 *MSEC_PER_SEC ; +module_param (page_reporting_delay_ms, uint,0644 ); +MODULE_PARM_DESC (page_reporting_delay_ms, +"Set page reporting delay in milliseconds" ); +static struct page_reporting_dev_info __rcu *pr_dev_info__read_mostly ;enum {@@ -56,6 +60,13 @@ enum { PAGE_REPORTING_ACTIVE }; +/* schedule work for page reporting */ +static void page_reporting_schedule_work (struct page_reporting_dev_info *prdev) +{ +schedule_delayed_work (&prdev->work, +msecs_to_jiffies (page_reporting_delay_ms)); +} +/* request page reporting */ static void __page_reporting_request (struct page_reporting_dev_info *prdev)@@ -76,11 +87,10 @@ __page_reporting_request(struct page_reporting_dev_info *prdev)return ;/* -* Delay the start of work to allow a sizable queue to build. For -* now we are limiting this to running no more than once every -* couple of seconds. +* Delay the start of work to allow a sizable queue to build. +* We limit this based on page_reporting_delay_ms. */ -schedule_delayed_work (&prdev->work,PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }/* notify prdev of free page reporting request */ @@ -335,12 +345,12 @@ static void page_reporting_process(struct work_struct *work) err_out:/* * If the state has reverted back to requested then there may be -* additional pages to be processed. We will defer for 2s to allow -* more pages to accumulate. +* additional pages to be processed. We will defer by +* page_reporting_delay_ms to allow more pages to accumulate. */ state =atomic_cmpxchg (&prdev->state, state,PAGE_REPORTING_IDLE );if (state ==PAGE_REPORTING_REQUESTED ) -schedule_delayed_work (&prdev->work,PAGE_REPORTING_DELAY ); +page_reporting_schedule_work (prdev); }static DEFINE_MUTEX (page_reporting_mutex); --
Quoted 2 lines
2.55.0.508.g3f0d502094-goog
--
Cheers, Lorenzo