From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 C9EAE22FE11 for ; Sat, 14 Feb 2026 21:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771104963; cv=none; b=MJyMXOD8lzosC7slDK+Ab5rqumG54+Yrlcoy9nfzqNbQAH9pvGXRz2ZqScO1BIdO6o0DxLiJ938hBFHdES/dNasVz47STwQAmjHBf7T4OGcRkjDu4bhHCcvLDxMOH5GJOdmyDCUOehEJJbXxFyg35+KeifNbr0if5arQYRkkFz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771104963; c=relaxed/simple; bh=bi1UicSJT58WD6qJpXaLohdtYTns9OgaLip4oakEuek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=gZBJmKrTV4sZIyDgxQh6AwI6JjKYpD7CKsyRNr+xXvmBNNPQv22nVREHYGYVAQW7SQPNtwhV/SskIKktfXNBAl3lBWMcGCHZAuF6HEXQFjFPSW3sx2/KkUpNkn60e8xFCrl712fxPS6bFBN70aIOjnMbdJ6jb+f72j6P9Yzul/I= 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=C1JRfD4R; arc=none smtp.client-ip=209.85.128.42 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="C1JRfD4R" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-482f454be5bso38103085e9.0 for ; Sat, 14 Feb 2026 13:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771104960; x=1771709760; darn=vger.kernel.org; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Ro0ZhP/FlNj+GMkv9hkfY7zWnxPHN/VgorELWyYQ2EU=; b=C1JRfD4RBwf1EvKvCBoDJrNQIQ5Ccd+Dgt8un8j+6Yp7oYxgvTb5lS4y1xAYrET9Cv 5OxVLJ+kCJqtawTI6V2zgeUZSzFGGqCjWGfaUH2GS0FoIQ9ra4YRAmljvIXOPQnDM5wg 56Zq+uzmNSr4De5irsih2xxfZemfthGX5fy12aR0oQXoEgdOvsKUrcy3wX9euPP6ty6v CGeMuIpbZK0yf5fszsiAiBW5QFffjKuB0x1ITZcaW8gymlB+nGylek8t5mp+58pfRN72 lMYZKTtcvnhsnhK9I5/itgo7/mXlK03H1ecgM/zMAp6feiZxVsc442Prwks9eRjeyrGN j9iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771104960; x=1771709760; h=content-transfer-encoding:content-disposition: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; bh=Ro0ZhP/FlNj+GMkv9hkfY7zWnxPHN/VgorELWyYQ2EU=; b=WvgvqHdeT1bc/QzuhqKK9/v2pRsYcGvGhlOQpJwDsmgVsHHPENsX+Tln2dqfKVSY8d 4KK8MmMGNsnRcMAnNSeDHc3Z4gXVvkl3BPZAi7GDCTFtG17sSqXvsjWSDVYrScFIVHek p6IZ+IziO9+ykxIduazE/2Xe1GhF8bDSstXbNeAyFSlp8RtIGoLJ/u2Ohv2JxmHwD2Ua tijXiTio9rQeuzxdfmjJytpXoa32pF23DbYdzu5nLbAOgHmsgkzCvkxzjkOENlLR9VA7 LbzhJSrnI4dRXjCTt7UdH+O1MKQulb6FuVEs1PlhOCbWs/ZZ6g7GUedOC/bJ7to2H9YE VEHw== X-Forwarded-Encrypted: i=1; AJvYcCUemQQA4h4UnJIFA2bAJbhOp1HrmxZMnX+u0dH04cv/80CuNHuAOa/intRqUsqVJJ2uSDDmSjOG7tpa0s4=@vger.kernel.org X-Gm-Message-State: AOJu0YwIbocec2uSP6qtXohP6dUGu0eNj7YQh31dBH/uWqVi8nzpGgd8 /i8k6qdWhfgZGGXb2/VRaNLxRGQFtBPxKHPlSk6sd8PNraq8XDbuiGU6 X-Gm-Gg: AZuq6aKc/U+wtR5nDjSQ+pmddmz/kfnIH6ZB1rdN15Q+gwoOknSWUevNXU2b1CM2V3e GJ24sDb+MD6GNGAh16ri5sSAeo2yW209l0TgIjeQvbu/e43SMXuhDpsaIjjG36TH3mz0N+tBUpL 3mlRutvoeIts6foQpStzW4u/X4GSxePSW/NOEO7T3QpZObelnbp6pacd9nX21dKkju7MfsPOdmw TGm/5Hct3PBkmRkevDjGM3z7BzRChndvVukGBFlqjUfob3NRKJO+1aUqWdb+r/9YbFzH+B7WGQf avR8HgC1RQW0W5nnM8LE84yJ76eJ8/vcPrOF3z9vdPvXq4ub9A48cRpHrKG+fdjCYY0EVeR55d6 FjWjrvLxz2W+EyGkJDAtGb4rMATla19qycjGPVhtuj0a9qL2EJnON1A9iCSf3e0DHATlAYKk7MH ia7QopczgvWH/3iK4kR/OuKazU4/gcsA3V3PI= X-Received: by 2002:a05:600c:4446:b0:47e:e38b:a83 with SMTP id 5b1f17b1804b1-48378d62a9emr67568155e9.7.1771104960057; Sat, 14 Feb 2026 13:36:00 -0800 (PST) Received: from WindFlash.powerhub ([2a0a:ef40:1b2a:fa01:9944:6a8c:dc37:eba5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48370a4ffafsm49226635e9.5.2026.02.14.13.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Feb 2026 13:35:59 -0800 (PST) From: Leonardo Bras To: Marcelo Tosatti Cc: Leonardo Bras , Michal Hocko , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Leonardo Bras , Thomas Gleixner , Waiman Long , Boqun Feng , Frederic Weisbecker Subject: Re: [PATCH 0/4] Introduce QPW for per-cpu operations Date: Sat, 14 Feb 2026 18:35:58 -0300 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: <20260206143430.021026873@redhat.com> 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, Feb 11, 2026 at 09:11:21AM -0300, Marcelo Tosatti wrote: > On Wed, Feb 11, 2026 at 09:01:12AM -0300, Marcelo Tosatti wrote: > > On Tue, Feb 10, 2026 at 03:01:10PM +0100, Michal Hocko wrote: > > > On Fri 06-02-26 11:34:30, Marcelo Tosatti 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. > > > > 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. > > > > > > > > Also, there is no need to worry about extra cache bouncing: > > > > The cacheline invalidation already happens due to schedule_work_on(). > > > > > > > > This will avoid schedule_work_on(), and thus avoid scheduling-out an > > > > RT workload. > > > > > > > > Proposed solution: > > > > A new interface called Queue PerCPU Work (QPW), which should replace > > > > Work Queue in the above mentioned use case. > > > > > > > > If PREEMPT_RT=n this interfaces just wraps the current > > > > local_locks + WorkQueue behavior, so no expected change in runtime. > > > > > > > > If PREEMPT_RT=y, or CONFIG_QPW=y, queue_percpu_work_on(cpu,...) will > > > > lock that cpu's per-cpu structure and perform work on it locally. > > > > This is possible because on functions that can be used for performing > > > > remote work on remote per-cpu structures, the local_lock (which is already > > > > a this_cpu spinlock()), will be replaced by a qpw_spinlock(), which > > > > is able to get the per_cpu spinlock() for the cpu passed as parameter. > > > > > > What about !PREEMPT_RT? We have people running isolated workloads and > > > these sorts of pcp disruptions are really unwelcome as well. They do not > > > have requirements as strong as RT workloads but the underlying > > > fundamental problem is the same. Frederic (now CCed) is working on > > > moving those pcp book keeping activities to be executed to the return to > > > the userspace which should be taking care of both RT and non-RT > > > configurations AFAICS. > > > > Michal, > > > > For !PREEMPT_RT, _if_ you select CONFIG_QPW=y, then there is a kernel > > boot option qpw=y/n, which controls whether the behaviour will be > > similar (the spinlock is taken on local_lock, similar to PREEMPT_RT). > > > > If CONFIG_QPW=n, or kernel boot option qpw=n, then only local_lock > > (and remote work via work_queue) is used. > > OK, this is not true. There is only CONFIG_QPW and the qpw=yes/no kernel > boot option for control. > > CONFIG_PREEMPT_RT should probably select CONFIG_QPW=y and > CONFIG_QPW_DEFAULT=y. Fully agree :) > > > What "pcp book keeping activities" you refer to ? I don't see how > > moving certain activities that happen under SLUB or LRU spinlocks > > to happen before return to userspace changes things related > > to avoidance of CPU interruption ? > > > > Thanks > > >