Skip to contentSkip to conversation

wait_task_inactive: "improve" the returned value for ->nvcsw == 0

PATCH In review Oleg Nesterov 2 participants 2 messages Jul 30, 2008 – Jul 31, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 wait_task_inactive: "improve" the returned value for ->nvcsw == 0

(on top of wait_task_inactive-dont-consider-task-nivcsw.patch)

wait_task_inactive() returns 1 when p->nvcsw == 0 || p->nvcsw == 1. This means that two subsequent calls can return the same number while the task was scheduled in between.

Change the code to return "nvcsw | LONG_MIN" instead of "nvcsw ?: 1", now the overlap always needs LONG_MAX schedules.

kernel/sched.c renamed from kernel/sched.c~1_WTI_RET +1 -1
@@ -1923,7 +1923,7 @@ unsigned long wait_task_inactive(struct 
 		on_rq = p->se.on_rq;
 		ncsw = 0;
 		if (!match_state || p->state == match_state)
-			ncsw = p->nvcsw ?: 1;
+			ncsw = p->nvcsw | LONG_MIN; /* sets MSB */
 		task_rq_unlock(rq, &flags);
 
 		/*