From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 C6A303537F6 for ; Sun, 12 Jul 2026 20:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783888381; cv=none; b=tJinxoTUbY0xC6o9SHCi96Aif2484gA+OZsapOMTOXzoA6KM1awyHW+oc2dEaQh2Dr+iHnoMxmh6aAzJMlBZHAdMuBSyHjH8yOk5dcsybofamb/fDocyhCc2308A8KXq9pPwRW7YIhUCID+iho7qKGNmPahjBNTCnhKewt/KFnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783888381; c=relaxed/simple; bh=vIxocmQXXq6Vrqr+5uIHeLC+jGNN0zgOMuWrSgXpbzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=CmZx4cErqS3KnFfFKK7qshntC3EtcILVBasCKJqtqI+DsNhYI2iwhmHAdVn+3yw1qQICs0sWtS1MGlkPZHzYZz1dVlDqZuIWgxViM5OTC1sMKdd236LdmaFevG2yQf4yVI/CV0ErcBJB+iWCf4L0kRB9Dr1f0CbyzGPTW5RnukY= 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=mMndYpb3; arc=none smtp.client-ip=209.85.128.47 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="mMndYpb3" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-493b1710405so11719635e9.2 for ; Sun, 12 Jul 2026 13:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783888378; x=1784493178; 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=hoFLr1vfVTbyBPCDDFLHELDOVM+etETDJUoaDXyGSaU=; b=mMndYpb34zhFfe6n0q6ytkYCkSYMBGJsTvSSn3nwukDrqQemtcbxyf0xWzTKPP274i ZXJNT1vaef+9uw9IwoO5VnvNqSVXUgQKgtOgLzPvZNyJU0jNTSllZVkjEPd6YDGxuvCR UN73jY1FPFHKzWrH/gEZKxI7RwMtmH5uHP5Ag91Jsf0NagdpZScIo6NFC+dM0BEYYZoH dYGwdoM0F3/GEED+L8BNIB9iTSf5mu/ralFFF3O3kox3DHWhwD8JhOtPvo94B2LrMwJV OMpYF8Gfn6wOAK45OGCBEiUhqD03vJyKHvJSaOxRCtHHP6kbbwYs1DuWVD0UOsiDG1Fl l3hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783888378; x=1784493178; 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=hoFLr1vfVTbyBPCDDFLHELDOVM+etETDJUoaDXyGSaU=; b=tMgeFQWocafUQq4n5QCZLLYP2Wmv2Kd9+qTAN/k13POuFeIP1523fUzAHPFqnyYIx4 /KLoREcRaH9QSIOUc9HNig3fEcNVe80q7Y3F5VVnexDUoibysD/j33EZsJxC6Lg03utb 4BN/xKdXZ1d5Ek4BZKfS0KJPFZdnI9iy9dyD8LE+u1fJ04o/PMe2qzF5pslsj20yRGsR KIj/A0Ibt27utqFuSctw99tj0ZtVirgY4yB2nSw9fxWBe0kimIbPTKFft9F6X4S56Pnw CuJMU+XugYTIDLxd3uhwOsx+yEIFha7zuW+blOVC5U2ADPb7NGwZ4eAk2BD1RyJ/YxIT SU1g== X-Forwarded-Encrypted: i=1; AHgh+RpLraCyTXUvj31KPuAttsRhfW0O6moK1eSs17uxunn2Tj0jRXYTBMQNABCJbMHufB6FAkSQk89iaEwQ5f4=@vger.kernel.org X-Gm-Message-State: AOJu0YzPsKbACSpixj6WRn5WUD5xGggL16DigKt0p+jH2WKlRmXqUPCu bnED1J/KhkTfb0bERKCaHfpSgkzbHsVbBkJPqzIxI+Suh9CXByjUHfA+ X-Gm-Gg: AfdE7cmNQC8yM77TLV294gklq6/ZGC1oivmVnpDg2PJ5z6pIe5Jzf3hFhuisc4gE00z h/dbAxcQFb8FrrJ3pz3v8j6qqjVroq3tQ17vsAjoHAoaGcFCn2JAUmifK4zFEKDKjcDXtttk4zw 1/r11T9O57pjbUeIy/Z9phaGLq1Kb+mfrFHiUlOJTclqxWMkCrrd2pLx2jOpK7ICxbF46H87lVu 0M8sg4eWzZcLWtn/a3dCKPDIeBPo56uqOorEQmjqrQ0JAiOn/OfZWW3MKNGS0DYDRL/4n2teGlm 0vvzx2m39/rQ7vCpXmoCAEBMp42bK9e+a7WT3ru6ZJUeYDJAineSZ18hwlS0ml6EGn2T0J1N05M /L/u7S/OA9ZCE1xzZY9XasD3RyKE6r5002B+l5wuaKkPqcUNqEixzolAPIypymqRubpRsNBAJG3 KGK4z9IU8ergpqTuRRV0EWXA== X-Received: by 2002:a05:600c:b99:b0:493:b61c:72c3 with SMTP id 5b1f17b1804b1-493f8829956mr66599105e9.32.1783888377859; Sun, 12 Jul 2026 13:32:57 -0700 (PDT) Received: from WindFlash.powerhub ([2a0a:ef40:f61:3b01:d08a:833b:756:8fce]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47aa039af67sm88998034f8f.17.2026.07.12.13.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 13:32:57 -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: Sun, 12 Jul 2026 17:32:49 -0300 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260520130903.Ebsd4aUa@linutronix.de> References: <20260519012754.240804-1-leobras.c@gmail.com> <20260520130903.Ebsd4aUa@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 Wed, May 20, 2026 at 03:09:03PM +0200, Sebastian Andrzej Siewior wrote: > On 2026-05-18 22:27:46 [-0300], Leonardo Bras wrote: > > The problem: > > Some places in the kernel implement a parallel programming strategy > > consisting on local_locks() for most of the work, and some rare remote > > operations are scheduled on target cpu. This keeps cache bouncing low since > > cacheline tends to be mostly local, and avoids the cost of locks in non-RT > > kernels, even though the very few remote operations will be expensive due > > to scheduling overhead. > > > > On the other hand, for RT workloads this can represent a problem: getting > > an important workload scheduled out to deal with remote requests is > > sure to introduce unexpected deadline misses. > > > > 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. > > > 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 :) Thanks again! Leo