From: Partha Satapathy <partha.satapathy@oracle.com>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: anna-maria@linutronix.de, tglx@kernel.org,
linux-kernel@vger.kernel.org, tj@kernel.org,
jiangshanlai@gmail.com, notify@kernel.org
Subject: Re: [External] : Re: [PATCH 0/2] timers/workqueue: Add support for active CPU
Date: Mon, 27 Apr 2026 22:22:53 +0530 [thread overview]
Message-ID: <ae24e309-724e-49b4-b95f-91c69629d0be@oracle.com> (raw)
In-Reply-To: <aeoLD_DWrXAP3Ynb@localhost.localdomain>
Thanks for the feedback,
One concrete example is our downstream RDS/RDMA code.
Commit 4c00f3b0dea023a9851908a501735c899b0772f9
("net/rds: Add preferred_cpu option to rds_rdma.ko")
added `preferred_cpu` so follow-up work can be placed for locality and
performance, not because correctness requires that exact CPU.
The motivation was to keep processing close to where the completion was
observed. The aim is to keep the workers near the CPU where the HCA's
queues are mapped, so completion handling and follow-up work remain
local. With `preferred_cpu=cq`, work is steered toward the CPU
matching the CQ interrupt affinity, which helps latency and cache
locality. With `preferred_cpu=numa`, work is kept on CPUs local to the
HCA's NUMA node, which helps scale-out while preserving locality to the
device and memory.
So here the chosen CPU is only a preference. If that CPU goes offline
in the window between selection and queueing, the delayed timer can end
up queued on a CPU that is no longer active, and execution is then
postponed until that CPU comes back.
For this class of user, fallback to an active CPU is preferable,
because the placement is an optimization, not a correctness requirement.
I also do not think this is specific to RDS. In general, network and
RDMA drivers often choose CPUs based on IRQ affinity, queue affinity, or
NUMA locality to improve latency and throughput, while still being able
to run on any online CPU. For that kind of workload, "active if
possible, fallback otherwise" looks like a useful generic behavior.
That said, I agree that a downstream-only example by itself may not be
enough to justify a mainline core API change. I mentioned RDS mainly to
answer your question about whether there are real users that choose CPUs
for performance/locality rather than strict correctness.
On 23-04-2026 17:35, Frederic Weisbecker wrote:
> Hi,
>
> Le Thu, Apr 23, 2026 at 09:19:05AM +0000, Partha Satapathy a écrit :
>> From: Partha Sarathi Satapathy <partha.satapathy@oracle.com>
>>
>> Hi,
>>
>> Timers queued with add_timer_on() and delayed work queued with
>> queue_delayed_work_on() currently rely on the caller to ensure that the
>> target CPU remains online until the enqueue operation completes. In
>> practice, CPU hotplug can still race with that sequence and leave the
>> timer queued on an offline CPU, where it will not run until that CPU
>> comes back online.
>>
>> For delayed work, this has a direct knock-on effect: if the backing
>> timer is stranded on an offline CPU, the work item is never queued for
>> execution until that CPU returns.
>>
>> In many cases, the target CPU is chosen for locality and cache affinity
>> rather than as a strict execution requirement. Falling back to an active
>> CPU is preferable to leaving the timer or delayed work blocked on a dead
>> CPU. While callers can try to track CPU hotplug state themselves, that
>> does not close the race, and taking the hotplug lock around enqueue
>> operations is too expensive for this class of use.
>>
>> This series adds opt-in helpers for that fallback behavior without
>> changing the semantics of the existing interfaces:
>>
>> - add_timer_active_cpu() queues a timer on the requested CPU only if
>> the target CPU's timer base is active; otherwise it falls back to
>> the current CPU.
>>
>> - queue_delayed_work_active_cpu() uses the new timer helper for the
>> delayed timer path and updates dwork->cpu to reflect the CPU
>> actually selected for the timer, so the work item is queued on the
>> same active CPU.
>>
>> The existing add_timer_on() and queue_delayed_work_on() behavior is left
>> unchanged for callers that require strict CPU placement.
>
> Timers are migrated when CPUs go offline. So the problem is queueing
> a timer to an offline CPU. It should be the responsibility of a subsystem
> to synchronize with CPU hotplug in order to avoid that.
>
> As for timers that are queued locally not for correctness but for performance
> reasons, do we know such example?
>
> Thanks.
>
prev parent reply other threads:[~2026-04-27 16:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 9:19 Partha Satapathy
2026-04-23 9:19 ` [PATCH 1/2] timer: add add_timer_active_cpu() Partha Satapathy
2026-05-05 21:33 ` Thomas Gleixner
2026-06-08 13:52 ` [External] : " Partha Satapathy
2026-06-19 16:20 ` Thomas Gleixner
2026-06-23 8:20 ` Partha Satapathy
2026-04-23 9:19 ` [PATCH 2/2] workqueue: add queue_delayed_work_active_cpu() Partha Satapathy
2026-04-23 12:05 ` [PATCH 0/2] timers/workqueue: Add support for active CPU Frederic Weisbecker
2026-04-27 16:52 ` Partha Satapathy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ae24e309-724e-49b4-b95f-91c69629d0be@oracle.com \
--to=partha.satapathy@oracle.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=notify@kernel.org \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome