From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796068534; b=uUKQJakJ/kx7wDeSY7v+hGveIrim0FKMGgfScgQ2abEDQpOakK96NSsf/2JjfJgn75d9 I09QgUljSpwOzXISsX9FzfFB/XBL3NkfJS5EzCg9/RNH3GLZ99cuZ5ZmD+FM8aKC75TDR K8bWMBaO/3Kg+m9G44saRmKLMvCgvQ2Mulqsq9NZyOXDAu+akHw5fAhgJbFdj7SrHjGrQ raZwypGNps0F9sjf427WfbVkhI51P2v/l97AsftumtGEgjedgu2vCnJ56dFYE+p6nBTQP QOUQDD5V/ghAnsJCepUbuAcvdakZmfv586mXeqqf0PrAPr9tc5gAcASvsiWqsdutHlA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796068534; h=Received:DKIM-Signature:Received:Received:X-ME-Sender: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:X-ThreadId:Date:From:To:Cc:Message-Id:In-Reply-To: References:Subject:Content-Type:Content-Transfer-Encoding; bh=Qu/wVtWpC1CEdcVxKVjjndxyL4cw1R1nnw4XOvvo4FI=; b=l8bKbNxoC284VJttWbHho8+czIcx3419njrLyB1U6fdDM4nd8v+g69Orc1dSaIIR6Nv9 ZWoV2Wwx3LCN2WHHs70BYpsNozmxsrtZ0WQq4bnSUr0fzRA13/EcmEjTLu9/WDvGOQYFc oaueh2PNMiElW5w6Xh/08sHyy5ttQ6b92w8oQFIZYBUKWcg2vrWbGDAAJlsfpTLMcPJq6 xZHfNNVvU50L1eHutQhQMw4Rr8LeFDxQcS7YIuaI3b2FyDBhHUh76Q4lOXjzuO/ObRW1h Ftml/uu6GrH50fZp8MyyhV17WzLS3CR+HibfpujHjkeDUK9zk1nmdI2lLbdO66IETSg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NRTo8wzQ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AF11606A325 for ; Mon, 30 Nov 2026 19:55:34 +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=NRTo8wzQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E85C1F0089B; Mon, 30 Nov 2026 19:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796068533; bh=Qu/wVtWpC1CEdcVxKVjjndxyL4cw1R1nnw4XOvvo4FI=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=NRTo8wzQZUFu3GpBpuXmZS8D2tzJzah+XEYQJAFJzhxNg6NfplIANAcU1Phyme0kK MnTrdR1GQYx8tE0OvzRBR4JkVHqMsgbroLRlq3iIKt28i7MNT/L/o4RdafHR3VYllL tRpCSbzJbVyojVyjAfoTGH8Wui2dazQvvt36fY+y8z3PSpskLVHRYHTXQ83t6GaYx3 bMTvgEuF0PSUwGTgUFL/OSxo682zV1AYUgX/CnhzgvxLhD6qNV3NefojGuYoPz76sj ZQicNyq9Z0GEU9PjKqdXAiwB5n3Oc6lTHDpvZs7pQwwLSi2/HO9MQWFjw3M9w1bkhw 70He3S3vrZiGA== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 9776AF40068; Mon, 30 Nov 2026 14:55:31 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-01.internal (MEProxy); Mon, 30 Nov 2026 14:55:31 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTF+xr7Lnnzq97lxKUIW522mMatso0FPJw04e1BuJCHEkrRqtly2yoj5qrNJP8Hapj WFJatagP98XoLosG3vjnYdUlIPaa5wcrWxRQ2qZumdyG272AQGwNrdzSaYF5WVJloV+nva S8Edp6fFzVcTqEsHe6FyyKjr5uMh/hAt1DhFFcumndlfhtCs94oxkcSVZZDDiz5yxq9IzX QdWUjMzvTqTHo7bPNXFPj4pMD2ZXM35oLhh4Kx04BvQjSZADR+lKXf8+cEgw8WqdwnuS/3 j3dyWUQ7RYAoG3lS+YxeMorItzwdSmICDuLNuSZ6AsGNNRGpKMr1weBQi/dhMgTuWGDwO+ J84XBBwhoRgmpOU16srzCoYipSmxunjjuEd1l41cEZrtGp0pIdk72CrspYWofrduyUBY01 SkQCC4Jckcizj0eOS0tfXowHN1EdEfXMMX+n9Xf1565YazjUkRxAHwqVivHeQH6cajp/aF RttFQy4fjVzfMXVgCgzalsZfmBGcc0xPyDKxEgpq788vnpSiutcDxHt3b8E1vON8jhr6ll GGRWv3pNcADudW0oslncj6aPrlHXPYtGLvS/7imgmrlNo8c1aje9NIGVYUl0GVtuLsBJWv YjF6Sz2RIb4TbVjhbvZV7zd1ghxVNBm4W3y9lBAgnCe4H9xALGKynGebRdqw X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 6BDD3700065; Mon, 30 Nov 2026 14:55:31 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-ThreadId: Ag4FU-lxcIVg Date: Mon, 30 Nov 2026 11:55:11 -0800 From: "Andy Lutomirski" To: "Valentin Schneider" , "Linux Kernel Mailing List" , linux-mm@kvack.org, "the arch/x86 maintainers" Cc: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "H. Peter Anvin" , "Peter Zijlstra (Intel)" , "Arnaldo Carvalho de Melo" , "Josh Poimboeuf" , "Paolo Bonzini" , "Arnd Bergmann" , "Frederic Weisbecker" , "Paul E. McKenney" , "Jason Baron" , "Steven Rostedt" , "Ard Biesheuvel" , "Sami Tolvanen" , "David S. Miller" , "Neeraj Upadhyay" , "Joel Fernandes" , "Josh Triplett" , "Boqun Feng" , "Uladzislau Rezki" , "Mathieu Desnoyers" , "Mel Gorman" , "Andrew Morton" , "Masahiro Yamada" , "Han Shen" , "Rik van Riel" , "Jann Horn" , "Dan Carpenter" , "Oleg Nesterov" , "Juri Lelli" , "Clark Williams" , "Tomas Glozar" , "Yair Podemsky" , "Marcelo Tosatti" , "Daniel Wagner" , "Petr Tesarik" , "Shrikanth Hegde" , "Dan Beimborn" , "Pak Hung Vincent Chiu" Message-Id: <0ec10a62-c496-431c-a6e4-158b2c9a9a6b@app.fastmail.com> In-Reply-To: <20261127201221.434876-1-vschneid@redhat.com> References: <20261127201221.434876-1-vschneid@redhat.com> Subject: Re: [PATCH v10 00/10] x86: Quiesce text_poke() IPIs Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, Nov 27, 2026, at 12:12 PM, Valentin Schneider wrote: > Christmas comes early this year, here's v10! > > Approach > ======== > > The heart of this series is the thought that while we cannot remove NOHZ_FULL > CPUs from the list of CPUs targeted by these IPIs, they may not have to execute > the callbacks immediately. Anything that only affects kernelspace can wait > until the next user->kernel transition, providing it can be executed "early > enough" in the entry code as a postponed operation. So I had a thought a while ago that I called "exact CT" (exact connection tracing). Basically the idea was to promote CT from a sort-of-specialized realtime/nohz feature to a core part of the entry and exit path. I probably sent some emails about it. The complexity (aside from rearranging a bunch of code) sort of boils down to needing a kind of unfortunate full barrier, and it goes like this: transition to user mode / quiescent: we set a percpu [0] quiescent flag saying "I promise that I'm on my way to userspace [1], and I will not access problematic mappings or rely on RCU (or, with your idea) run deferred-pokable code until I transition back". We need accesses that logically predate this to be logically synchronized with anything remote that reads this flag, so we make it a release. No big deal, I think. transition back from user mode / quiescent: This one is far trickier. We're going to clear the flag. But a remote CPU needs to be able to observe that the flag is clear and therefore not IPI us, which (on every architecture I'm familiar) requires smp_mb() or the equivalent. So I think we clear the quiescent flag and then read the "did anything happen that we need to handle bit". This could literally be a write, smp_mb(), read, or it could be a CAS (and I haven't really contemplated whether it needs to be a sequentially consistent CAS on architectures (not x86) where this is a real distinction). And here's why I'm bringing this up. The unquiesce sequence is kind of expensive (tens of cycles! we used to care about this on syscall return!), but maybe it solves your problem too. After all, a deferred TLB flush looks a lot like a deferred serializing operation, and those two look at least a little bit like a remote CPU relying on us being RCU-quiescent. (Okay, RCU really is different, since we probably want to increment a *count* of quiescence too, but I think this can be made to fit in.) And one thing I hate about the current context tracking is that it's sort of glued on and RCU-specific instead of being a real part of the entry/exit sequence. But maybe it's actually time to change this. I call my idea "exact" context tracking specifically because I think this stuff should change: void noinstr __ct_user_enter(enum ctx_state state) { struct context_tracking *ct = this_cpu_ptr(&context_tracking); lockdep_assert_irqs_disabled(); /* Kernel threads aren't supposed to go to userspace */ WARN_ON_ONCE(!current->mm); ^^^^^ excuse me, what is this doing here? if (!context_tracking_recursion_enter()) return; ^^^^^^ the x86 and generic code do not have recursion confusion any more if (__ct_state() != state) { ^^^^^ the state transition really should be a foregone conclusion if (ct->active) { In the bad old days of the entry/exit code, we had lots of code paths that didn't really know the state that they were transitioning *from*. These days we keep extremely careful track of exactly what's going on, but CT never got updated. I would be absolutely delighted to help review this if you write it :) [0] We have a weird tradition of actually using per-task flags on the current task for this kind of thing. This particular use case might require either annoying remote acquisitions of the rq lock or actually using a percpu flag. [1] There's nothing wrong with aborting the transition as long as we still do the reverse transition.