Skip to content

Commit 630246a

Browse files
Quentin PerretIngo Molnar
authored andcommitted
sched/fair: Clean-up update_sg_lb_stats parameters
In preparation for the introduction of a new root domain flag which can be set during load balance (the 'overutilized' flag), clean-up the set of parameters passed to update_sg_lb_stats(). More specifically, the 'local_group' and 'local_idx' parameters can be removed since they can easily be reconstructed from within the function. While at it, transform the 'overload' parameter into a flag stored in the 'sg_status' parameter hence facilitating the definition of new flags when needed. Suggested-by: Peter Zijlstra <peterz@infradead.org> Suggested-by: Valentin Schneider <valentin.schneider@arm.com> Signed-off-by: Quentin Perret <quentin.perret@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: adharmap@codeaurora.org Cc: chris.redpath@arm.com Cc: currojerez@riseup.net Cc: dietmar.eggemann@arm.com Cc: edubezval@gmail.com Cc: gregkh@linuxfoundation.org Cc: javi.merino@kernel.org Cc: joel@joelfernandes.org Cc: juri.lelli@redhat.com Cc: morten.rasmussen@arm.com Cc: patrick.bellasi@arm.com Cc: pkondeti@codeaurora.org Cc: rjw@rjwysocki.net Cc: skannan@codeaurora.org Cc: smuckle@google.com Cc: srinivas.pandruvada@linux.intel.com Cc: thara.gopinath@linaro.org Cc: tkjos@google.com Cc: vincent.guittot@linaro.org Cc: viresh.kumar@linaro.org Link: https://lkml.kernel.org/r/20181203095628.11858-12-quentin.perret@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 1f74de8 commit 630246a

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

kernel/sched/fair.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7905,16 +7905,16 @@ static bool update_nohz_stats(struct rq *rq, bool force)
79057905
* update_sg_lb_stats - Update sched_group's statistics for load balancing.
79067906
* @env: The load balancing environment.
79077907
* @group: sched_group whose statistics are to be updated.
7908-
* @load_idx: Load index of sched_domain of this_cpu for load calc.
7909-
* @local_group: Does group contain this_cpu.
79107908
* @sgs: variable to hold the statistics for this group.
7911-
* @overload: Indicate pullable load (e.g. >1 runnable task).
7909+
* @sg_status: Holds flag indicating the status of the sched_group
79127910
*/
79137911
static inline void update_sg_lb_stats(struct lb_env *env,
7914-
struct sched_group *group, int load_idx,
7915-
int local_group, struct sg_lb_stats *sgs,
7916-
bool *overload)
7912+
struct sched_group *group,
7913+
struct sg_lb_stats *sgs,
7914+
int *sg_status)
79177915
{
7916+
int local_group = cpumask_test_cpu(env->dst_cpu, sched_group_span(group));
7917+
int load_idx = get_sd_load_idx(env->sd, env->idle);
79187918
unsigned long load;
79197919
int i, nr_running;
79207920

@@ -7938,7 +7938,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
79387938

79397939
nr_running = rq->nr_running;
79407940
if (nr_running > 1)
7941-
*overload = true;
7941+
*sg_status |= SG_OVERLOAD;
79427942

79437943
#ifdef CONFIG_NUMA_BALANCING
79447944
sgs->nr_numa_running += rq->nr_numa_running;
@@ -7954,7 +7954,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
79547954
if (env->sd->flags & SD_ASYM_CPUCAPACITY &&
79557955
sgs->group_misfit_task_load < rq->misfit_task_load) {
79567956
sgs->group_misfit_task_load = rq->misfit_task_load;
7957-
*overload = 1;
7957+
*sg_status |= SG_OVERLOAD;
79587958
}
79597959
}
79607960

@@ -8099,17 +8099,14 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
80998099
struct sched_group *sg = env->sd->groups;
81008100
struct sg_lb_stats *local = &sds->local_stat;
81018101
struct sg_lb_stats tmp_sgs;
8102-
int load_idx;
8103-
bool overload = false;
81048102
bool prefer_sibling = child && child->flags & SD_PREFER_SIBLING;
8103+
int sg_status = 0;
81058104

81068105
#ifdef CONFIG_NO_HZ_COMMON
81078106
if (env->idle == CPU_NEWLY_IDLE && READ_ONCE(nohz.has_blocked))
81088107
env->flags |= LBF_NOHZ_STATS;
81098108
#endif
81108109

8111-
load_idx = get_sd_load_idx(env->sd, env->idle);
8112-
81138110
do {
81148111
struct sg_lb_stats *sgs = &tmp_sgs;
81158112
int local_group;
@@ -8124,8 +8121,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
81248121
update_group_capacity(env->sd, env->dst_cpu);
81258122
}
81268123

8127-
update_sg_lb_stats(env, sg, load_idx, local_group, sgs,
8128-
&overload);
8124+
update_sg_lb_stats(env, sg, sgs, &sg_status);
81298125

81308126
if (local_group)
81318127
goto next_group;
@@ -8175,8 +8171,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
81758171

81768172
if (!env->sd->parent) {
81778173
/* update overload indicator if we are at root domain */
8178-
if (READ_ONCE(env->dst_rq->rd->overload) != overload)
8179-
WRITE_ONCE(env->dst_rq->rd->overload, overload);
8174+
WRITE_ONCE(env->dst_rq->rd->overload, sg_status & SG_OVERLOAD);
81808175
}
81818176
}
81828177

kernel/sched/sched.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@ struct perf_domain {
716716
struct rcu_head rcu;
717717
};
718718

719+
/* Scheduling group status flags */
720+
#define SG_OVERLOAD 0x1 /* More than one runnable task on a CPU. */
721+
719722
/*
720723
* We add the notion of a root-domain which will be used to define per-domain
721724
* variables. Each exclusive cpuset essentially defines an island domain by

0 commit comments

Comments
 (0)