From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB51324A06D for ; Mon, 13 Jul 2026 21:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783977452; cv=none; b=eS90klgRet3x19BT39rdo9pPvCrEF1vC61gILI2aqlT24vjgf34ByZb24fNuic4fnCMX2juRHTRtFvvuUXyWYOYi54n1Tr9lXCtBTmM/jFpqjaixo1V5giYhEkGRhDBZKzo6/4Hn46a2/f2+WxIjZBcSMjOWFr7gwvp7+XFualY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783977452; c=relaxed/simple; bh=ESZSUj+QsiIF6nv0NbuhSDu+P6Pwr5U/SNiDVxlW6sk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=HptEz1Ybc4OBZ2UFOY9s5UoRcmAOK2EJy2soW2EsdVYCz9T81XICG/iWOgZjdKTk+zvMgnNkxta9KRIhAFfZTWzdy3PBBCJfO/EZL9Ud/vVRHgshrPQM02HYU0y+UZ1WEYAlm4cAph1Wj+uBT9/yoLXKCC4rSXbvUh3FKIor65Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oMHN5ODE; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oMHN5ODE" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-69a5ecbbfb2so450400a12.2 for ; Mon, 13 Jul 2026 14:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783977449; x=1784582249; darn=vger.kernel.org; h=content-transfer-encoding:content-disposition:content-type :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=npiX22YSguzWJpXGx2hHTXeW3ywrBRl4LUKqa1yh85s=; b=oMHN5ODEsWjYmZrdJCzfdOqFdP+qBC3cKNC+RxVz+zkhavTaEZJXW0euPRlaBJaoBS aWuSY56DIscLKrywDNhaQFNnZ5SCQpy57WMrTVQCDrLWbd8b8+Jkgcs4LvGQhosohbtx mi06pSDb7AGBtaNlIktcA/40JdTqWvXq8b8bBBuumxyhwCXCa/K/0cpk9EqP68ijmwau pRlKqm6akrEhYdeVLZGRQn2a2BpsE7LnnWN92+9fXfDys90mIZeIUctDCa2WVIsR1y8I u17sLoCC0fHxtTwQR9Xw7VMEjGPLxkh2B97lz+9zbR6cQknfbrBeEsANuhtJXcfBcr2I glzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783977449; x=1784582249; h=content-transfer-encoding:content-disposition:content-type :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=npiX22YSguzWJpXGx2hHTXeW3ywrBRl4LUKqa1yh85s=; b=Qow3LFCQy+lqTeFK49KbWMzKH6+rWcGBc38dIuHKsj/UpSV/6oaSrJAvHsvRl3UbHC YGewGT0Rr5H3KMYvQ/ELOKOH4MJwUJRZl+w0v4cL6op0t2LkGUBwhgKwnn2xz+ZSsM5j K9fljIIfCgRnyzztb4/XJzdfH+A25ghs2wCX8DaQZtNSbPHMw0muadLbNHE3d+mP3p4R N+vJVIeUad5PNxq0to9/pAHd8g+fLqNTX+8HTPg7C8ofuvl2I9N8s+Cz85A01qhjwSDH lvY2Epa21zdna3gvvvgo5QL6YLWXnuQJMGbREMVAig+5GxnGSehhVNu9sbTvr1yvb3rg yTIA== X-Forwarded-Encrypted: i=1; AHgh+RpZ8lXhSLSybYm9p5qbBydjKOyeUZO4HP5KDqmMDNd/j8Twzok+3+LPoSOUlHgO8/9TmW5WK13EmnKubAI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxy+shOLmu6DHfxpzXj3wVhn0X9YJ+nL5/UE1P2ppzcUNw1fawR 4DlyfJwhCtnVjcP6ja0aGIiHAhZ0PkG4RskNgweDNX9kLOSwvF0Df5wc X-Gm-Gg: AfdE7cmLlN+Lq68YXr9qGDnGDnnGo92AiS/3QnrXm4V5YduuSfdzx+GvibyMHbRTnDT IimNnZQj9fzPksxGA4+QkznpXkUemmdICxRWfVbxJ1t4r7mVJCSP8yEUhyHBQCRCOucNzE3utzZ y9CRN+PiLFS4NtCOZRGQl7+jngCdk2++gcomaa75bgsVe/9tG7+4bPRx4YAOwXBGKNJbv+uLxLN 6MNF+Px4ZuyPHBj+rq3u2AdWnCaSRXEewR1bW0QA7/NgFPC98h6fPhnOIPGF6MxTpN40ySa6HVL u/gPmkBv+wVfuALii3RySxRdUfAkmxq1sNGrxIDGp49rQcoWWA+Mc3NArOwPyIIgqEY8pc5SDtI OxztSWv995DMtxe5sTbBsL9wqza6PIaSafggIc4I7b8TXqUqsQjdIT7vXqUMx1jYq2jqWdjYcH3 aur0658MGE3bRLoXTMreP/vhbE6iPAvI7P X-Received: by 2002:a05:6402:3220:b0:698:ad7f:9383 with SMTP id 4fb4d7f45d1cf-69c5f0c3130mr4880740a12.14.1783977448821; Mon, 13 Jul 2026 14:17:28 -0700 (PDT) Received: from WindFlash.powerhub ([2a0a:ef40:f61:3b01:d08a:833b:756:8fce]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-69cd2952836sm386903a12.27.2026.07.13.14.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 14:17:27 -0700 (PDT) From: Leonardo Bras To: Sebastian Andrzej Siewior Cc: Leonardo Bras , Jonathan Corbet , Shuah Khan , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , Brendan Jackman , Johannes Weiner , Zi Yan , Harry Yoo , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , "Borislav Petkov (AMD)" , Randy Dunlap , Thomas Gleixner , Feng Tang , Dapeng Mi , Kees Cook , Marco Elver , Jakub Kicinski , Li RongQing , Eric Biggers , "Paul E. McKenney" , Nathan Chancellor , Miguel Ojeda , Nicolas Schier , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Douglas Anderson , Gary Guo , Christian Brauner , Pasha Tatashin , Masahiro Yamada , Coiby Xu , Frederic Weisbecker , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rt-devel@lists.linux.dev Subject: Re: [PATCH v4 0/4] Introduce Per-CPU Work helpers (was QPW) Date: Mon, 13 Jul 2026 18:17:23 -0300 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260713080723.XOTiibfG@linutronix.de> References: <20260519012754.240804-1-leobras.c@gmail.com> <20260520130903.Ebsd4aUa@linutronix.de> <20260713080723.XOTiibfG@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Jul 13, 2026 at 10:07:23AM +0200, Sebastian Andrzej Siewior wrote: > On 2026-07-12 17:32:49 [-0300], Leonardo Bras wrote: > > > > The idea: > > > > Currently with PREEMPT_RT=y, local_locks() become per-cpu spinlocks. > > > > Hi Sebastian, thank you for reviewing! > > (Sorry for the delay) > > > > > It does not become a _spin_lock because it does not spin. It sleeps. > > > > Right, it's a per-cpu mutex. > > My point is that it's a full lock, and we could use it instead of doing the > > whole scheduling thing, since we are already paying the 'atomic overhead' > > to get the lock here. > > The whole lock is a spinlock_t. There is also raw_spinlock_t and > bit_spin_lock(). All three are considered spinlocks. > > > > > In this case, instead of scheduling work on a remote cpu, it should > > > > be safe to grab that remote cpu's per-cpu spinlock and run the required > > > > work locally. That major cost, which is un/locking in every local function, > > > > already happens in PREEMPT_RT. > > > > > > We did have this before but only in the RT tree. It was a bit messy from > > > the naming because it started with local_ but then it was a remote CPU. > > > > Had the same naming issue here. This idea was initially a expansion to > > local_lock() mechanism, about the same way you were planning in the past. > > > > > The main issue was the different code path which led to a few deadlocks > > > back then. > > > By the time local_lock_t went upstream, the cross-CPU locking was > > > removed. As far as I remember, the cross-CPU user which did schedule > > > work on a remote CPU and annoyed NOHZ folks were replaced. > > > > I understand this could be a big issue if used in a generic way. > > > > What I am proposing here a mechanism that standardizes those > > local_lock()+IPI strategies based on how they are done today, so we are > > only explected to get 'remote-cpu' pwlocks in the 'IPI replacement' > > operations. > > > > The idea is pwlock_local* in every local function, and pwlock*(,cpu) in > > operations that can be remote. > > > > Maybe being used in a more constrained way, it has less chance of being an > > issue. Also, the whole idea is to improve CPU isolation numbers by > > reducing IPIs, so maybe NOHZ people will be happier with that :) > > I get that part. The local_lock_t part is cheap on !RT and becomes a > full lock on RT. While the lock details change the overall expectation > remain the same. With this change it is possible to acquire the lock > cross-CPU but this depends on the config/ setup. This might not be easy > in terms of testing and maintenance. > The more potential users you have, the better it might become in terms > of a selling argument. If you have just (say) two users it might be > simpler to address just those. > IIRC there are multiple users of this mechanism around the kernel. I remember picking the first three (swap, slub and memcontrol) as examples of how to use pwlocks (QPW at the time). With the concept proven, I could then proceed to work with other potential users to replace it. (We ended up dropping memcontrol in the process) The main idea is to replace as many potential users as possible to reduce as much as possible the amount of IPIs in isolated cpus, and allow Linux to run workloads which require much lower latency. This idea came as a general solution to a bunch of latency violations Marcelo and I were coming across. Thanks! Leo