Skip to content

Commit

Permalink
sched: Avoid unnecessary calculation of load imbalance at clone time
Browse files Browse the repository at this point in the history
In find_idlest_group(), the load imbalance is only relevant when the group
is either overloaded or fully busy but it is calculated unconditionally.
This patch moves the imbalance calculation to the context it is required.
Technically, it is a micro-optimisation but really the benefit is avoiding
confusing one type of imbalance with another depending on the group_type
in the next patch.

No functional change.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lkml.kernel.org/r/20201120090630.3286-3-mgorman@techsingularity.net
  • Loading branch information
Mel Gorman authored and Peter Zijlstra committed Nov 24, 2020
1 parent abeae76 commit 5c33900
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -8777,9 +8777,6 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu)
.group_type = group_overloaded,
};

imbalance = scale_load_down(NICE_0_LOAD) *
(sd->imbalance_pct-100) / 100;

do {
int local_group;

Expand Down Expand Up @@ -8833,6 +8830,11 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu)
switch (local_sgs.group_type) {
case group_overloaded:
case group_fully_busy:

/* Calculate allowed imbalance based on load */
imbalance = scale_load_down(NICE_0_LOAD) *
(sd->imbalance_pct-100) / 100;

/*
* When comparing groups across NUMA domains, it's possible for
* the local domain to be very lightly loaded relative to the
Expand Down

0 comments on commit 5c33900

Please sign in to comment.