[PATCH 2/2] sched/core: Get rid of 'cpu' variable in __schedule()

From: Alexander Gordeev
Date: Sun Feb 28 2016 - 11:40:51 EST


'cpu' variable is only used to acquire the current runqueue.
By using this_rq() instead, we can get rid of that variable.

Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
---
kernel/sched/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4e56a4d..82206f0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3205,10 +3205,8 @@ static void __sched notrace __schedule(bool preempt)
struct task_struct *prev, *next;
unsigned long *switch_count;
struct rq *rq;
- int cpu;

- cpu = smp_processor_id();
- rq = cpu_rq(cpu);
+ rq = this_rq();
prev = rq->curr;

/*
@@ -3280,7 +3278,6 @@ static void __sched notrace __schedule(bool preempt)

trace_sched_switch(preempt, prev, next);
rq = context_switch(rq, prev, next); /* unlocks the rq */
- cpu = cpu_of(rq);
} else {
lockdep_unpin_lock(&rq->lock);
raw_spin_unlock_irq(&rq->lock);
--
1.8.3.1