From: Thomas Gleixner <tglx@linutronix.de>
To: Imran Khan <imran.f.khan@oracle.com>,
anna-maria@linutronix.de, frederic@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] timers: introduce timer_try_add_on_cpu.
Date: Wed, 15 Jan 2025 17:04:27 +0100 [thread overview]
Message-ID: <87v7ugaws4.ffs@tglx> (raw)
In-Reply-To: <20250115134111.2703089-3-imran.f.khan@oracle.com>
On Thu, Jan 16 2025 at 00:41, Imran Khan wrote:
> + * Return:
> + * * %true - If timer was started on an online cpu
> + * * %false - If the specified cpu was offline or if its online status
> + * could not be ensured due to unavailability of hotplug lock.
> + */
> +bool timer_try_add_on_cpu(struct timer_list *timer, int cpu)
> +{
> + bool ret = true;
> +
> + if (unlikely(!cpu_online(cpu)))
> + ret = false;
> + else if (cpus_read_trylock()) {
> + if (likely(cpu_online(cpu)))
> + add_timer_on(timer, cpu);
> + else
> + ret = false;
> + cpus_read_unlock();
> + } else
> + ret = false;
> +
> + return ret;
Aside of the horrible coding style, that cpus_read_trylock() part does
not make any sense.
It's perfectly valid to queue a timer on a online CPU when the CPU
hotplug lock is held write, which can have tons of reasons even
unrelated to an actual CPU hotplug operation.
Even during a hotplug operation adding a timer on a particular CPU is
valid, whether that's the CPU which is actually plugged or not is
irrelevant.
So if we add such a function, then it needs to have very precisely
defined semantics, which have to be independent of the CPU hotplug lock.
The only way I can imagine is that the state is part of the per CPU
timer base, but then I have to ask the question what is actually tried
to solve here.
As far as I understood that there is an issue in the RDS code, queueing
a delayed work on a offline CPU, but that should have triggered at least
the warning in __queue_delayed_work(), right?
So the question is whether this try() interface is solving any of this
and not papering over the CPU hotplug related issues in the RDS code in
some way.
Thanks,
tglx
next prev parent reply other threads:[~2025-01-15 16:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 13:41 [PATCH 0/2] Handle timers added to offlined CPU(s) Imran Khan
2025-01-15 13:41 ` [PATCH 1/2] timers: WARN if add_timer_on is used with offlined cpu Imran Khan
2025-01-15 14:39 ` Thomas Gleixner
2025-01-15 15:10 ` imran.f.khan
2025-01-15 13:41 ` [PATCH 2/2] timers: introduce timer_try_add_on_cpu Imran Khan
2025-01-15 16:04 ` Thomas Gleixner [this message]
2025-01-15 17:00 ` imran.f.khan
2025-01-28 3:36 ` imran.f.khan
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=87v7ugaws4.ffs@tglx \
--to=tglx@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=imran.f.khan@oracle.com \
--cc=linux-kernel@vger.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