* [PATCH RESEND] sched: idle: Optimize the generic idle loop by removing needless memory barrier
@ 2024-10-09 9:37 Zhongqiu Han
2024-10-09 13:05 ` Peter Zijlstra
2024-10-18 7:07 ` [tip: sched/core] " tip-bot2 for Zhongqiu Han
0 siblings, 2 replies; 4+ messages in thread
From: Zhongqiu Han @ 2024-10-09 9:37 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid
Cc: linux-kernel, quic_zhonhan
The memory barrier rmb() in generic idle loop do_idle() function is not
needed, it doesn't order any load instruction, just remove it as needless
rmb() can cause performance impact.
The rmb() was introduced by the tglx/history.git commit f2f1b44c75c4
("[PATCH] Remove RCU abuse in cpu_idle()") to order the loads between
cpu_idle_map and pm_idle. It pairs with wmb() in function cpu_idle_wait().
And then with the removal of cpu_idle_state in function cpu_idle() and
wmb() in function cpu_idle_wait() in commit 783e391b7b5b ("x86: Simplify
cpu_idle_wait"), rmb() no longer has a reason to exist.
After that, commit d16699123434 ("idle: Implement generic idle function")
implemented a generic idle function cpu_idle_loop() which resembles the
functionality found in arch/. And it retained the rmb() in generic idle
loop in file kernel/cpu/idle.c.
And at last, commit cf37b6b48428 ("sched/idle: Move cpu/idle.c to
sched/idle.c") moved cpu/idle.c to sched/idle.c. And commit c1de45ca831a
("sched/idle: Add support for tasks that inject idle") renamed function
cpu_idle_loop() to do_idle().
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
---
kernel/sched/idle.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index d2f096bb274c..ab911d1335ba 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -271,7 +271,6 @@ static void do_idle(void)
tick_nohz_idle_enter();
while (!need_resched()) {
- rmb();
/*
* Interrupts shouldn't be re-enabled from that point on until
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH RESEND] sched: idle: Optimize the generic idle loop by removing needless memory barrier
2024-10-09 9:37 [PATCH RESEND] sched: idle: Optimize the generic idle loop by removing needless memory barrier Zhongqiu Han
@ 2024-10-09 13:05 ` Peter Zijlstra
2024-10-18 7:07 ` [tip: sched/core] " tip-bot2 for Zhongqiu Han
1 sibling, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2024-10-09 13:05 UTC (permalink / raw)
To: Zhongqiu Han
Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
bsegall, mgorman, vschneid, linux-kernel
On Wed, Oct 09, 2024 at 05:37:45PM +0800, Zhongqiu Han wrote:
> The memory barrier rmb() in generic idle loop do_idle() function is not
> needed, it doesn't order any load instruction, just remove it as needless
> rmb() can cause performance impact.
>
> The rmb() was introduced by the tglx/history.git commit f2f1b44c75c4
> ("[PATCH] Remove RCU abuse in cpu_idle()") to order the loads between
> cpu_idle_map and pm_idle. It pairs with wmb() in function cpu_idle_wait().
>
> And then with the removal of cpu_idle_state in function cpu_idle() and
> wmb() in function cpu_idle_wait() in commit 783e391b7b5b ("x86: Simplify
> cpu_idle_wait"), rmb() no longer has a reason to exist.
>
> After that, commit d16699123434 ("idle: Implement generic idle function")
> implemented a generic idle function cpu_idle_loop() which resembles the
> functionality found in arch/. And it retained the rmb() in generic idle
> loop in file kernel/cpu/idle.c.
>
> And at last, commit cf37b6b48428 ("sched/idle: Move cpu/idle.c to
> sched/idle.c") moved cpu/idle.c to sched/idle.c. And commit c1de45ca831a
> ("sched/idle: Add support for tasks that inject idle") renamed function
> cpu_idle_loop() to do_idle().
>
> Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
> History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread* [tip: sched/core] sched: idle: Optimize the generic idle loop by removing needless memory barrier
2024-10-09 9:37 [PATCH RESEND] sched: idle: Optimize the generic idle loop by removing needless memory barrier Zhongqiu Han
2024-10-09 13:05 ` Peter Zijlstra
@ 2024-10-18 7:07 ` tip-bot2 for Zhongqiu Han
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Zhongqiu Han @ 2024-10-18 7:07 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Zhongqiu Han, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 8e113df990c9df70fc6d83ebd53ee1b2867c23c4
Gitweb: https://git.kernel.org/tip/8e113df990c9df70fc6d83ebd53ee1b2867c23c4
Author: Zhongqiu Han <quic_zhonhan@quicinc.com>
AuthorDate: Wed, 09 Oct 2024 17:37:45 +08:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 14 Oct 2024 12:52:40 +02:00
sched: idle: Optimize the generic idle loop by removing needless memory barrier
The memory barrier rmb() in generic idle loop do_idle() function is not
needed, it doesn't order any load instruction, just remove it as needless
rmb() can cause performance impact.
The rmb() was introduced by the tglx/history.git commit f2f1b44c75c4
("[PATCH] Remove RCU abuse in cpu_idle()") to order the loads between
cpu_idle_map and pm_idle. It pairs with wmb() in function cpu_idle_wait().
And then with the removal of cpu_idle_state in function cpu_idle() and
wmb() in function cpu_idle_wait() in commit 783e391b7b5b ("x86: Simplify
cpu_idle_wait"), rmb() no longer has a reason to exist.
After that, commit d16699123434 ("idle: Implement generic idle function")
implemented a generic idle function cpu_idle_loop() which resembles the
functionality found in arch/. And it retained the rmb() in generic idle
loop in file kernel/cpu/idle.c.
And at last, commit cf37b6b48428 ("sched/idle: Move cpu/idle.c to
sched/idle.c") moved cpu/idle.c to sched/idle.c. And commit c1de45ca831a
("sched/idle: Add support for tasks that inject idle") renamed function
cpu_idle_loop() to do_idle().
History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20241009093745.9504-1-quic_zhonhan@quicinc.com
---
kernel/sched/idle.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index d2f096b..ab911d1 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -271,7 +271,6 @@ static void do_idle(void)
tick_nohz_idle_enter();
while (!need_resched()) {
- rmb();
/*
* Interrupts shouldn't be re-enabled from that point on until
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH RESEND] sched: idle: Optimize the generic idle loop by removing needless memory barrier
@ 2024-08-16 10:06 Zhongqiu Han
0 siblings, 0 replies; 4+ messages in thread
From: Zhongqiu Han @ 2024-08-16 10:06 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid
Cc: linux-kernel, quic_zhonhan
The memory barrier rmb() in generic idle loop do_idle() function is not
needed, it doesn't order any load instruction, just remove it as needless
rmb() can cause performance impact.
the rmb() was introduced by the tglx/history.git commit f2f1b44c75c4
("[PATCH] Remove RCU abuse in cpu_idle()") to order the loads between
cpu_idle_map and pm_idle. It pairs with wmb() in function cpu_idle_wait().
And then with the removal of cpu_idle_state in function cpu_idle() and
wmb() in function cpu_idle_wait() in commit 783e391b7b5b ("x86: Simplify
cpu_idle_wait"), rmb() no longer has a reason to exist.
After that, commit d16699123434 ("idle: Implement generic idle function")
implemented a generic idle function cpu_idle_loop() which resembles the
functionality found in arch/. And it retained the rmb() in generic idle
loop in file kernel/cpu/idle.c.
And at last, commit cf37b6b48428 ("sched/idle: Move cpu/idle.c to
sched/idle.c") moved cpu/idle.c to sched/idle.c. And commit c1de45ca831a
("sched/idle: Add support for tasks that inject idle") renamed function
cpu_idle_loop() to do_idle().
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
---
kernel/sched/idle.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index e53e2da04ba4..712c1ce16c8b 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -271,7 +271,6 @@ static void do_idle(void)
tick_nohz_idle_enter();
while (!need_resched()) {
- rmb();
/*
* Interrupts shouldn't be re-enabled from that point on until
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-18 7:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 9:37 [PATCH RESEND] sched: idle: Optimize the generic idle loop by removing needless memory barrier Zhongqiu Han
2024-10-09 13:05 ` Peter Zijlstra
2024-10-18 7:07 ` [tip: sched/core] " tip-bot2 for Zhongqiu Han
-- strict thread matches above, loose matches on Subject: below --
2024-08-16 10:06 [PATCH RESEND] " Zhongqiu Han
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