From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=216.40.44.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796070905; b=tXcIAAGc3DgUF5C24sjoHKJEAZX+XNYZ5liiXL/uddBwXRDjhY1vPn0F3u4kVkGgpKkB jApMiben+6Zc/Bko6i/RmdK2zxTi15vwIwTyXRmSRErHed07Zcpp7OdS+Jc5M4lV9CGX0 rRKuQBeGV7XTG5S11XB3ZWWHkROzmuHFRaUy0FpkKQ31xn6Pg1zqFUpVbCH9Fy4Rg40Yn 061aVCCNTF2H479Z6reZbo5LmkELHV0GvMMbrFvTrXnjLg0eXIHDeictN/J0SP0IOl5L9 /VsbrmATQvIbdyUJkZmevJIGt9HNzFh/aCiDCSvBUFBsS4WMq+jvYFCi411kzDVZYCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796070905; h=DMARC-Filter:Received:Received:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Stat-Signature:X-Spam-Status: X-Rspamd-Server:X-Rspamd-Queue-Id:X-Session-Marker:X-Session-ID: DKIM-Signature:X-HE-Tag:X-HE-Meta; bh=j0bXZYLsJmLCKmLEoLChpO4hQnCkxEOpeUb86ZqK5lQ=; b=ZOyh6kJCl7zlalL/BkXHwIvS/FhRPtsbAC2X8pQ70vaAFcK+AuhCA8bScWhkDfnz3+IG fy39wARoEPvFtieL0eQcuLchAG8uw0EDCRcafJ92zMFGUSWhSJfBLYBUG/gWW4MKNzJIq ddGBVR/p99NgKjbFwRWvXyQUxfrhID/dzsdnUFGQvcm7qsx9rpxHNHoWe7igvW/yS+ekR CARCgwzRNpb9qwrtqqMtSFt+JkK3gzG1SaCvck0SjJWLnPkebsXjRnFcclX/ydYs+KUpJ 4cVdvcUMF8rVTctyLtxg4z83YPCHX/LCJsPfW2J49ziLGVRSmDE5OOcNXfjH521X7Ng== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; dkim=pass header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=g4NSegjj; arc=none smtp.remote-ip=216.40.44.11 Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) (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 5F7B5606A325 for ; Mon, 30 Nov 2026 20:35:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5F7B5606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=g4NSegjj Received: from omf17.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0CEB2160C27; Mon, 30 Nov 2026 20:34:59 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf17.hostedemail.com (Postfix) with ESMTPA id 9461819; Mon, 30 Nov 2026 20:34:47 +0000 (UTC) Date: Mon, 30 Nov 2026 15:34:46 -0500 From: Steven Rostedt To: "Andy Lutomirski" Cc: "Valentin Schneider" , "Linux Kernel Mailing List" , linux-mm@kvack.org, "the arch/x86 maintainers" , "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" , "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 Message-ID: <20261130153446.56d07d33@gandalf.local.home> 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> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: 8n1h6831ht999yj54jzkm3373x6azn4p X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: 9461819 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1+L4LcGHOTgyJP+wuzFwiWbz/Ia++H+W8I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=goodmis.org; h=date:from:to:cc:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=dkim1; bh=j0bXZYLsJmLCKmLEoLChpO4hQnCkxEOpeUb86ZqK5lQ=; b=g4NSegjjEB83/Ny6YaKlNCqoqa6C5iTHlnNaxqBUPwrnFC3wyDnUGY3IiZ4vF+d04Z7vPOsB09F5uwF3BWeooO4LAkI8D218zoS72GOqnIAQVX3oM5ukL7muhEsUrb8K1vQ5u/KbIRdRm6o693cD5qu/u1I6UYgiopdayMO+1Uw= X-HE-Tag: 1796070887-364361 X-HE-Meta: U2FsdGVkX1/6Igtevuj8pPuDciLV+QsvqFBu5/Oqcuhd7nacdT68It8NNARzF5ZkJHYGUt63VKwdseFf6vl+ZAh84NQGyEWjxPpNCaRxVYF50ORnVu7A4Tmh1nqaZL+g99H7EYSYO4Ob21jFA/yqQrRDA/fmYg9aN5+wSVsYtlXNqhRaJdaplr+8Z7TFAFJfU2Hdg9TV5Fkxh3Y8xfaJXRrDK+Fuzry3Hq41vAyMP4maglHIYpC99+FkKG9Epn+rrWGdmyR0u9GQZCa/wecekG7IBBhoEIgewnN+hQlQPqvN1nMUXZYSuW2J9sYOY6cRvmIvrQCDrlsCRFwihOBF+4Wf3GV59scf On Mon, 30 Nov 2026 11:55:11 -0800 "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. Note, at least in our use case (and perhaps others), we do not need an "exact" moment for not bothering NO_HZ full after it enters user space. Heck, RCU needs a few ticks before it will stop bothering a NO_HZ CPU. Could we take advantage of that? That is, we do not use smp_mb() until a NO_HZ full CPU is fully registered after some time running in user space (perhaps way for a RCU synchronization period?). Once a CPU has fully registered that a task is running in NO_HZ full, then we can start doing more invasive memory synchronizations from other CPUs when it needs to send an IPI to this one. As NO_HZ tasks tend to not want to ever go into the kernel, we do not care if it is expensive when that task returns back from user space. > > 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. +1 > > 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. Looks like this code could use some TLC! > > > 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. This should most definitely be per-cpu flags and not rely on tasks themselves. -- Steve > > [1] There's nothing wrong with aborting the transition as long as we > still do the reverse transition.