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 C3483606A322 for ; Wed, 2 Dec 2026 19:11:38 +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=YVtGVpYc Received: by kanga.kvack.org (Postfix) id EA40D6B05E7; Wed, 2 Dec 2026 14:11:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E7B6B6B05E8; Wed, 2 Dec 2026 14:11:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6A4A6B05F2; Wed, 2 Dec 2026 14:11:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B21836B05E7 for ; Wed, 2 Dec 2026 14:11:37 -0500 (EST) Received: from smtpin05.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4C83DA7D91 for ; Wed, 2 Dec 2026 19:11:37 +0000 (UTC) X-FDA: 85499987034.05.5E2DC67 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf01.hostedemail.com (Postfix) with ESMTP id 83BA540007 for ; Wed, 2 Dec 2026 19:11:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=YVtGVpYc; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of vbabka@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=vbabka@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796238695; b=FWNxgqBUswmAEliF2aPrMaa2FWNb2562odMo3YoERG+z7nnjpYwdl1pNLgVBBl5wM2Ky6R Qkv+ODeANMJ/qe/fjHKp9/HIzsTkEi3sLiFZs4p7xVjdeWo1TWYjcAdYMxVjRwsUdu7YF2 gALr2leYKb1KI70I75BcZR4LYh71+T8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796238695; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4kz7UPUPYtDxt9bFWqSs2f1gZpQMnVSeQqVcVfoRVRM=; b=HuREDXNBec+E4N7Gut26cAwh9aM9i1/f9xdef1NdnfhlvqjfMC9E0YkLSyVsbEOHpClxcf stc2Caq0gFSsI3qLcfAq6Ix5s79ZMLVg16cMTwqC1ZskS/TGGLIa5SemhQhG+fnvnJKmRO hRY16K5d155o0yRPCYXGB+310ySC5w8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=YVtGVpYc; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of vbabka@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=vbabka@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E84E76062E; Wed, 2 Dec 2026 19:11:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 843C61F000C1; Wed, 2 Dec 2026 19:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796238694; bh=4kz7UPUPYtDxt9bFWqSs2f1gZpQMnVSeQqVcVfoRVRM=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=YVtGVpYcvdwvX5M/5uTxSwqTa+Y5hpDwm5gbkZqM6pWg5g01Y0fct/hWwn8obtUW3 lrFSW0EY7x1IYeSNU7Xsl17aPt4KejiQZ4qXhAvZ8FBZdNtrvL3/BPqE71Uv8YaAPT eLUtjaMYdyqvWRTVhCo386me4MD9vBkF7xLyguKhy0CNNNIlAbZ2uvy4ihyinUfH1Z xXtYIGPuY1On/7OFgB7IIXkFxREoY0uW1pNx6hAH6kr4ejhMUtCLsgUGaRGD/hlKpw vg2LaQU6ghHK5+qlXhtUNrzYEkq2DH7UuRRySU6ldOJeJVq4nwlP934c32cmgozEw2 d8GA24T4onD0Q== Message-ID: Date: Wed, 2 Dec 2026 20:11:30 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs Content-Language: en-US To: Joshua Hahn , Harry Yoo Cc: Andrew Morton , Johannes Weiner , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , Mel Gorman , linux-mm@kvack.org, kernel-team@meta.com References: <20261125212730.1128631-1-joshua.hahnjy@gmail.com> <20261201161138.294531-2-joshua.hahnjy@gmail.com> <20261201213125.294531-5-joshua.hahnjy@gmail.com> <20261202182114.2250433-1-joshua.hahnjy@gmail.com> From: "Vlastimil Babka (SUSE)" Autocrypt: addr=vbabka@kernel.org; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOX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vPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: <20261202182114.2250433-1-joshua.hahnjy@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: x1c3obpknjy8kgbop61k5rpzb49ohhp8 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 83BA540007 X-Rspam-User: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-HE-Tag: 1796238695-954223 X-HE-Meta: U2FsdGVkX1/By03F3Ybd5NjCBPvtbdWZLnJSQprSLVtw0UxnV4IxhCSEm+wa5jRrUbdBJaCsCh3gDmM8C9VMlwsc3wHMbhB+3CGt2D+TMPhhh/oG6k3uKnVvaswpr4nbpRyr8AwsfYk0i2dVP5oaMY+KJKcxZZWm5XLMQZWc7hoHsW6wxmqwKalgDd0So4wSORos2CsRf/pk09bq3hPjrymL92q+H/FqInGIaLhvirCx8YhK2Li7AM62y3BrPtbXmSkND0JvA/QoN1Hw5qmKUMZqmJCedzd2Vry3Co85IXlvZvu6EyC01QRdzaZyLG8bYyTuinphIB4WMCRI7g904zQPB3MRBDK/tCQg+ayi/bGoj8EGnqCABWjZKIcX5HoIME8Cu8rTM9J0rrYsR3gytUfo4hCKJD+Zrgp0a6gg2n2MriyfW7iy5mp/B5D7egYFlD/PGqbB8YAIARnCspCKt+zNUBYABdoiVaoJWp44Hs7zmoKXO9IqpcF2n/Lur4eT74XcUAj7iKF9zIEm+d1SIgUhPB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ner-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 On 12/2/26 19:32, Joshua Hahn wrote: > On Wed, Dec 02, 2026 at 03:24:16AM +0000, Harry Yoo wrote: >> On Tue, Dec 01, 2026 at 11:53:48PM +0000, Harry Yoo wrote: >> > On Tue, Dec 01, 2026 at 02:05:57PM -0800, Joshua Hahn wrote: >> > > > > 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? >> > > > >> > > > Yeah, I think this is very reasonable :p It does seem like a lot to >> > > > remember about when the IRQ is enabled / disabled and who needs to >> > > > remember what... I also did not really like the fact that the locking >> > > > and IRQ toggling wouldn't be FILO if we switched the order of the >> > > > pcp unlock and IRQ enabling. >> > > > >> > > > Anyways, let me do some benchmarking to revisit the cost and the >> > > > tradeoffs. It would essentially be a revert of Mel's commit but I think >> > > > there's been a lot of changes on top of it over the years, it might >> > > > be a bit more plumbing than a simple revert. >> > > >> > > Hey Harry, so I did some quick prototyping with AI (diff at the end). >> > >> > We don't need pcpu_task_pin()/unpin() if we disable IRQs >> >> Sorry this is not exactly something we've had in the past, so I need to >> describe it further. >> >> > and so the >> > regression might be overestimated as we disable migration AND IRQs. >> >> It's not "overestimated" in terms of measuring performance of the >> revert... but it's still silly to disable both preemption and IRQs >> and we can probably do better here. >> >> pcp_spin_trylock() on !RT should disable IRQs first and then call >> spin_trylock(). >> >> on RT it should disable migration and then call spin_trylock(). >> >> This avoids allocating pages from a different CPU's PCP by mistake >> due to task migration. > > Hi Harry, > > That makes a lot of sense, I tried the change the way you described, so > on !RT pcp_spin_trylock() is just local_irq_save() and spin_trylock(), > and on RT it's migrate_disable() and then spin_trylock(). > > I ran the benchmarks again with the changes, this one is David's > benchmark (alloc_pages() + __free_pages() on one CPU). The value is > mean time it took in ns +- the standard deviation, across 50 runs: > > +---------+-------------+-------------+-------------+ > | | mm-new | revert | no-pin | > +---------+-------------+-------------+-------------+ > | order-0 | 80.0 +- 0.9 | 85.2 +- 0.3 | 85.5 +- 0.5 | > | order-1 | 79.7 +- 0.4 | 88.1 +- 0.4 | 87.0 +- 0.0 | > | order-3 | 85.9 +- 0.9 | 95.5 +- 1.1 | 94.6 +- 0.7 | > +---------+-------------+-------------+-------------+ > > Unfortunately it seems like the majority of the cost comes from the IRQ, > the pin is only about 1 ns compared to the revert only. Wonder if we can have our cake and eat it too? No irq disabling for the fast path, when we take or return a pcplist page and don't need to refill or flush. Relock with irq disabled for the refill/flush. Always a risk something changes while we relock, but we already handle that e.g. in the flushing with the periodic unlock you added a while ago. Woud it be feasible? > And this is the result for will-it-scale (process mode). Here the value > is millions of faults per sec, also for mean +- standard deviation. > So higher is better here. Across 5 runs I got: > > page_fault1: > +-------+----------------+------------------------+------------------------+ > | tasks | mm-new | revert | no-pin | > +-------+----------------+------------------------+------------------------+ > | 1 | 1.065 +- 0.021 | 1.060 +- 0.004 (-0.4%) | 1.077 +- 0.003 (+1.2%) | > | 16 | 7.073 +- 0.379 | 7.170 +- 0.088 (+1.4%) | 7.452 +- 0.131 (+5.4%) | > | 64 | 6.921 +- 0.262 | 6.897 +- 0.308 (-0.3%) | 7.091 +- 0.260 (+2.5%) | > | 128 | 6.208 +- 0.159 | 6.154 +- 0.372 (-0.9%) | 6.334 +- 0.439 (+2.0%) | > +-------+----------------+------------------------+------------------------+ > > page_fault2: > +-------+----------------+------------------------+------------------------+ > | tasks | mm-new | revert | no-pin | > +-------+----------------+------------------------+------------------------+ > | 1 | 0.743 +- 0.036 | 0.728 +- 0.028 (-1.9%) | 0.765 +- 0.037 (+2.9%) | > | 16 | 5.213 +- 0.044 | 5.267 +- 0.052 (+1.0%) | 5.249 +- 0.112 (+0.7%) | > | 64 | 6.675 +- 0.077 | 6.467 +- 0.045 (-3.1%) | 6.748 +- 0.122 (+1.1%) | > | 128 | 6.277 +- 0.193 | 6.330 +- 0.247 (+0.8%) | 6.306 +- 0.221 (+0.5%) | > +-------+----------------+------------------------+------------------------+ > > Compared to before, it seems like we get much better results this time, > and this is probably more reflective of what we end up seeing in real > workloads anyways. But note that the standard deviation looks pretty > high and all the gains are within the standard deviation, so I wouldn't > read too much into the + as a real win :p > > At least we know it isn't regressing too obviously. > > Everything considered I think this is: > - Around 5-9 ns per alloc/free pair in a microbenchmark > - No real difference to throughput in realistic workloads