From nobody Fri Jul 24 22:17:22 2026 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00F0143B3C4 for ; Wed, 22 Jul 2026 21:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754922; cv=none; b=huYOI632OoniGEs7H0ISW6NBrgOem3WNV+Z6SVwPXfGaCRX3EejSH/0WWOCu7lDrYWWkDO5GmR7a4Z7UZK3sDr06TtgVB9CmAdyuqG/evmeNQy4IXxWxRAQxad8daMHkZUjBJT+fEK68Vw8b+JK64c2dQibL9qY8Zmp+mydPnWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754922; c=relaxed/simple; bh=GBexBHJWmjH6a4/TO+G6lPMdcF/hXj5wvGbK2sZNfho=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=M4hAjwsYIx5v0o8wuM3yoir869joCCzCPznrQ4nCpA81tGmhuQ9dnUiMt6cwEBCiqqCizwqVa+K5f11vYTofXUwBCTOfnmX4VcwAkHSNzHgUNMzjp/8wzcZJ0Ru23syvjq8qPTJAACSypCHoN1aTgAT25VcReo0DhFOAuQIRm4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pratmal.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XI7yRaCM; arc=none smtp.client-ip=209.85.214.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pratmal.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XI7yRaCM" Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2cc7e86e7c5so231051395ad.3 for ; Wed, 22 Jul 2026 14:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784754920; x=1785359720; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gbj5OI5PlzQDQcxOYA0/WolD08NrjVoBr7kUzAyBAz0=; b=XI7yRaCM5kQGyiXbkxJyipn+mXaFufvNoG066LMp4Q+5np4bKF4zkEtHKnl9G3b+eU aPZa+pkkJNyBe5NsTKCagc9ShzOPuZ+eIhRky015XPftfFgRJBEmfvCzpHdlrMdI4Y+D 8Bl0Lzx6h4BIla+xvxb/hs5TEiek918L2mVjOA9hwiZKfk6tvm82rZvGzSiIkaNHWmLT btTEJMh4XH9qmyFFFwXDygz1SUrbUO2a0PABpolFUfI+QhjXqtoN+8MhZ8bX+Hi2Q06f qEk5TM9cmpH3z7OmfNK9aNrqoIW916kKVmtDfRMDFKY1eU/+Hbc3asFaZDyBGPDz84C9 FiUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784754920; x=1785359720; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gbj5OI5PlzQDQcxOYA0/WolD08NrjVoBr7kUzAyBAz0=; b=hEyZd6LtGUfwJXm6cz4hGjeRLm0sog3Ce07EXao3sWUrdJtHT0SL/NE0FH9EupXPf8 iavxDd0hGGPdhL4xJ9Wks8SCG8sCANcvtoD3Du4VW+rzNzZFbu+2g5Cd4Pmglg1A6+wy 6sB/eOo7GWsz19IzZasK/s8xZXzrX40H20h+KPngaBMIT67pjj2r25J9EXI0X7ooRJcP ox46sq7qFDQiFt0F1nDkfH6DUsw2xZzi9Xc3dmPAJSrWsbcuiGXSCC/nYggf3mJZHnnJ GGJAK6IJZAzTjguDejMRqH6EqpZiVqVA7eYIJ9YCLsp9AgiLV+l6wod4W6mxPm0D8BRJ 2hMg== X-Forwarded-Encrypted: i=1; AHgh+Rrhm+NSG09WxllVAknVNckrTRG5e5A5zFhJ6JZrEbSY6j4Ll3irVjmAG1GzdgKPIP2Y7QnLzSrw8mtpPUA=@vger.kernel.org X-Gm-Message-State: AOJu0YyCwK+t4W9/IuqjkIok/8rIDRWj625EbTQzmXjv+fzKa4huiW/A R/gpXMXkHvYzIbMXrADlFtQG+1Ot9DI+tSjyU5okYXSw4sKxMxcPLpJBlyrj5zbUfLXypIeyJ3G 48wnFm33foA== X-Received: from dybb28.prod.google.com ([2002:a05:693c:609c:b0:30f:26b4:89f6]) (user=pratmal job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f544:b0:2cc:7c36:2c23 with SMTP id d9443c01a7336-2cfa6f8eee1mr5312055ad.43.1784754919719; Wed, 22 Jul 2026 14:15:19 -0700 (PDT) Date: Wed, 22 Jul 2026 21:15:17 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260722211517.1898228-1-pratmal@google.com> Subject: [PATCH v2] mm/page_reporting: Add page_reporting_delay_ms sysctl From: pratmal@google.com To: Anshuman Khandual , David Hildenbrand , Andrew Morton , Vlastimil Babka Cc: Greg Thelen , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pratyush Mallick Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Pratyush Mallick 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 --- v2: - Documented page_reporting_delay_ms in Documentation/admin-guide/sysctl/v= m.rst. - v1: https://lore.kernel.org/linux-mm/20260722192935.1646848-1-pratmal@go= ogle.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@g= oogle.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 t= he 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. =20 +page_reporting_delay +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 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 #include #include +#include #include =20 #include "page_reporting.h" @@ -47,7 +48,10 @@ MODULE_PARM_DESC(page_reporting_order, "Set page reporti= ng order"); */ EXPORT_SYMBOL_GPL(page_reporting_order); =20 -#define PAGE_REPORTING_DELAY (2 * HZ) +#define PAGE_REPORTING_DELAY_MS_MAX (10 * MSEC_PER_SEC) + +static unsigned int page_reporting_delay_ms =3D 2 * MSEC_PER_SEC; +static unsigned int page_reporting_delay_ms_max =3D PAGE_REPORTING_DELAY_M= S_MAX; static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly; =20 enum { @@ -56,6 +60,19 @@ enum { PAGE_REPORTING_ACTIVE }; =20 + +static struct ctl_table page_reporting_sysctls[] =3D { + { + .procname =3D "page_reporting_delay", + .data =3D &page_reporting_delay_ms, + .maxlen =3D sizeof(unsigned int), + .mode =3D 0644, + .proc_handler =3D proc_douintvec_minmax, + .extra1 =3D SYSCTL_ZERO, + .extra2 =3D &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)); } =20 /* notify prdev of free page reporting request */ @@ -340,7 +357,7 @@ static void page_reporting_process(struct work_struct *= work) */ state =3D atomic_cmpxchg(&prdev->state, state, PAGE_REPORTING_IDLE); if (state =3D=3D PAGE_REPORTING_REQUESTED) - schedule_delayed_work(&prdev->work, PAGE_REPORTING_DELAY); + schedule_delayed_work(&prdev->work, msecs_to_jiffies(page_reporting_dela= y_ms)); } =20 static DEFINE_MUTEX(page_reporting_mutex); @@ -416,3 +433,10 @@ void page_reporting_unregister(struct page_reporting_d= ev_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); --=20 2.55.0.229.g6434b31f56-goog