linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched: Drop outdated compile-optimization comment
@ 2022-06-15 22:27 Brian Norris
  2022-06-17 11:10 ` Valentin Schneider
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2022-06-15 22:27 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Ben Segall, linux-kernel, Dietmar Eggemann,
	Daniel Bristot de Oliveira, Mel Gorman, Valentin Schneider,
	Steven Rostedt, Brian Norris

Looks like this exists from way back in 2011 (commit 095c0aa83e52
("sched: adjust scheduler cpu power for stolen time")), when there was a
little more aggressive use of #if around these variables. That #if is
gone, and the comment just confuses the reader now. (For one, we don't
call sched_rt_avg_update() directly any more either.)

Signed-off-by: Brian Norris <briannorris@chromium.org>
---

 kernel/sched/core.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bfa7452ca92e..6dbe52d90bef 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -679,10 +679,6 @@ struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf)
 
 static void update_rq_clock_task(struct rq *rq, s64 delta)
 {
-/*
- * In theory, the compile should just see 0 here, and optimize out the call
- * to sched_rt_avg_update. But I don't trust it...
- */
 	s64 __maybe_unused steal = 0, irq_delta = 0;
 
 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
-- 
2.36.1.476.g0c4daa206d-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] sched: Drop outdated compile-optimization comment
  2022-06-15 22:27 [PATCH] sched: Drop outdated compile-optimization comment Brian Norris
@ 2022-06-17 11:10 ` Valentin Schneider
  2022-06-17 13:31   ` Peter Zijlstra
  2022-06-17 20:33   ` Brian Norris
  0 siblings, 2 replies; 4+ messages in thread
From: Valentin Schneider @ 2022-06-17 11:10 UTC (permalink / raw)
  To: Brian Norris, Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Ben Segall, linux-kernel, Dietmar Eggemann,
	Daniel Bristot de Oliveira, Mel Gorman, Steven Rostedt,
	Brian Norris

On 15/06/22 15:27, Brian Norris wrote:
> Looks like this exists from way back in 2011 (commit 095c0aa83e52
> ("sched: adjust scheduler cpu power for stolen time")), when there was a
> little more aggressive use of #if around these variables. That #if is
> gone, and the comment just confuses the reader now. (For one, we don't
> call sched_rt_avg_update() directly any more either.)
>

So that sched_rt_avg_update() became update_irq_load_avg() with

  91c27493e78d ("sched/irq: Add IRQ utilization tracking")

and then the #ifdef configs were reorganized in

  11d4afd4ff66 ("sched/pelt: Fix warning and clean up IRQ PELT config")

I'd argue that comment is still somewhat relevant but it applies to that
block:

#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
		update_irq_load_avg(rq, irq_delta + steal);
#endif

if !CONFIG_HAVE_SCHED_AVG_IRQ then yes you'd expect the compiler to not
even add a call to update_irq_load_avg() in there, but compilers aren't the
most trustworthy things :-) If you feel like it, you could play with
GCC/clang and see what they emit if you remove those #ifdefs.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sched: Drop outdated compile-optimization comment
  2022-06-17 11:10 ` Valentin Schneider
@ 2022-06-17 13:31   ` Peter Zijlstra
  2022-06-17 20:33   ` Brian Norris
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2022-06-17 13:31 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: Brian Norris, Ingo Molnar, Juri Lelli, Vincent Guittot,
	Ben Segall, linux-kernel, Dietmar Eggemann,
	Daniel Bristot de Oliveira, Mel Gorman, Steven Rostedt

On Fri, Jun 17, 2022 at 12:10:05PM +0100, Valentin Schneider wrote:
> On 15/06/22 15:27, Brian Norris wrote:
> > Looks like this exists from way back in 2011 (commit 095c0aa83e52
> > ("sched: adjust scheduler cpu power for stolen time")), when there was a
> > little more aggressive use of #if around these variables. That #if is
> > gone, and the comment just confuses the reader now. (For one, we don't
> > call sched_rt_avg_update() directly any more either.)
> >
> 
> So that sched_rt_avg_update() became update_irq_load_avg() with
> 
>   91c27493e78d ("sched/irq: Add IRQ utilization tracking")
> 
> and then the #ifdef configs were reorganized in
> 
>   11d4afd4ff66 ("sched/pelt: Fix warning and clean up IRQ PELT config")
> 
> I'd argue that comment is still somewhat relevant but it applies to that
> block:
> 
> #ifdef CONFIG_HAVE_SCHED_AVG_IRQ
> 	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
> 		update_irq_load_avg(rq, irq_delta + steal);
> #endif
> 
> if !CONFIG_HAVE_SCHED_AVG_IRQ then yes you'd expect the compiler to not
> even add a call to update_irq_load_avg() in there, but compilers aren't the
> most trustworthy things :-) If you feel like it, you could play with
> GCC/clang and see what they emit if you remove those #ifdefs.

Mostly I think it was the jump_label stuff getting them confused. I
suspect that's fixed in todays compilers tho, so yeah, it might be good
to get rid of it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sched: Drop outdated compile-optimization comment
  2022-06-17 11:10 ` Valentin Schneider
  2022-06-17 13:31   ` Peter Zijlstra
@ 2022-06-17 20:33   ` Brian Norris
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Norris @ 2022-06-17 20:33 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Ben Segall, linux-kernel, Dietmar Eggemann,
	Daniel Bristot de Oliveira, Mel Gorman, Steven Rostedt

On Fri, Jun 17, 2022 at 12:10:05PM +0100, Valentin Schneider wrote:
> I'd argue that comment is still somewhat relevant but it applies to that
> block:
> 
> #ifdef CONFIG_HAVE_SCHED_AVG_IRQ
> 	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
> 		update_irq_load_avg(rq, irq_delta + steal);
> #endif

Eh, I suppose. The confusion still stands though ;)

> if !CONFIG_HAVE_SCHED_AVG_IRQ then yes you'd expect the compiler to not
> even add a call to update_irq_load_avg() in there, but compilers aren't the
> most trustworthy things :-) If you feel like it, you could play with
> GCC/clang and see what they emit if you remove those #ifdefs.

FWIW, update_irq_load_avg() is just "return 0" in that case. I think
that'd be considered excessive paranoia if you think a modern compiler
would still somehow produce a suboptimal result for that case :)

But anyway, I tried CONFIG_IRQ_TIME_ACCOUNTING=n +
CONFIG_PARAVIRT_TIME_ACCOUNTING=n with these compilers:

  x86 gcc 11.2.0 (Debian)
  x86 clang 13.0.1 (Debian)
  aarch64-linux-gnu-gcc 11.2.0 (Debian)

and they all dropped the update_irq_load_avg() even without the #ifdef.

I'll drop it in a v2, since that seems to be the consensus.

Brian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-17 20:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 22:27 [PATCH] sched: Drop outdated compile-optimization comment Brian Norris
2022-06-17 11:10 ` Valentin Schneider
2022-06-17 13:31   ` Peter Zijlstra
2022-06-17 20:33   ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).