From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 E39C1348866 for ; Sun, 8 Mar 2026 18:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772992942; cv=none; b=AnwhBjVJEFyqBDf2KK0O5HTI5irMDBz81C3A7fexCAMbkJ9Q6zIOsWdE9L+mE2kxUcPgFQtMN5n9TUHLkVHciq0N93iF5CwWrbFVAXdMzlYweFUWD72zw04A0RREp6r023LlpE976H8bOMZXSQnQudvzSxZiYSTSvLzN9AcJUJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772992942; c=relaxed/simple; bh=JfYY/VXIYtRtoAUVtFEdgUxWGwaKLMhy9VbenHPgF6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=qLnfcfwSeV/KW7igUGQI5XhXCrHkIIdyc8P+3mZhXSVCc4seHrAuZRhvD3sXfMRKofUHXsbcXMhhV+o7v8TGEuxkNoThkfOM09d0XkkkXI6Rww/Xj7sZ8sMHLveChuAmjkMeHkcU3Pr2LpTHY+BRxeW9gGzsrR3JCj833KGnI4E= 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=apI4BH2x; arc=none smtp.client-ip=209.85.221.50 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="apI4BH2x" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-439b611274bso4770000f8f.3 for ; Sun, 08 Mar 2026 11:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772992939; x=1773597739; 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=zKtcruYTzK14kYFJK3mP/hRfgZ/eHbQmYEP+7T1CmKo=; b=apI4BH2x2RnpCH5/YE5fbY6KkQH+Q+Ex/8XadDhrFFdWAFQ9lLpxR8pB3KDF7UIcUP 4E4t6pI3Zeh819/T9aSLw7JV2It+7B54GDG8ID9kaCWM+ioVRHSaKjgBt9c6cjLtskr/ oN1wDlIH2962i2vah240+9aiGy9igCKmVhPrWOTn9GHARfrAwecKtGttFUnO1q5taE/p oi/XJ4m8znAD5SJ12QY4u3HaXmVqFakIYzcvQOLaBVkykRj3CSYViigP1qDEjNl2QCWB 7vB2x5MLAVUCwCjFPb4TyPxLU+rm+sYuUvs2GApq0C0/m0QhJ09U0/5FmA3yl2Ttn9Yv AdIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772992939; x=1773597739; 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=zKtcruYTzK14kYFJK3mP/hRfgZ/eHbQmYEP+7T1CmKo=; b=edF0cmJX/bLy2H4j5n7ixzcoqRxMNT81THnH1qb2rtJECRukvXzvvRE94X43nqHPfT jZWgu5Hp/IEdpDbdryw9Gu56vJUxukN21+jCZfPPBTL+hkm6bVItT+5NhtVpytbOWo78 qNHGSbJ006RiUg13fTsxHY2AKFzZq8ohtGNT2Hh5SMpzCDYgHjg97PBf8CvSanWSj49h ASx0Aeyw1uBC0xJoLzMlqk4RU+525LkNbW7jmvHDnEigY+OE3MOgv8F+yudSKKuBmLcU 8vJqDHasoniFi8ctsHR6NuWDIRA+PggS0cTrfPhHy/pZxcQB07t6DpWCQQIk26K4QJbc BjdA== X-Forwarded-Encrypted: i=1; AJvYcCV6otW/0p6rJCIHNT8JhTxh1h0EScXYzxhIiaDL/BYVS0t4yqZ2a8yYjAtTOsm+B254ZQkHIhK7wVibpwk=@vger.kernel.org X-Gm-Message-State: AOJu0YzqHTfpstq0LgVe+iydF6JN+G6BxGW0nc25ORmx1CzN56k4cpTR bAxJUSH72kXgfPpDx/LQeH//Z3nu6EZGU/o/oIzKg0d9Z8INR9S8NtcG X-Gm-Gg: ATEYQzxbekCUuQEh3niktSchTwEX4y4gTqhZkSA70fRvLstsnUDxL7F+xWkwoyEPCc4 AC7K4B9r7ouA+76TztZiWpr7KWTeKDt25LO8YE7srH2B+v24vDBQ9ys6XItdBUhqLYS2Vyq/P3O 6HQFaQlcRksBNNGFE9ARRJA5S6+J+T/VE5L6x0UtAcI/hm7L/6awmku1w8+J+x50XwNjHCLETTj odIGWclOfnHPdPhhLbWd0MXvV/RxiPC+gw11Mm7BWkaXJkVOMfBULGjiNu+dlhUYx3UlW7qHJVM yeYnjwq3BCfyvEKNpYNkiv/4CPzJaufF2v9bMoN8YAcNwmEY9WTpRUDSpNf6DAzzqu90iE/ol+8 ZfU2oeSjrkf9EXzXCB8siB6CAAbZL9SzVvR0kGvVxzhXRGBqHY6o1GXm33dcCabq87GJo7SvIi9 7vTOrn25Jkyh87Fe4CrGzESsPV4wE3c+HzFig= X-Received: by 2002:a5d:588e:0:b0:439:ccd7:cde1 with SMTP id ffacd0b85a97d-439da65c413mr14710906f8f.14.1772992939024; Sun, 08 Mar 2026 11:02:19 -0700 (PDT) Received: from WindFlash.powerhub ([2a0a:ef40:1b2a:fa01:9944:6a8c:dc37:eba5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dad97abasm18039839f8f.10.2026.03.08.11.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2026 11:02:18 -0700 (PDT) From: Leonardo Bras To: Frederic Weisbecker Cc: Leonardo Bras , Marcelo Tosatti , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Thomas Gleixner , Waiman Long , Boqun Feun Subject: Re: [PATCH v2 0/5] Introduce QPW for per-cpu operations (v2) Date: Sun, 8 Mar 2026 15:02:17 -0300 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: <20260302154945.143996316@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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Mar 03, 2026 at 12:15:53PM +0100, Frederic Weisbecker wrote: > Le Mon, Mar 02, 2026 at 12:49:45PM -0300, Marcelo Tosatti a écrit : > > 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 CONFIG_QPW=n this interfaces just wraps the current > > local_locks + WorkQueue behavior, so no expected change in runtime. > > > > If CONFIG_QPW=y, and qpw kernel boot option =1, > > 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. > > Ok I'm slowly considering this as a more comfortable solution than the > flush before userspace. Despite it being perhaps a bit more complicated, > remote handling of housekeeping work is more surprise-free against all > the possible nohz_full usecases that we are having a hard time to envision. > > Reviewing this more in details now. Awesome! Thanks! Leo > > Thanks. > > -- > Frederic Weisbecker > SUSE Labs