From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E474F606A31A for ; Tue, 1 Dec 2026 01:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OLp+qiSt Received: by kanga.kvack.org (Postfix) id 166596B00EF; Mon, 30 Nov 2026 20:40:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 13E9E6B05B1; Mon, 30 Nov 2026 20:40:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 054626B05B2; Mon, 30 Nov 2026 20:40:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A06EB6B00EF for ; Mon, 30 Nov 2026 20:40:13 -0500 (EST) Received: from smtpin13.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 408711C4747 for ; Tue, 1 Dec 2026 01:40:13 +0000 (UTC) X-FDA: 85493708706.13.A4D59C9 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf14.hostedemail.com (Postfix) with ESMTP id 92711100013 for ; Tue, 1 Dec 2026 01:40:11 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=OLp+qiSt; spf=pass (imf14.hostedemail.com: domain of harry@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=harry@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796089211; b=pNjhZ2uP2NBCamT1a7kJHS1qjaTp6xR6m5ENv0PbVscAwu4F/bWB38PSyTmV/FJoFDouY3 ZzM/EHUmfxAPVzA7fYkoh2lC2vYSt3SHNawlqeEzhFnFbGh0Tly8U0wgR6fcXdlxC+lJRw 3peP38rYipcWTgRKkmNywQMz7BA250I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796089211; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pB7w7KZv8X1FLZ8msd6JVDWo7arPTN6AGNTNvmkpopU=; b=JC/sKSAf3v+f9v9id30vKjG+OYwzfK0qxyBSZh3nbEbkcnYRQ/yFBdw1GcMr10CaSM5oYy qCGSvnJ2OatMCm1+wkSd222pf7PleeWqNodg5SoI7SBgyLE1GUcfOvxzRR8zHVECa+PnBP 3Kx/UXjjZKZRJDnUwokDecpdrjDL/hs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=OLp+qiSt; spf=pass (imf14.hostedemail.com: domain of harry@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=harry@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 0C076600B9; Tue, 1 Dec 2026 01:40:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 526A51F000C1; Tue, 1 Dec 2026 01:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796089210; bh=pB7w7KZv8X1FLZ8msd6JVDWo7arPTN6AGNTNvmkpopU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=OLp+qiSt/K/sox4z7lrMqJZJHXdISOK0KnbWufep5PLT9eit9feJPBpiMAOlaHFZG dauE+QTZSWpDnkRxlo2Gfgq+bnthnyyGI99MRKsuA4bwzwPQd9Pv4y8AoudlGk+vsS 9HgDtGjan3w29wG4yTP2xFXlo8Y7navco0TLn34S3bVqF8geuWMuZwp4gXDxzGoj/e qBI1YuVhFpfO8W427YZBKb4o76TzD5TPRP38tjshu+BXvguiL+wwG/5hAkT3O/W7Lg GRY8Qyi8h5utW3rkJg0+UFPH206gXYG1na7kb3d172RS9ZN7h/FP44JZkOSYuzpko3 3vOzghpR6Ze7Q== Date: Tue, 1 Dec 2026 01:40:08 +0000 From: Harry Yoo To: Joshua Hahn Cc: Andrew Morton , Vlastimil Babka , Johannes Weiner , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , linux-mm@kvack.org, kernel-team@meta.com Subject: Re: [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs Message-ID: References: <20261125212730.1128631-1-joshua.hahnjy@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261125212730.1128631-1-joshua.hahnjy@gmail.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 92711100013 X-Stat-Signature: x394rmyu87691hs1i1gbq5qd7tm4q5d3 X-Rspam-User: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796089211-356339 X-HE-Meta: U2FsdGVkX1+vHdUyG7n9uRh7j3rVjSJjeJkNMQkyHjV5KsNFgG7payXD7tfEANYb032I3VXIP9fSUMMrd7OgGe3p0NZNtesWXd+vVOh1pJd+KBckrEt1I73TYHtmBacoaruYVRGHL22pqfbg/QHZBBepb1Ki895ynJrvhjOeHlw7xiwG5e7mw06jhc72+CnLyGbPJC2iGuxLUmw+gQfsrTaHyjVQQDBCKbL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ljOIElPChqYeiwUqJWLsB5eMYF1u02388ZaPibqoF/8KclN+THJXBqJ13+JtGfgvalv3acYOfGIQUG7VbUP8y1g+iWmhW3S9+0qK7yz5KvK0EDxPR+rlhapKzG29wXWK8U2ASbxaO+HgKBne5i9ieURpjfgcoAZUdyJ2DL4DtIsZVtr2mqcrxaQ8o8M40zx9Po7I21UJELs36E86OXcd0H+4L7Ob7/IV1ZbNXH6IHAV1xevu/M1kPAoRxRwIgL4uTVSSB2zi9IQUbo8i7PCINEnDpwbz25VWvZkUHvrwuIOJQrgUrsU/mx/yYy6wr3kO9nf3zRXVS+LV62x8MDzvjed0j1ONGxMFguWhR5sGTcaKMM9WCjvug== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Joshua! On Wed, Nov 25, 2026 at 01:27:24PM -0800, Joshua Hahn wrote: > When the zone lock needs to be acquired from within the pcp lock > (due to refills or drains), IRQs are disabled to prevent deadlocks > with the IRQ handler. Today it looks like this: > > pcp lock > IRQ disabled > zone lock > zone unlock > IRQ enabled > pcp unlock > > So any interrupt that queues during the IRQ disabled section fires > before the pcp unlock. This is not a rare operation; the zone lock > remains one of the most contended locks on large systems. > > Together, those two observations mean that any IRQ handler that requires > taking the pcp lock will fire before the interrupted task can let go of > the pcp lock, and the handler will always fall back to the already > contended zone lock. Interestingly, this was anticipated when it was converted to a spin_trylock without disabling IRQs. [1] https://lore.kernel.org/all/20221118101714.19590-1-mgorman@techsingularity.net "Demote the lock to pcp_spin_lock avoids an IRQ disable/enable in the common case at the cost of some IRQ allocations taking a slower path. If the PCP lists need to be refilled, the zone lock still needs to disable IRQs but that will only happen on PCP refill and drain. If an IRQ is raised when a PCP allocation is in progress, the trylock will fail and fallback to using the buddy lists directly. Note that this may not be a universal win if an interrupt-intensive workload also allocates heavily from interrupt context and contends heavily on the zone->lock as a result." Apparenlty back then it was considered to be a corner case... > In Meta production workloads, we've seen softlockups on large machines > where one CPU spent 23s in an RCU softirq freeing page tables, and > taking zone->lock once per page because it had interrupted a task > already holding the pcp lock. But now it has become easer to hit by freeing page tables by RCU ([2] has a good summary of this) [2] https://lore.kernel.org/linux-mm/20260925-rcu-pagetable-freeing-v5-0-31e91065fea4@kernel.org > Instead, keep the IRQ disabled until the pcp unlock, so that interrupt > handlers can have a better chance at taking the pcp lock and relieving > contention on the zone lock: > > pcp lock > IRQ disabled > zone lock > zone unlock > pcp unlock > IRQ enabled The PCP lock is already complicated and now we're trying to add more complexity only to avoid disabling and enabling IRQ around the PCP lock in the common path. We should probably revisit the tradeoff made in [1] instead of adding more complexity, what do you think? > This series was tested on a 128-vCPU KVM guest, where every vCPU faults > in and MADV_DONTNEEDs in a loop. The "pcp fallbacks" (taking the zone > lock instead of the pcp lock) and long softirqs were summed across 6 > runs of 30 seconds each. > > +----------+---------------+-------------------+-----------------+ > | | pcp fallbacks | callback avg (ms) | softirqs > 65ms | > +----------+---------------+-------------------+-----------------+ > | mm-new | 135590 | 14 | 832 | > | +patch 1 | 10481 | 1.5 | 116 | > | +patch 2 | 2327 | 0.6 | 55 | > | +patch 3 | 190 | 0.6 | 10 | > +----------+---------------+-------------------+-----------------+ > > Running the same tests with PROVE_LOCKING, DEBUG_VM, and DEBUG_PREEMPT > also raised no concerns. > > Joshua Hahn (3): > mm/page_alloc: drop the pcp lock before enabling IRQs after a drain > mm/page_alloc: drop the pcp lock before enabling IRQs after a refill > mm/page_alloc: disable IRQs around the remaining pcp drains > > mm/page_alloc.c | 59 +++++++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 50 insertions(+), 9 deletions(-) > > > base-commit: 9f004372ebeb18fdeb699f9880a0e472df90135b > -- > 2.53.1-Meta -- Cheers, Harry / Hyeonggon