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 B38921E47CA for ; Tue, 14 Oct 2025 22:12:54 +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=1760479974; cv=none; b=KyWFKrz26eQZyCBZK2dPmRs+bWoKobzn+D0UXdPciXriR8trh2VEbnGnKx+JzO1spVZl4huNZbu7OTDzPeivlBFam669z+75kQ5aPtqHCQpRJeD+juJUieruEfRfs+m4PP2rCKXNleaeZ57fSSaVQeyRKCG0G1vkpPO5SzjXxMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760479974; c=relaxed/simple; bh=JBnO/e7GVN0HReprvQ+rMjKJzUXFYB7lbbnjxLWU5v8=; h=Date:To:From:Subject:Message-Id; b=aCyMvloBiR5d491T/Y98zmSbijagbG9fNL2nCp8ijuxmZuxabcH84TL+ne/AkIhwAV5qHFuGfM0fwtT8GEioDj7n5FkSipCukfAsfzOAANGslaJfg4m0RcVpPacBrqFWDTATnraFYL2MZf/JSPXSISX3x9eijM2UciUrw7hrrwo= 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=001c1amb; 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="001c1amb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 370B7C4CEE7; Tue, 14 Oct 2025 22:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1760479974; bh=JBnO/e7GVN0HReprvQ+rMjKJzUXFYB7lbbnjxLWU5v8=; h=Date:To:From:Subject:From; b=001c1ambsturTDOSbkBOmo4Bu6E4oMpznIVf1v6eTh6MFn6Dh2ArJQ9zL/9R6q6ed K0PIYIjaPOSQKn6ONxAQXkG5uFsmTB94WKAN1dfiHeqApwSbBRDUEwECcCABmOeceM gS3el1tJCvWCrYsZFFwgAfvy6rpYla5/NBq3yjrc= Date: Tue, 14 Oct 2025 15:12:53 -0700 To: mm-commits@vger.kernel.org,ziy@nvidia.com,vbabka@suse.cz,surenb@google.com,sj@kernel.org,mhocko@suse.com,kirill@shutemov.name,jackmanb@google.com,hannes@cmpxchg.org,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: <20251014221254.370B7C4CEE7@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: Tue, 14 Oct 2025 07:50:09 -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 or zone 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/20251014145011.3427205-3-joshua.hahnjy@gmail.com Signed-off-by: Joshua Hahn Suggested-by: Chris Mason Suggested-by: Andrew Morton Co-developed-by: Johannes Weiner Reviewed-by: Vlastimil Babka Cc: Brendan Jackman Cc: "Kirill A. Shutemov" Cc: Michal Hocko Cc: SeongJae Park Cc: Suren Baghdasaryan 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-clarify-batch-tuning-in-zone_batchsize.patch mm-page_alloc-prevent-reporting-pcp-batch-=-0.patch 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 mm-page_alloc-batch-page-freeing-in-free_frozen_page_commit-fix.patch