From: Thomas Gleixner <tglx@linutronix.de>
To: zhuqiuer1@huawei.com, anna-maria@linutronix.de,
frederic@kernel.org, linux-kernel@vger.kernel.org
Cc: zhuqiuer1@huawei.com
Subject: Re: Question: One-jiffy latency from the checking in run_local_timers()
Date: Tue, 21 May 2024 17:02:50 +0200 [thread overview]
Message-ID: <871q5vi4x1.ffs@tglx> (raw)
In-Reply-To: <20240520132040.259477-1-zhuqiuer1@huawei.com>
On Mon, May 20 2024 at 21:20, zhuqiuer1@huawei.com wrote:
> Hi there, the function "kernel/time/timer.c:run_local_timers" avoids
> raising a softirq when there are no timers set to expire at the
> current time. It achieves this by comparing the current "jiffies"
> with "base->next_expiry". However, when working with SMP, it is
> possible that a few CPUs are reading the jiffies while it is being
> incremented. These CPUs may read the old-jiffies value in
> "run_local_timers" and fail to invoke expired timers at this jiffy.
> This results in a one-jiffy latency for the timers.
Sure, but one tick latency is not the end of the world. What is the real
world problem caused by that?
> Can we simply add 1 to the "jiffies" value when we compare it with
> next_expiry? This may result in an unnecessary softirq being raised
> if a timer expires in the next jiffy, but can remove the one-jiffy
> latency. Not sure if this is a positive trade-off.
What guarantees that the jiffies increment has happened when the soft
interrupt is invoked at the end of the tick interrupt?
Nothing, especially not in virtualized environments.
So I rather keep it simple unless there is a real world problem to be
solved.
Thanks,
tglx
prev parent reply other threads:[~2024-05-21 15:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 13:20 Question: One-jiffy latency from the checking in run_local_timers() zhuqiuer1
2024-05-21 15:02 ` Thomas Gleixner [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=871q5vi4x1.ffs@tglx \
--to=tglx@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zhuqiuer1@huawei.com \
/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