Skip to content

Commit

Permalink
sched/fair: Move update_nohz_stats() to the CONFIG_NO_HZ_COMMON block…
Browse files Browse the repository at this point in the history
… to simplify the code & fix an unused function warning

When !CONFIG_NO_HZ_COMMON we get this new GCC warning:

   kernel/sched/fair.c:8398:13: warning: ‘update_nohz_stats’ defined but not used [-Wunused-function]

Move update_nohz_stats() to an already existing CONFIG_NO_HZ_COMMON #ifdef
block.

Beyond fixing the GCC warning, this also simplifies the update_nohz_stats() function.

[ mingo: Rewrote the changelog. ]

Fixes: 0826530 ("sched/fair: Remove update of blocked load from newidle_balance")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20210329144029.29200-1-yuehaibing@huawei.com
  • Loading branch information
YueHaibing authored and Ingo Molnar committed Apr 20, 2021
1 parent d0d252b commit 3f5ad91
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -8430,28 +8430,6 @@ group_type group_classify(unsigned int imbalance_pct,
return group_has_spare;
}

static bool update_nohz_stats(struct rq *rq)
{
#ifdef CONFIG_NO_HZ_COMMON
unsigned int cpu = rq->cpu;

if (!rq->has_blocked_load)
return false;

if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
return false;

if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
return true;

update_blocked_averages(cpu);

return rq->has_blocked_load;
#else
return false;
#endif
}

/**
* update_sg_lb_stats - Update sched_group's statistics for load balancing.
* @env: The load balancing environment.
Expand Down Expand Up @@ -10406,6 +10384,24 @@ void nohz_balance_enter_idle(int cpu)
WRITE_ONCE(nohz.has_blocked, 1);
}

static bool update_nohz_stats(struct rq *rq)
{
unsigned int cpu = rq->cpu;

if (!rq->has_blocked_load)
return false;

if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
return false;

if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
return true;

update_blocked_averages(cpu);

return rq->has_blocked_load;
}

/*
* Internal function that runs load balance for all idle cpus. The load balance
* can be a simple update of blocked load or a complete load balance with
Expand Down

0 comments on commit 3f5ad91

Please sign in to comment.