Skip to content

Commit e418e1c

Browse files
Christoph LameterLinus Torvalds
authored andcommitted
[PATCH] sched: move idle status calculation into rebalance_tick()
Perform the idle state determination in rebalance_tick. If we separate balancing from sched_tick then we also need to determine the idle state in rebalance_tick. V2->V3 Remove useless idlle != 0 check. Checking nr_running seems to be sufficient. Thanks Suresh. Signed-off-by: Christoph Lameter <[email protected]> Cc: Peter Williams <[email protected]> Cc: Nick Piggin <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: "Siddha, Suresh B" <[email protected]> Cc: "Chen, Kenneth W" <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7835b98 commit e418e1c

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

kernel/sched.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,10 +2867,16 @@ static void update_load(struct rq *this_rq)
28672867
*/
28682868

28692869
static void
2870-
rebalance_tick(int this_cpu, struct rq *this_rq, enum idle_type idle)
2870+
rebalance_tick(int this_cpu, struct rq *this_rq)
28712871
{
28722872
unsigned long interval;
28732873
struct sched_domain *sd;
2874+
/*
2875+
* We are idle if there are no processes running. This
2876+
* is valid even if we are the idle process (SMT).
2877+
*/
2878+
enum idle_type idle = !this_rq->nr_running ?
2879+
SCHED_IDLE : NOT_IDLE;
28742880

28752881
for_each_domain(this_cpu, sd) {
28762882
if (!(sd->flags & SD_LOAD_BALANCE))
@@ -2902,37 +2908,26 @@ rebalance_tick(int this_cpu, struct rq *this_rq, enum idle_type idle)
29022908
/*
29032909
* on UP we do not need to balance between CPUs:
29042910
*/
2905-
static inline void rebalance_tick(int cpu, struct rq *rq)
2906-
{
2907-
}
29082911
static inline void idle_balance(int cpu, struct rq *rq)
29092912
{
29102913
}
2911-
static inline void update_load(struct rq *this_rq)
2912-
{
2913-
}
29142914
#endif
29152915

2916-
static inline int wake_priority_sleeper(struct rq *rq)
2916+
static inline void wake_priority_sleeper(struct rq *rq)
29172917
{
2918-
int ret = 0;
2919-
29202918
#ifdef CONFIG_SCHED_SMT
29212919
if (!rq->nr_running)
2922-
return 0;
2920+
return;
29232921

29242922
spin_lock(&rq->lock);
29252923
/*
29262924
* If an SMT sibling task has been put to sleep for priority
29272925
* reasons reschedule the idle task to see if it can now run.
29282926
*/
2929-
if (rq->nr_running) {
2927+
if (rq->nr_running)
29302928
resched_task(rq->idle);
2931-
ret = 1;
2932-
}
29332929
spin_unlock(&rq->lock);
29342930
#endif
2935-
return ret;
29362931
}
29372932

29382933
DEFINE_PER_CPU(struct kernel_stat, kstat);
@@ -3148,20 +3143,20 @@ void scheduler_tick(void)
31483143
struct task_struct *p = current;
31493144
int cpu = smp_processor_id();
31503145
struct rq *rq = cpu_rq(cpu);
3151-
enum idle_type idle = NOT_IDLE;
31523146

31533147
update_cpu_clock(p, rq, now);
31543148

31553149
rq->timestamp_last_tick = now;
31563150

3157-
if (p == rq->idle) {
3151+
if (p == rq->idle)
31583152
/* Task on the idle queue */
3159-
if (!wake_priority_sleeper(rq))
3160-
idle = SCHED_IDLE;
3161-
} else
3153+
wake_priority_sleeper(rq);
3154+
else
31623155
task_running_tick(rq, p);
3156+
#ifdef CONFIG_SMP
31633157
update_load(rq);
3164-
rebalance_tick(cpu, rq, idle);
3158+
rebalance_tick(cpu, rq);
3159+
#endif
31653160
}
31663161

31673162
#ifdef CONFIG_SCHED_SMT

0 commit comments

Comments
 (0)