From: pratmal@google.com
To: Anshuman Khandual <anshuman.khandual@arm.com>,
David Hildenbrand <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@kernel.org>
Cc: Greg Thelen <gthelen@google.com>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Pratyush Mallick <pratmal@google.com>
Subject: [PATCH v2] mm/page_reporting: Add page_reporting_delay_ms sysctl
Date: Wed, 22 Jul 2026 21:15:17 +0000 [thread overview]
Message-ID: <20260722211517.1898228-1-pratmal@google.com> (raw)
From: Pratyush Mallick <pratmal@google.com>
Currently, the free page reporting daemon uses a hardcoded delay of
(2 HZ) between reporting intervals. While this is a reasonable
default, it lacks the flexibility to adapt to varying guest workloads.
A low delay allows aggressive memory reclamation, returning unused
pages to the host as quickly as possible. However, during spiky
allocation/free churn, this immediate reporting can lead to a severe
performance penalty (nested page faults) as the guest re-allocates memory
that the host has just unmapped. In these scenarios, there is benefit
from increasing the delay to batch free pages over a longer window,
absorbing the churn without hypercall and re-fault overhead.
This patch refactors the delay into a dynamically tunable sysctl,
/proc/sys/vm/page_reporting_delay_ms, measured in milliseconds. The value
defaults to 2000ms to precisely match the original (2 HZ) behavior.
Signed-off-by: Pratyush Mallick <pratmal@google.com>
---
v2:
- Documented page_reporting_delay_ms in Documentation/admin-guide/sysctl/vm.rst.
- v1: https://lore.kernel.org/linux-mm/20260722192935.1646848-1-pratmal@google.com/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/20260714171456.2350037-1-pratmal@google.com/T/#u
Documentation/admin-guide/sysctl/vm.rst | 13 +++++++++++
mm/page_reporting.c | 30 ++++++++++++++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
index b9b0c218bfb4..6efa460b4547 100644
--- a/Documentation/admin-guide/sysctl/vm.rst
+++ b/Documentation/admin-guide/sysctl/vm.rst
@@ -66,6 +66,7 @@ Currently, these files are in /proc/sys/vm:
- overcommit_ratio
- page-cluster
- page_lock_unfairness
+- page_reporting_delay
- panic_on_oom
- percpu_pagelist_high_fraction
- stat_interval
@@ -896,6 +897,18 @@ stolen from under a waiter. After the lock is stolen the number of times
specified in this file (default is 5), the "fair lock handoff" semantics
will apply, and the waiter will only be awakened if the lock can be taken.
+page_reporting_delay
+=======================
+
+This value determines the delay in milliseconds between free page
+reporting intervals. A lower delay allows aggressive memory
+reclamation by returning unused pages to the host quickly, while a
+higher delay helps to batch free pages over a longer window, absorbing
+allocation/free churn without hypercall and re-fault overhead.
+
+The default value is 2000 (2 seconds). The minimum allowed value is
+0 (immediate reporting) and the maximum allowed value is 10000 (10 seconds).
+
panic_on_oom
============
diff --git a/mm/page_reporting.c b/mm/page_reporting.c
index 942e84b6908a..805da4bc1101 100644
--- a/mm/page_reporting.c
+++ b/mm/page_reporting.c
@@ -6,6 +6,7 @@
#include <linux/export.h>
#include <linux/module.h>
#include <linux/delay.h>
+#include <linux/sysctl.h>
#include <linux/scatterlist.h>
#include "page_reporting.h"
@@ -47,7 +48,10 @@ MODULE_PARM_DESC(page_reporting_order, "Set page reporting order");
*/
EXPORT_SYMBOL_GPL(page_reporting_order);
-#define PAGE_REPORTING_DELAY (2 * HZ)
+#define PAGE_REPORTING_DELAY_MS_MAX (10 * MSEC_PER_SEC)
+
+static unsigned int page_reporting_delay_ms = 2 * MSEC_PER_SEC;
+static unsigned int page_reporting_delay_ms_max = PAGE_REPORTING_DELAY_MS_MAX;
static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly;
enum {
@@ -56,6 +60,19 @@ enum {
PAGE_REPORTING_ACTIVE
};
+
+static struct ctl_table page_reporting_sysctls[] = {
+ {
+ .procname = "page_reporting_delay",
+ .data = &page_reporting_delay_ms,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_douintvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = &page_reporting_delay_ms_max,
+ },
+};
+
/* request page reporting */
static void
__page_reporting_request(struct page_reporting_dev_info *prdev)
@@ -80,7 +97,7 @@ __page_reporting_request(struct page_reporting_dev_info *prdev)
* now we are limiting this to running no more than once every
* couple of seconds.
*/
- schedule_delayed_work(&prdev->work, PAGE_REPORTING_DELAY);
+ schedule_delayed_work(&prdev->work, msecs_to_jiffies(page_reporting_delay_ms));
}
/* notify prdev of free page reporting request */
@@ -340,7 +357,7 @@ static void page_reporting_process(struct work_struct *work)
*/
state = atomic_cmpxchg(&prdev->state, state, PAGE_REPORTING_IDLE);
if (state == PAGE_REPORTING_REQUESTED)
- schedule_delayed_work(&prdev->work, PAGE_REPORTING_DELAY);
+ schedule_delayed_work(&prdev->work, msecs_to_jiffies(page_reporting_delay_ms));
}
static DEFINE_MUTEX(page_reporting_mutex);
@@ -416,3 +433,10 @@ void page_reporting_unregister(struct page_reporting_dev_info *prdev)
mutex_unlock(&page_reporting_mutex);
}
EXPORT_SYMBOL_GPL(page_reporting_unregister);
+
+static int __init page_reporting_sysctl_init(void)
+{
+ register_sysctl_init("vm", page_reporting_sysctls);
+ return 0;
+}
+late_initcall(page_reporting_sysctl_init);
--
2.55.0.229.g6434b31f56-goog
next reply other threads:[~2026-07-22 21:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 21:15 pratmal [this message]
2026-07-22 22:54 ` [PATCH v2] mm/page_reporting: Add page_reporting_delay_ms sysctl Andrew Morton
2026-07-23 0:06 ` SJ Park
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=20260722211517.1898228-1-pratmal@google.com \
--to=pratmal@google.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=david@redhat.com \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.