From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 7308732F76D for ; Fri, 31 Jul 2026 19:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785526629; cv=none; b=jGeKQ0T66zju7Rr5ZqjXkh2g3CpJGIWpvcl/SglAGUSHE/8AHgR98e4aUR393GVpJ8L/TAmyVwW4J/2cl5FciYjYWLPrUO9gSf4pr6XFfMCovlJUsQfVAXKPFyqBAUXGKvA1yIfg3fjJ4pAxXSiFFQRHsjHlkG8o/NBecWDFJuA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785526629; c=relaxed/simple; bh=qXT/YyghuLXJBSy1G2LLYi1ev8LYFIkXQQw2480uRds=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=eXRg6OZ9PUkcjzXmJ8HcrJYzBAAk2URawbESE4ED5LL/fKeHTwIr+bBOTK89NsrJLSZbd/bRGBgEb9m30BVUnz+AZd1TyJPDz4sYo4PljqGDrUHPoL3Oj36UriBn6/ADPiJo2K/PVwlWxc9jxE1GHTLgcvg2mrDt+xRcMGS6LUg= 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=nYG0NrQA; arc=none smtp.client-ip=209.85.215.199 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="nYG0NrQA" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb4bd11ddf8so1470351a12.3 for ; Fri, 31 Jul 2026 12:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785526628; x=1786131428; 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=vECLUKzXFGOEzwlGZwpZ/IhaB1EZugqHi458H7aGCEg=; b=nYG0NrQAIFuj63nhJDxmPcu1N6CVfErECmcjVMT19WThRSIlWDzqqmlU0e5Xl4ar2B 2jY8S4VbH17U25hjjHg65iNGe+w4sWJ10nkGivRCxe9sf+ciIQBEfqVlUv7RfMhaGR+G Xip6nHXNSJeAfBsleV8lRUBRVk7mmMDqsp8HANtR2aXPLamp9y0ueXEGMJpVkYKbCstF 7t+haRCNRfDpVxedRQB7H5bvFFoeQCd4Uqdz1G77nBzt4R+V4hMPzcCBenp7aep7SVqk h6AFgx7b065m4bJBEr59biEiOWzf4PxKszNP78MaShtHQ71Ve0f49zMDyz2UNzIQUtF/ +eIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785526628; x=1786131428; 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=vECLUKzXFGOEzwlGZwpZ/IhaB1EZugqHi458H7aGCEg=; b=DJAnq3HIcP+UdGLj1CwgOvmqfMEguOiKWLxpwIQwUk2gYYg+Fsjg7DJg0z1zwGc+c2 1miTmv+BEOE9vNpr8RIXRdC0l9GHysCgAnSCqd6/dYFhLg10Hq6clXqaPaHnltf4izyp 96ELzwZdWb/9Biee1Aw+9jidwD4JPuu/qwsH1D0C07qFZEAvM+p0NwthLs/4WnkFwzDZ mLmDjRGIh+pwPbbBGudh9o6oP/AmJ0TsR4jAAHO/Vz8Cz3i9UJHwJ5FqsSl2K408yoGO bfX2xcdZnm7ZawlLVxdeMr6p1wclo6PpqNVaS9p7Ktl3AWECCxkUilrcLKI987KShvzt wETA== X-Forwarded-Encrypted: i=1; AHgh+RqkCM/PYTCUneDoGrpDlVt64FUH0x5GJgstVbJglwiTJh189IyHhPKI1YZTjGO9cWQW5FKm8fYeQeUQRa4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9ItzwVFJvyU3CAjTv0pnoJEFjKjk+2cC5IL+8TaDmnivv6hJs bsijz62wGrj1fvwZ/t2cB57VZFZRbZ/wZCaDzbXJIKREFSUDH304rhbmZCT8zm6u5dA9OY7b0cU G3AMjkUKu/A== X-Received: from dybb18.prod.google.com ([2002:a05:693c:6092:b0:311:cbf9:7438]) (user=pratmal job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:7007:b0:3c6:3c5b:f2e4 with SMTP id adf61e73a8af0-3c92a8f460fmr957909637.60.1785526627519; Fri, 31 Jul 2026 12:37:07 -0700 (PDT) Date: Fri, 31 Jul 2026 19:37:05 +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.508.g3f0d502094-goog Message-ID: <20260731193705.2902728-1-pratmal@google.com> Subject: [PATCH v4] 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, ljs@kernel.org 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, 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 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. Signed-off-by: Pratyush Mallick --- 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/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 | 26 +++++++++++++------ 2 files changed, 24 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..c01aa3af80f3 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 { @@ -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); -- 2.55.0.508.g3f0d502094-goog