From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796123628; b=34UPHEYgZglweqriv5cXHCfsKMYLpvYyXJXEkQDvUc3iRvn3X9+vwQQd0lzQ70uYt1Z0 QsqWDNnAu3lEsTrimnQw+u1kwajvsqwRiF6hmZoQWgUQEMZdMWixSi9jokoA6FYmry4hG 0Tp/CGycNId3GnrS24obx3YpnV6edvFQGG1pXrN9A/hcfV4eF+u+N1pIZ2r0RbQ47jxiv 9vKseGUni7689dbTdOOFdY5ITiSFcNL8IcfzNP8zkSWo5AqDjKuwNsQjZ/6EtrXsD9y5Z 19yMTbK4FeZSiRn/97UG32GbM3AeYH4Jyef+JKY6c+OHuEtgYndhVUgFVmNqN6Col3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796123628; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type; bh=C9G9aMXW2QM9xpgXd8/2zuaBbhj0vSaOx0kPJUeFmUY=; b=lyF7El+XnCXEJALdXUrlOC/E77i9du0PJxrgRpPkrcrov6x5njGEqKW+P/vBH5QSPpsx x2VCJYCX44hRBps4Nq3xK32F3saNX9S2+PxevF60UFcwijVC5kRJH9Ym7XsubZXMMtsQH R5uVc3YeWqZjRQY8rWeY/AOs4R4aoOsMnwQEfFDntGDz7XFP23tA3Tb1Ek/9gFR7Lzl1h Aohq0I4TjxkZeeZlWGcnb0obZ7lft0lcqsDAoGNzJZUXvkDj9Ae/u6mIg+jBBOeWwEn9Z SpkTfxTAFLMs8l08XbNIIrWb5QGxZY8IoAn3KB9+JUwtPafWtxo4bub6JRjuITogSFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ebiLYnOc; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=eCSjhuHR; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05EEA606A6A4 for ; Tue, 1 Dec 2026 11:13:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 05EEA606A6A4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ebiLYnOc; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=eCSjhuHR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796123618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=C9G9aMXW2QM9xpgXd8/2zuaBbhj0vSaOx0kPJUeFmUY=; b=ebiLYnOcb1a1e4HYszbog1NcVDSq9aUgnDcwVqbeBMA9JmDKep/NG5lL5BB4SsettMHnYT uWGz/1xDWbTICE4U6ExWQj0x468by5msXNJIFlpjZUu7quVsV3PfcIR/dgYErmhHb8kmFM e7n5piG1T4HxyT4wsjJ3wqEln0yGpLc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-QgMKk2QEM9-L-wJPuZVGxw-1; Tue, 1 Dec 2026 11:13:37 +0000 X-MC-Unique: QgMKk2QEM9-L-wJPuZVGxw-1 X-Mimecast-MFC-AGG-ID: QgMKk2QEM9-L-wJPuZVGxw_1796123616 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4bb64c99bb8so101607115e9.1 for ; Tue, 01 Dec 2026 03:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796123616; x=1796728416; darn=vger.kernel.org; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C9G9aMXW2QM9xpgXd8/2zuaBbhj0vSaOx0kPJUeFmUY=; b=eCSjhuHRoSfD3lrC0RlXiLBfcCIO/jgj3FGL6PvBMD890L4iOdjG26eJ3ddJl0e0M5 0JOR3nhoyp+ILdlQHGkS8Bg7QOiGw2JyaoBY7+mhSr09IrlqkaNzWiV+NA0zkD35P1U+ NWXWHa1z3XloV9xLr4z7xFzzsHP2Wyta9EcmXLzIJiN7N9Jmgkgcr5pSzzSVnbFBWZNu wgePv50getB6BY7Mo9CHJQ72vbsT4nRaqfUNFAJqEC0Sznjv/mO6nGh9qU5Suvc7zpNF wAM4jQH9RF51CNvYYxJNDwMtiO8Sa1aUWqKHsRdhae/7M/FOUDNTovyQZXaxjokqYMJw Ko9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796123616; x=1796728416; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=C9G9aMXW2QM9xpgXd8/2zuaBbhj0vSaOx0kPJUeFmUY=; b=YPV+gb+r+t6A2miNyc1SSgIzwwGEocPLmYlKW3mo8pSRZjmOMeQwVbmZKNHq/kQM3t dVXC8ltyt9tie4vd9HAqRJaajYUA/yQMaXiSZa9a1mTCCUFOBqS3WVgAtVlkaZtkeFeJ d+JlSfrKbJ/0fyqbyMnZLnuXg9hdC4Sgnf39fqP35/k7AgbaxIm93p11PWAcK6q4FM7g jxpK6gSma7sfdADpqWV2DkizFp73qwfJhXzAx3pjx1jQ6sYoxmcsGOnSM4J25h7IDe4/ pQ384EDFpY8eBWEUcBIERKZdh0+G2wJSOk7Z+p/VyOruANxFOAaYtC9GUzuMXs9RTV8g gEIg== X-Forwarded-Encrypted: i=1; AL+hErE5LmsT2tO7tMqI4K7CV8iUxFVs0uPB/sFwO6TdbwlxyoLlTiPKCNiP/lrQuKMHcJ0wy/YHuRA5u6hUSxk=@vger.kernel.org X-Gm-Message-State: APuU4Z/grRKZxDA+Vuo2ItDuT3AjP9eNnPRgEkjmfM5R+hp/wtn4OOy2 mLZ9cFUqWsCDDk/NxQaWi6iCVJRo3DKJAlcEqXgfS6bdwgSp79ABu2ERNkVM2TZA+pc5Q5YO9eD ObdwVb8LA24OO0ERHJ8Kk5smPnEx/tEATH8X62sxN1JEfmE7O0UCk5HJHyudl95u4lA== X-Gm-Gg: AZFdTZdwNzOP4aK8wXEPU+G9W0YTY4eqXoaBKKN5uYVFyC9xQZPU1z9oP3IgdmRVmBd vjL2ZunlH/Cuo4LEtnkCvs8cBiiNikE1PmtA9tWUt/azQkaef/q8+Dk2hqsowbwESeg1uTw6AcX LLzbdmC0NP1lwIBsVWkAl64/IdF0Sjq6qrdd7+ndhNmMArghVp3yLbHbiPauqUAJecPJMqvLIdO CfgVzrc2HXYYc4jkW7Cs9lG4C7BWV32deAdhqg+xY5mpPLduPyivWMu0AJjSW3bb7L4mvFG6LDO iBStyFhHpu2Gp/Gjv3U1fkHbxxn3rF+fPGA+usb6HdOYn52zztKpsn/XYCIcBiV6NK0YR2UNEkh IpWroRZDh6bPfmtBsd0TMlblkWdXJOZ/Hm+/T3xie8ta7bjwpxl4F63nkxfgSBKwonFY+qo0XSB ScnKkUc3EWDCMOVq+mRLypzoHquHp+GRPrIQ== X-Received: by 2002:a05:600c:a4b:b0:4a1:dade:f049 with SMTP id 5b1f17b1804b1-4bb88806292mr759904135e9.15.1796123615826; Tue, 01 Dec 2026 03:13:35 -0800 (PST) X-Received: by 2002:a05:600c:a4b:b0:4a1:dade:f049 with SMTP id 5b1f17b1804b1-4bb88806292mr759903145e9.15.1796123615260; Tue, 01 Dec 2026 03:13:35 -0800 (PST) Received: from vschneid-thinkpadt14sgen2i.remote.csb (213-44-135-146.abo.bbox.fr. [213.44.135.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884a3a3dsm998922445e9.10.2026.12.01.03.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 03:13:34 -0800 (PST) From: Valentin Schneider To: Andy Lutomirski , 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 Subject: Re: [PATCH v10 00/10] x86: Quiesce text_poke() IPIs In-Reply-To: <0ec10a62-c496-431c-a6e4-158b2c9a9a6b@app.fastmail.com> References: <20261127201221.434876-1-vschneid@redhat.com> <0ec10a62-c496-431c-a6e4-158b2c9a9a6b@app.fastmail.com> Date: Tue, 01 Dec 2026 12:13:32 +0100 Message-ID: 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 Content-Type: text/plain 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/ Although now I would just not store anything and have a single, always-run-at-entry catchup sequence (like the CR3 RMW).