[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <871q5vi4x1.ffs@tglx>
Date: Tue, 21 May 2024 17:02:50 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: zhuqiuer1@...wei.com, anna-maria@...utronix.de, frederic@...nel.org,
linux-kernel@...r.kernel.org
Cc: zhuqiuer1@...wei.com
Subject: Re: Question: One-jiffy latency from the checking in
run_local_timers()
On Mon, May 20 2024 at 21:20, zhuqiuer1@...wei.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
Powered by blists - more mailing lists