From: Lance Yang <lance.yang@linux.dev>
To: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org, david@kernel.org,
dave.hansen@intel.com, will@kernel.org, aneesh.kumar@kernel.org,
npiggin@gmail.com, linux-arch@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] mm/mmu_gather: replace IPI with synchronize_rcu() when batch allocation fails
Date: Tue, 24 Feb 2026 20:57:28 +0800 [thread overview]
Message-ID: <d48e0326-a746-40ca-95d4-aff2c457877b@linux.dev> (raw)
In-Reply-To: <20260224123538.GW1282955@noisy.programming.kicks-ass.net>
On 2026/2/24 20:35, Peter Zijlstra wrote:
> On Tue, Feb 24, 2026 at 08:18:46PM +0800, Lance Yang wrote:
>>
>>
>> On 2026/2/24 19:41, Peter Zijlstra wrote:
>>> On Tue, Feb 24, 2026 at 11:07:00AM +0800, Lance Yang wrote:
>>>> From: Lance Yang <lance.yang@linux.dev>
>>>>
>>>> When freeing page tables, we try to batch them. If batch allocation fails
>>>> (GFP_NOWAIT), __tlb_remove_table_one() immediately frees the one without
>>>> batching.
>>>>
>>>> On !CONFIG_PT_RECLAIM, the fallback sends an IPI to all CPUs via
>>>> tlb_remove_table_sync_one(). It disrupts all CPUs even when only a single
>>>> process is unmapping memory. IPI broadcast was reported to hurt RT
>>>> workloads[1].
>>>>
>>>> tlb_remove_table_sync_one() synchronizes with lockless page-table walkers
>>>> (e.g. GUP-fast) that rely on IRQ disabling. These walkers use
>>>> local_irq_disable(), which is also an RCU read-side critical section.
>>>>
>>>> This patch introduces tlb_remove_table_sync_rcu() which uses RCU grace
>>>> period (synchronize_rcu()) instead of IPI broadcast. This provides the
>>>> same guarantee as IPI but without disrupting all CPUs. Since batch
>>>> allocation already failed, we are in a way slow path where sleeping is
>>>> acceptable - we are in process context (unmap_region, exit_mmap) with only
>>>> mmap_lock held. might_sleep() will catch any invalid context.
>>>
>>> So sending the IPIs also requires non-atomic context, so change there.
>>
>> Yeah, you're right!
>>
>>> What isn't explained, and very much not clear to me, is why
>>> tlb_remove_table_sync_one() is retained?
>>
>> Good point. tlb_remove_table_sync_one() is still needed in:
>>
>> 1) khugepaged (mm/khugepaged.c) - after pmdp_collapse_flush()
>> 2) tlb_finish_mmu() (tlb.h) - when tlb->fully_unshared_tables
>> 3) ...
>>
>> These are not slow paths like batch allocation failure. This patch only
>> converts this obvious slow path first.
>>
>> I'm working on converting the remaining callers as well, but not with
>> RCU, looking at other options (e.g. targeted IPI).
>
> OK, so with that addition to the Changelog,
>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Thanks for taking time to review!
next prev parent reply other threads:[~2026-02-24 12:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 3:07 Lance Yang
2026-02-24 11:04 ` David Hildenbrand (Arm)
2026-02-24 11:32 ` Lance Yang
2026-02-24 11:41 ` Peter Zijlstra
2026-02-24 11:55 ` Peter Zijlstra
2026-02-24 12:18 ` Lance Yang
2026-02-24 12:35 ` Peter Zijlstra
2026-02-24 12:57 ` Lance Yang [this message]
2026-02-24 15:04 ` Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d48e0326-a746-40ca-95d4-aff2c457877b@linux.dev \
--to=lance.yang@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@kernel.org \
--cc=dave.hansen@intel.com \
--cc=david@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox