From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 79B79287502 for ; Wed, 8 Oct 2025 00:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759884485; cv=none; b=SWA9aWPjYubmOL2GqswplqY5+zDtBA8gnrvq+02L+fKDE0kDKKmVLgtI1U0rGzqPF6lKmkwEmaHp0fLMxGentSI5iae1oo2eFP6mo6kTOQPDHwhlUTNF9xhi2TdOVmeNCUXvRRgZjP/tCygVgq/f/LKH0DUkyN9TXLla7TJnvhE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759884485; c=relaxed/simple; bh=Ny88E8bJUfBaC0bt+W28T9Ga99cg/xa9NN4MxVcDyPI=; h=Date:To:From:Subject:Message-Id; b=n2pwFSyvaPWW2J047Nv8hxdyogmJqirXoQFA6TJOw7CF76/yawhfxHYfSB2KcSafc3BRQko41sJP8WxO26XmEAxYoe7Yec3G4p8mFtw1x85MY51SVXtulMO4cdYJGBM4l13wJbCWpvlwsJCrztjB86msLz6L4SMpm5uQdP1QXHo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=wYH0iKBb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="wYH0iKBb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA7A3C4CEF1; Wed, 8 Oct 2025 00:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1759884482; bh=Ny88E8bJUfBaC0bt+W28T9Ga99cg/xa9NN4MxVcDyPI=; h=Date:To:From:Subject:From; b=wYH0iKBb47xBN9V+hLi/W8Z+oGDaFsr2qgDle4CnMtf4zSUJ99DlkRwXrCLf8egt6 iwxICE4DOmN5BrXwFpDR6ec5aPhmUOOVg1NYn7Z8dz5ldAI2ge0Uy32mgfDeplaDdB yhMuqh31z+Xv6COodMaQNc27db5OEZEtPFzSiX70= Date: Tue, 07 Oct 2025 17:48:01 -0700 To: mm-commits@vger.kernel.org,ziy@nvidia.com,vbabka@suse.cz,surenb@google.com,rppt@kernel.org,mhocko@suse.com,lorenzo.stoakes@oracle.com,liam.howlett@oracle.com,kirill@shutemov.name,jackmanb@google.com,hdanton@sina.com,hannes@cmpxchg.org,david@redhat.com,clm@fb.com,akpm@linux-foundation.org,joshua.hahnjy@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-page_alloc-batch-page-freeing-in-decay_pcp_high.patch added to mm-new branch Message-Id: <20251008004801.EA7A3C4CEF1@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/page_alloc: batch page freeing in decay_pcp_high has been added to the -mm mm-new branch. Its filename is mm-page_alloc-batch-page-freeing-in-decay_pcp_high.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_alloc-batch-page-freeing-in-decay_pcp_high.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Joshua Hahn Subject: mm/page_alloc: batch page freeing in decay_pcp_high Date: Thu, 2 Oct 2025 13:46:32 -0700 It is possible for pcp->count - pcp->high to exceed pcp->batch by a lot. When this happens, we should perform batching to ensure that free_pcppages_bulk isn't called with too many pages to free at once and starve out other threads that need the pcp lock. Since we are still only freeing the difference between the initial pcp->count and pcp->high values, there should be no change to how many pages are freed. Link: https://lkml.kernel.org/r/20251002204636.4016712-3-joshua.hahnjy@gmail.com Signed-off-by: Joshua Hahn Suggested-by: Chris Mason Suggested-by: Andrew Morton Co-developed-by: Johannes Weiner Cc: Brendan Jackman Cc: David Hildenbrand Cc: Hillf Danton Cc: "Kirill A. Shutemov" Cc: Liam Howlett Cc: Lorenzo Stoakes Cc: Michal Hocko Cc: Mike Rapoport Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Zi Yan Signed-off-by: Andrew Morton --- mm/page_alloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/mm/page_alloc.c~mm-page_alloc-batch-page-freeing-in-decay_pcp_high +++ a/mm/page_alloc.c @@ -2559,7 +2559,7 @@ static int rmqueue_bulk(struct zone *zon */ bool decay_pcp_high(struct zone *zone, struct per_cpu_pages *pcp) { - int high_min, to_drain, batch; + int high_min, to_drain, to_drain_batched, batch; bool todo = false; high_min = READ_ONCE(pcp->high_min); @@ -2577,11 +2577,14 @@ bool decay_pcp_high(struct zone *zone, s } to_drain = pcp->count - pcp->high; - if (to_drain > 0) { + while (to_drain > 0) { + to_drain_batched = min(to_drain, batch); spin_lock(&pcp->lock); - free_pcppages_bulk(zone, to_drain, pcp, 0); + free_pcppages_bulk(zone, to_drain_batched, pcp, 0); spin_unlock(&pcp->lock); todo = true; + + to_drain -= to_drain_batched; } return todo; _ Patches currently in -mm which might be from joshua.hahnjy@gmail.com are mm-page_alloc-vmstat-simplify-refresh_cpu_vm_stats-change-detection.patch mm-page_alloc-batch-page-freeing-in-decay_pcp_high.patch mm-page_alloc-batch-page-freeing-in-free_frozen_page_commit.patch