From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70E78470EAD; Tue, 28 Jul 2026 18:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785264958; cv=none; b=Ve8AEJzphoBCkxmtRldJ1X0EIpJZfkRLDh3EXz5IWcGy70IjdOUu7biVOYu7aLiM0Fw/8ls9TD2ckcATMjZZ/VNu+zAiUnwlUhM3vZHe+xZ9cUHbHlisb3It0/LPcx8Lx8y8Guz4rTISMLqRhuxCdI8WrR7qPzhR159xnsjS3a0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785264958; c=relaxed/simple; bh=AgsjISV7Zlwr2AIsccSiFmgmy0pKqU+9P7pZE26q6oc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aaGPwHZUYjNzkDMTj7+XXax3caLlUo8yTC5Yqx45eUkyZ4i/pdpdEWjY9Sg3s8h1ZxGM+qlxWJaKYoMz4Ul/6hOXAi5lKecfhlLJnBdyu7j3SlF+TUgkWyg2OWl9NjmYVHyFojZYvORT6S5r2rGBbzrLo2vfEFnMaW8R9qx0+yc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZJkspsqW; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZJkspsqW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 390521F000E9; Tue, 28 Jul 2026 18:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785264955; bh=xyDi5xQA1AMyz6Holti/bfjxIF++j2+pJzGhsHUHlqw=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=ZJkspsqWXjWjFcbFYiktTjt1XKmKGc8738BdLNGQ0FnV5wYHoEdUZuY5EJmD+ATGF R5AZmBSuh+BLQNox+qjFxERXMl/iNswBFSN1mJ8hA2GxfsnzZdIGTC+S4lE0ypvYMp E92zF7hQc3nOn7QX9SMS6fFLOyF5bxw2Q3ySZeErMn7jJo3mzXbB8yGysJQAiAjAIs 5yUuNU/zKJMz8755pkFjLE3dGh6Paw3Q0J4QX93kt+jantx2f8LQqtMPJfzJcUvF+I lthrriD7UbeIE3no9F1ZfV6tPuujFJoxald8/LXO9INq+L3V0baPqZQtrwB1XtwG7w k3Pdsz5VRQiOg== Message-ID: <91b61f02-c533-41b9-b680-7de52a5c6918@kernel.org> Date: Tue, 28 Jul 2026 20:55:47 +0200 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm/page_reporting: Add page_reporting_delay_ms module parameter To: "Lorenzo Stoakes (ARM)" , pratmal@google.com Cc: akpm@linux-foundation.org, vbabka@kernel.org, sj@kernel.org, corbet@lwn.net, 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 References: <20260727230545.262579-1-pratmal@google.com> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ d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sfKou3v+jP/l14a7DGBvrmlYjO 59o3t6inu6H7pt7OL6u6BQj7DoMAEQEAAcLBfAQYAQgAJgIbDBYhBBvZyq1zXEw6Rg38yk3e EPcA/4NaBQJonNqrBQkmWAihAAoJEE3eEPcA/4NaKtMQALAJ8PzprBEXbXcEXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/28/26 13:13, Lorenzo Stoakes (ARM) wrote: > On Mon, Jul 27, 2026 at 11:05:45PM +0000, pratmal@google.com wrote: >> 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. > > Since you're talking about increasing it, maybe set the floor at the current > value of 2s? > >> >> 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. > > I'm not sure this is great as it means we now have a parameter we have to > support forever and autotuning becomes harder to implement, also if later the > implementation is changed, this might prevent a reimplementation. While I'd prefer to keep the implementation as simple as possible unless really required, I guess auto-tune could be enabled by setting the parameter to e.g., -1 in the future. > > Have you considered actually adding logic to detect the problem you're having > and delay in that case? > > It seems like this is the "easy" solution but it has a price too. > >> >> 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)); > > Err, do we not want to limit this to something sensible? What if the user > specifies 0 does it just hammer the system at that stage? IIUC, 0 just means "as soon there is a suitable free page block to report, start reporting immediately". With 2s, we wait 2s before we start reporting immediately by kicking the workqueue immediately. So "0" does not mean "report all the time", rather "start reporting immediately as we are notified about a pageblock to report". -- Cheers, David