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=1796160716; b=X6CuYFCcAI3VsSidmx0CzHtzkcQT79McSlmC0aPo0/kgBFhQC1j4HwcU/ZGBdKRSQcV+ V0bFdeWWUDniE+1UV2rv43slDkA9tSCH+dp1MYdzWW5Z8Xd2O6qBygwJgB9iHX68XyFvy V6/QgTHrBdf1eHrgdqNqesuUyBRqNLwljLI5Y5Glv4j+uK14PGd1iIarCd3L4LH4aRoPf yEprfBKj8sizJKKmH7vAuYXoF5DdoI7hVwRooedvRjcPP5UrdYXy4hSs4BrEv8y3rr4gL DksFy++Z6jJXYiHRyDmw5rZ9qyEAdSZWwofnSPd4LqylDZsaE461KgcFfrDC5NJnieQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796160716; 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=YZUO6ZSLgIWkzmra1+p/1JSin2s1R/T7rajcElKwH0o=; b=JEtCkBR7BjQ0oN3Qj/c3rdYOXGeNA8z0bUw5OXmlDNMaoETJjm7DoE+qt8GvovSj6p2z SGhoDLqmNHnt5EZz5zD2qaaNCKkX+zj2+iRJVl0A56+y2/joe+eRtN40KJrj+jN77uxAG TNIqA8a+XF01qxBYVoBGV+6Ml3X645RnKmIX3eQlLyWMvk2zWCQQ2ic5xiMblPxXPHaio DgF20XeZIa/Xy6+COANunPfebmDOe8KSUt49vukaiJDvtaKKreYegB6uwk68Vm/fYU+Y7 +DGPtn/2ruIxse26vHTTWzYybxJV2ZFwRZ9cXe1Fg//b+6zmk2ejb+nctF465GuhAhA== 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=E7ClKf7A; 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 54DA7606A31A for ; Tue, 1 Dec 2026 21:31:55 +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=E7ClKf7A Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1ED41F0089C; Tue, 1 Dec 2026 21:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796160715; bh=YZUO6ZSLgIWkzmra1+p/1JSin2s1R/T7rajcElKwH0o=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=E7ClKf7AD1oyyzBmOpqkLeHkTtouFEeW7b7cdIy7x5h/tbWYy97Tf0J0D2OvzZXIN Y/6H+xi2IVX+S3J6Bn9pK8XGW8ZDYyynqEFF7RIYQEZQkbZDGmaIYxsLPJzGQwYQQx 7jiOAeKOA+Y3mNp3I7sS8ekjJJLeSDCPAe7IJSMWxaculeaK8ILcpbYGSrT9YCeu/N vaxzK6dii2CBcdFnhAfVlasXD+FOjwAL+yRjTWV8rTQt933otKTu9L1luJs1eMKk+u yPulXKlWXC8lS11M/o8FZD7Z8dEqgmmpyQlmdgOLyqGDdEgD8p0yTszRpARG+kgeJ0 bj1qmX86XlJjQ== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 33833F40068; Tue, 1 Dec 2026 16:31:53 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-01.internal (MEProxy); Tue, 01 Dec 2026 16:31:53 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTFb156dtMThE6QlCw5Glt6f5Iq3yiNTyFLhL2oKyQxrb14uGfDULrVXldlylSiVCN T4iqiUUNecnTTXC8dRGTWytrYFOYfCPyuQNr28frv6opC6Qr934KAaoZlZT8N5yaN2dYGM LcBbue5nqMdk961u1nHfA2G/cx4v/GnYSJyKnCrdJnJ4+hNQvCCbBeM3Gkyd0p2F5Pk1EI tknpItuTtXguHqHt2pEd+4R7ddm9fwluLfmM+hhySocZT+ygU7jYGIK7NZZ2m3rB2eNmZM Bteicf3juZT9xaBZyWNhcNITU15b4TTUIoz/Xw2m81iHp4Ri8uG7SvDVvTFUM2DUiiThtP e0t+eUjF3NI8aggjTxKyjUvr/jZXSQ3I/2vGiLzUSo3Zg9kCJLnDJQwkMLBhwvbAnFzcF/ QIktVo5OlZS11RaIKZBS6W5wxdfPZCZlOr03iwxbRcUobgvYKEqjyF2sj0yS2UOaCUExwt 7I1FscA6q87f/8+DY1uX76iZiPoLEMpXRAyxAvVwcbQZk+Jo+es2y2vAlewuEpakUrhDrt heWUTldc/CgSlv6dkoURWZARY9LU7ruH3d0tBhOIlLwuFufbvkUP+1Dk8sa/eko6PZFWFh 0lGxPK5+3b1ry9MS/3ju7yAYBXyU6uG3wqUALYER9d9+uzATxTQPJRGkAkjg X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id F0DD8700065; Tue, 1 Dec 2026 16:31:52 -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: Tue, 01 Dec 2026 13:31:32 -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: <35f7bf0d-651a-4d90-b0af-b4daa53f1f8a@app.fastmail.com> In-Reply-To: References: <20261127201221.434876-1-vschneid@redhat.com> <0ec10a62-c496-431c-a6e4-158b2c9a9a6b@app.fastmail.com> Subject: Re: [PATCH v10 00/10] x86: Quiesce text_poke() IPIs Content-Type: text/plain Content-Transfer-Encoding: 7bit On Tue, Dec 1, 2026, at 3:13 AM, Valentin Schneider wrote: > On 30/11/26 11:55, Andy Lutomirski wrote: >> 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 :) >> > > At a high level that sort of sounds like what Frederic had suggested and I > had implemented here: > > https://lore.kernel.org/lkml/20251114151428.1064524-4-vschneid@redhat.com/ I actually like that better. This is in line with what I was trying to suggest with my email. But I think the right way to do it would be to actually enumerate the allowed state transitions *from the perspective of the entry code* and then to reimplement it without all the weird ifs and incs and generally bizarre tolerance of being called for nonsensical state transitions. Make it simple and clean. > > Although now I would just not store anything and have a single, > always-run-at-entry catchup sequence (like the CR3 RMW). CR3 is slow. Even SERIALIZE is probably pretty slow. --Andy