提交 338b1c7a 编写于 作者: T Thomas Gleixner 提交者: Zheng Zengkai

tick/sched: Optimize tick_do_update_jiffies64() further

mainline inclusion
from mainline-5.11-rc1
commit 7a35bf2a
category: feature
feature: Deep isolation
bugzilla: https://gitee.com/openeuler/kernel/issues/I4N00D
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7a35bf2a6a871cd0252cd371d741e7d070b53af9

--------------------------------

Now that it's clear that there is always one tick to account, simplify the
calculations some more.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20201117132006.565663056@linutronix.deSigned-off-by: NYunfeng Ye <yeyunfeng@huawei.com>
Reviewed-by: NChao Liu <liuchao173@huawei.com>
Reviewed-by: NChen Hui <judy.chenhui@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 7bda799f
...@@ -53,7 +53,7 @@ static ktime_t last_jiffies_update; ...@@ -53,7 +53,7 @@ static ktime_t last_jiffies_update;
*/ */
static void tick_do_update_jiffies64(ktime_t now) static void tick_do_update_jiffies64(ktime_t now)
{ {
unsigned long ticks = 0; unsigned long ticks = 1;
ktime_t delta; ktime_t delta;
/* /*
...@@ -91,20 +91,21 @@ static void tick_do_update_jiffies64(ktime_t now) ...@@ -91,20 +91,21 @@ static void tick_do_update_jiffies64(ktime_t now)
write_seqcount_begin(&jiffies_seq); write_seqcount_begin(&jiffies_seq);
last_jiffies_update = ktime_add(last_jiffies_update, tick_period);
delta = ktime_sub(now, tick_next_period); delta = ktime_sub(now, tick_next_period);
if (unlikely(delta >= tick_period)) { if (unlikely(delta >= tick_period)) {
/* Slow path for long idle sleep times */ /* Slow path for long idle sleep times */
s64 incr = ktime_to_ns(tick_period); s64 incr = ktime_to_ns(tick_period);
ticks = ktime_divns(delta, incr); ticks += ktime_divns(delta, incr);
last_jiffies_update = ktime_add_ns(last_jiffies_update, last_jiffies_update = ktime_add_ns(last_jiffies_update,
incr * ticks); incr * ticks);
} else {
last_jiffies_update = ktime_add(last_jiffies_update,
tick_period);
} }
do_timer(++ticks); do_timer(ticks);
/* /*
* Keep the tick_next_period variable up to date. WRITE_ONCE() * Keep the tick_next_period variable up to date. WRITE_ONCE()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册