From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pQqiAj0YUGqG7gAAWB0awg (envelope-from ) for ; Thu, 09 Jul 2026 17:53:01 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=lists.lttng.org header.i=@lists.lttng.org header.a=rsa-sha256 header.s=default header.b=dB23Qj5y; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F029F1E04F; Thu, 09 Jul 2026 17:53:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=4.0.1 Received: from lists.lttng.org (lists.lttng.org [IPv6:2607:5300:400:ed00::6c26]) (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 simark.ca (Postfix) with ESMTPS id B88161E04F for ; Thu, 09 Jul 2026 17:52:59 -0400 (EDT) ARC-Filter: OpenARC Filter v1.2.1 lists.lttng.org 4gx7xR209kz29GV ARC-Seal: i=1; d=lists.lttng.org; s=arc1; a=rsa-sha256; cv=none; t=1783633979; b=R5M1VTW4TGadLbiMY2EDZFjnvaEXn+gMiGcRc/fXymjmJzw8iTfriTYMyGEVGvDOocye y/YOM5wv04lQfUO2S/y8P9qOsCgfhfqlh8eAlUmyf8aRUSvrfrTL5V+/JSLg9LnPqF8zm gW/a9qTAm5eXGWiK+MwrEBqnXvu3we8Uz+pOY4S51VigkjKBUlOP85OyH0Tr51jCaUfE0 SLOFvKeTjL+Ms4Y+Bmv/tgsR1jsQhm+nCH/gNmGbAdBmS+QrWSGfkKriq7b4HnD3R/SRP 5aDjGrAnOIJGkS9qpYqsewulTzxrW+Ejf29rwDHGK/SlGXMUmfBGKHMuAZqE9swqyZA== ARC-Message-Signature: i=1; d=lists.lttng.org; s=arc1; a=rsa-sha256; c=relaxed/simple; t=1783633979; h=DKIM-Signature:Date:To:Subject:Message-ID:MIME-Version:From:From; bh=W0d9AeIS+tnsysTC1uwzcB3cC5v8OZIKspDeBECsCj0=; b=QnD8YYDa8v9okgtE+25DvJ0KAU7fUtD14FTp+XWcVmP7uC7orC/2ZJn3hQNMaZviwdjs xgP4PmaVHSnp7So+uMYrEPjI1DxC5q+wO2Z/96N9iTveJlyCiopymjVHZBGHVqL/YTXzP 8iSNWK0xU+K9+6Phu7sIpmU5/FGGsSaRHNHafzmIArPu0XRUcmZDbDHlUVIAtFTyTOfWB 60FWV8Wf2PB6nKtazX3oH9YU9+2KNclZKwrGumpio4RBDWo1MAXPkav2eD8ud7yEVWoZA OM+DPfUMwUsdFI6fncd48Az7mWfrqrn6VjUivgYYdKqbNG7Y67h0jyH184BqXBE5FRg== ARC-Authentication-Results: i=1; lists.lttng.org; arc=none smtp.remote-ip="::1" DKIM-Filter: OpenDKIM Filter v2.11.0 lists.lttng.org 4gx7xR209kz29GV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.lttng.org; s=default; t=1783633979; bh=U2Q9PXVjBfzXXIvJMs7XIbB02eZ37ycEjxBAkf9VJds=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dB23Qj5yd6Z7N/FjDLznnwFN3s0++MxYRuolpMQ3tBrVk0A6jB5iq0NnNRpy8KYA3 3lqDmq5ghqVzIy1HbgBENgdRpb4UCEADXxFXM9IW00Yfb2VJMabQZDr7insSHtI3gJ Ei9Cs+jcVkHtO67MFwvR4QAXYatUs2ZUJGqW/QkbzMU3sZ7D3jlJnhmgR8PIJW+vj7 wQ/fTT8gm/xZg0b5AiJZgOs5g60RWEs91dIakSbmw/NCBzKbhbLe3ot58gLqo9ufoL +y869bG8mXMmJMhCiEZc+lVmFO/Kg8hYvZHxSX9hvJ1hbCY3gC5ulAf71fWLPUjvhq SSzMu1tTZsfNw== Received: from lists-lttng01.efficios.com (localhost [IPv6:::1]) by lists.lttng.org (Postfix) with ESMTP id 4gx7xR209kz29GV; Thu, 9 Jul 2026 17:52:59 -0400 (EDT) ARC-Filter: OpenARC Filter v1.2.1 lists.lttng.org 4gx7xP3x9Dz29GT DKIM-Filter: OpenDKIM Filter v2.11.0 lists.lttng.org 4gx7xP3x9Dz29GT Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) by lists.lttng.org (Postfix) with ESMTPS id 4gx7xP3x9Dz29GT for ; Thu, 9 Jul 2026 17:52:57 -0400 (EDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id CE176431E1; Thu, 9 Jul 2026 21:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B217C1F000E9; Thu, 9 Jul 2026 21:45:18 +0000 (UTC) Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 82D0ACE0F1C; Thu, 9 Jul 2026 14:45:18 -0700 (PDT) Date: Thu, 9 Jul 2026 14:45:18 -0700 To: Mathieu Desnoyers Cc: lttng-dev , Olivier Dion Subject: Re: CPU affinity behavior of liburcu call-rcu per-cpu worker threads Message-ID: <3573944e-3abc-48d7-aedf-3362ebd7ebe4@paulmck-laptop> References: <0600b601-3edf-4897-b319-b4763943809c@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0600b601-3edf-4897-b319-b4763943809c@efficios.com> X-BeenThere: lttng-dev@lists.lttng.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: LTTng development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "Paul E. McKenney via lttng-dev" Reply-To: paulmck@kernel.org Errors-To: lttng-dev-bounces@lists.lttng.org Sender: "lttng-dev" On Thu, Jul 09, 2026 at 04:00:17PM -0400, Mathieu Desnoyers wrote: > On 2026-07-09 14:48, Mathieu Desnoyers wrote: > > Hi Paul, > > > > I have a question related to liburcu per-cpu call-rcu worker threads. > > > > So far in the current liburcu releases no affinity is set when the > > worker threads are started. We have to wait for > > SET_AFFINITY_CHECK_PERIOD_MASK grace periods before the affinity is set > > (it takes about 2.5s in my benchmarks). > > > > This means that short-lived test programs will get poor CPU affinity > > for call-rcu worker threads at the beginning of their lifetime. So for > > short lived programs, this means poor performance. > > > > OTOH, if we have short-lived applications on a large machine, setting > > the affinity immediately when the worker thread is starting means > > we use CPU time on CPUs which may never be actually used by the > > application (no call-rcu activity), which can be detrimental to other > > use-cases as well. > > > > So I was wondering: is the choice of skipping setting the affinity > > on call-rcu worker thread startup done on purpose ? And if so, > > should we perhaps consider setting the affinity as soon as the > > worker thread is woken up for the first time rather than after > > SET_AFFINITY_CHECK_PERIOD_MASK grace periods ? My approach when I first implemented call_rcu() was that the typical application would have lots of reads and very few updates, so the default was a single call_rcu() thread shared by all worker threads. I allowed for manual configuration and affinity of call_rcu() threads for special-case high-update-rate applications. My hope was that we would be able to use per-CPU call_rcu() threads with something like rseq allowing the worker threads to move around arbitrarily but still getting good cache affinity in their interactions with the call_rcu() threads. Easy to say, I know! ;-) > I've implemented this compromise approach here: > > https://review.lttng.org/c/userspace-rcu/+/18257 call-rcu worker: set CPU affinity on first non-empty dequeue The idea being that the call_rcu() thread checks its partner and uses explicit affinity to follow it around? I am reminded of a DYNIX/ptx feature that allowed you to say that a pair of userspace threads were related, so that they should be migrated together. This idea did not go over well during the initial Linux-kernel scheduler discussions a quarter century back. ;-) I know! I know! Use sched_ext!!! (Sorry, couldn't resist...) Thanx, Paul > Feedback is welcome, > > Thanks! > > Mathieu > > > > > Note that there is a commit in liburcu changing this behavior right > > now, but it's not part of any release yet. I want to figure out the > > wanted behavior before releasing this change: > > > > commit 28f282af1905a1cf50ff9b5835b4cd9de4416ddf > > Author: Mathieu Desnoyers > > Date:   Wed Jul 1 12:49:43 2026 -0400 > > > >     call_rcu: pin per-CPU worker at thread startup > > > > Thanks, > > > > Mathieu > > > > > -- > Mathieu Desnoyers > EfficiOS Inc. > https://www.efficios.com