Skip to contentSkip to conversation

sched: Move level 'again' after get_cpu() in sched_exec.

PATCH In review Rakib Mullick 2 participants 2 messages Jan 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: Move level 'again' after get_cpu() in sched_exec.

sched: move level again after get_cpu().

We can get this_cpu by calling get_cpu() once and it remains
same. We don't need to call it again.

---

kernel/sched.c +1 -1
@@ -3143,8 +3143,8 @@ void sched_exec(void)
 	unsigned long flags;
 	struct rq *rq;
 
-again:
 	this_cpu = get_cpu();
+again:
 	dest_cpu = select_task_rq(p, SD_BALANCE_EXEC, 0);
 	if (dest_cpu == this_cpu) {
 		put_cpu();
#1 lore raw
Quoted 4 lines · Rakib Mullick

sched: move level again after get_cpu().

We can get this_cpu by calling get_cpu() once and it remains
same. We don't need to call it again.

Yes we do... get_cpu() needs to be paired with put_cpu() and they disable/enable preemption.

Since there's an unconditional put_cpu() before the goto again, we need to do the get_cpu().

Plenty of kernel debug options would have informed you of this if you'd tried running it.

Quoted 15 lines

---

kernel/sched.c +1 -1
@@ -3143,8 +3143,8 @@ void sched_exec(void)
 	unsigned long flags;
 	struct rq *rq;
 
-again:
 	this_cpu = get_cpu();
+again:
 	dest_cpu = select_task_rq(p, SD_BALANCE_EXEC, 0);
 	if (dest_cpu == this_cpu) {
 		put_cpu();