mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] sched: Drop outdated compile-optimization
@ 2022-06-17 20:34 Brian Norris
  2022-06-20 13:52 ` Valentin Schneider
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Norris @ 2022-06-17 20:34 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Valentin Schneider, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Steven Rostedt, Dietmar Eggemann,
	linux-kernel, 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. The comment
mostly serves to confuse the reader, although it may arguably apply to
the (excessive) #ifdef CONFIG_HAVE_SCHED_AVG_IRQ.

Anyway, the #ifdef is not needed, so drop both the comment and the
"optimization." Any modern compiler will realize this block is not
needed (for one, update_irq_load_avg() is an empty function when
!CONFIG_HAVE_SCHED_AVG_IRQ).

Confirmed on:

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

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

Changes in v2:
 - drop #ifdef too

 kernel/sched/core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bfa7452ca92e..eced503aa670 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
@@ -724,10 +720,9 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 
 	rq->clock_task += delta;
 
-#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
 	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
 		update_irq_load_avg(rq, irq_delta + steal);
-#endif
+
 	update_rq_clock_pelt(rq, delta);
 }
 
-- 
2.36.1.476.g0c4daa206d-goog


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

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

On 17/06/22 13:34, 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. The comment
> mostly serves to confuse the reader, although it may arguably apply to
> the (excessive) #ifdef CONFIG_HAVE_SCHED_AVG_IRQ.
>
> Anyway, the #ifdef is not needed, so drop both the comment and the
> "optimization." Any modern compiler will realize this block is not
> needed (for one, update_irq_load_avg() is an empty function when
> !CONFIG_HAVE_SCHED_AVG_IRQ).
>
> Confirmed on:
>
>   x86 gcc 11.2.0 (Debian)
>   x86 clang 13.0.1 (Debian)
>   aarch64-linux-gnu-gcc 11.2.0 (Debian)
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>

Reviewed-by: Valentin Schneider <vschneid@redhat.com>


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 20:34 [PATCH v2] sched: Drop outdated compile-optimization Brian Norris
2022-06-20 13:52 ` Valentin Schneider

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®