From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 2798F3E0C76 for ; Mon, 27 Jul 2026 23:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785193550; cv=none; b=U3otE2OuGy37yhAHQyPJIRhgjDiAmEgVhLkR4hzxlwiC68lQBy8VTQQQ30pD5qlqFrYu9IRYA13GvqkDLxPp1+o1vRdWvWwj+l+a7MwxvIVQeRtcu/S5dChDbe4iiTNoz5uLqRypBWPaAAkyUO1keE1YcxocKI5DpED0VfJwXU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785193550; c=relaxed/simple; bh=IMjQJw16RAAwAtYnIc+WsIqMjJ3c9v+3r6PBzyWepzA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=uO3qoaV/lCs0SKvFVy1iErf7oc7uXIf3dq/OBwJwRzdzB3njBkzkjHBVARf1DeFWZ4fEd4pVc/xB32bVUsc0RahQGdxRPBTQwCKXRRYC9GYDU2EkLygx6+VDMBTPoYPfoTTys8cFqEtewQ/0x3z4JPOOAF+b1Ym0oYJ1iWbIUww= 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=f32UOKEl; arc=none smtp.client-ip=209.85.215.198 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="f32UOKEl" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cb6dd278512so2028785a12.3 for ; Mon, 27 Jul 2026 16:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785193548; x=1785798348; 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=lCgFliqJWz+M9tZQ5Il6O3npkwRo/L4rfW7GdWN7+m0=; b=f32UOKElxHmmdh1i7VuMtO0X680cF0EUugfryK+E2CwzWPNocbSGKTLriGUfrWub8r N92nn7Zps6wclXvp8a5bQoPFoVpn5nQrP8/N8HqkkpMCZEaTpV5b8jDEOI+RbnIxlPK0 wYkGtBMBR7oCE//Dz6wy0kKIf0ra51GAChtbcAPoNuZ2ylx9s7Jo6BroPkB+RAfVilwr DGCgV7Am2d6L8K6oovCRQxOTQMV7bKIsmyML51cTUUh0SVqVztEP+DahSjwoV53REgjL 3tVJHA+eexV0ZdDwamjNWa2dew3FjqFQspz9sPPmOwov2k7M7vQEZ+QSARC1gyc0wafj 9xWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785193548; x=1785798348; 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=lCgFliqJWz+M9tZQ5Il6O3npkwRo/L4rfW7GdWN7+m0=; b=mNYBzP/DKq7kFDopIhZiRK+hg+Jgk5QmPvhFp/jKFlqrUlEes4qyoOuPyNMxyGPJIa wcHAdfZsFFh4rfViUENqjArZRSm/WJl7gYkdeop970ZGTbEB+fioDc5q8lxCcy9j8GxW iRIZFTKOUAg3AxpCt9Pnyym0LzGrWuP2yJRn0EHa7Uk3JIZov1bH7tc2OxCc6rx1YcLQ e0mU2FtZxVfAQ/sZXU8q4S7DWYTi+ZCboN7Or3w+8FVTAvTo9A9+lYAxP9wzS4CcTaRV A7j7I+P0hruNNsUAbj3GBa7rMhtS/5KRm8V3h6lSNzHnOwaxUM0WArjgZoMq2YsLFV42 56dA== X-Forwarded-Encrypted: i=1; AHgh+RqwjLXmvRVddJ8O4WhuCeG8SJ8o6TwaB1KY2NBBL468wD1h70e5wTB3MXBxtd9xcL8F5KWM6cGTPKRicRM=@vger.kernel.org X-Gm-Message-State: AOJu0YxF4y51KPOoBr+yTMv/uphFEmJyu7MuOiqC1iJvxKoCFuKgLz2+ 1pGZ9e0X7yQKJisxjFmqKN142u2P4pG5GWof9wkPIHD+ZLJjP6KvZNZX9atVB72d2crjn/ceJux t5jZ+NJp6vQ== X-Received: from dykm9.prod.google.com ([2002:a05:7300:1889:b0:311:4890:b1b9]) (user=pratmal job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:b92:b0:3c3:6c90:65b3 with SMTP id adf61e73a8af0-3c67dff9882mr9745829637.65.1785193547902; Mon, 27 Jul 2026 16:05:47 -0700 (PDT) Date: Mon, 27 Jul 2026 23:05:45 +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: <20260727230545.262579-1-pratmal@google.com> Subject: [PATCH v3] mm/page_reporting: Add page_reporting_delay_ms module parameter From: pratmal@google.com To: akpm@linux-foundation.org, vbabka@kernel.org, david@kernel.org, sj@kernel.org, corbet@lwn.net Cc: skhan@linuxfoundation.org, anshuman.khandual@arm.com, gthelen@google.com, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, ljs@kernel.org, liam@infradead.org, rppt@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Pratyush Mallick Content-Type: text/plain; charset="UTF-8" From: Pratyush Mallick Currently, the free page reporting 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 exposes the delay as a module parameter: /sys/module/page_reporting/parameters/page_reporting_delay_ms, measured in milliseconds and defaults to 2000ms. Signed-off-by: Pratyush Mallick --- 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_delay_ms in kernel-parameters.txt. - Updated code comments in mm/page_reporting.c. - v2: https://lore.kernel.org/linux-mm/3da27fde-25dc-4cb8-8e05-74cd26fc2f7c@kernel.org/T/#t 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 .../admin-guide/kernel-parameters.txt | 6 ++++++ mm/page_reporting.c | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b5493a7f8f22..364c2dce8e70 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -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: + Adjust the delay in milliseconds between free page + reporting intervals. Default is 2000 (2 seconds). + panic= [KNL] Kernel behaviour on panic: delay timeout > 0: seconds before rebooting timeout = 0: wait forever diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 942e84b6908a..a67311468204 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -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 { @@ -76,11 +80,11 @@ __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); + schedule_delayed_work(&prdev->work, + msecs_to_jiffies(page_reporting_delay_ms)); } /* notify prdev of free page reporting request */ @@ -335,12 +339,13 @@ 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); + schedule_delayed_work(&prdev->work, + msecs_to_jiffies(page_reporting_delay_ms)); } static DEFINE_MUTEX(page_reporting_mutex); -- 2.55.0.229.g6434b31f56-goog