Skip to contentSkip to conversation

detach_pid(): eliminate one find_pid() call

PATCH In review Oleg Nesterov 1 participant 1 message Oct 1, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 detach_pid(): eliminate one find_pid() call

Hello.

Now there is no point in calling costly find_pid(type) if __detach_pid(type) returned non zero value.

Oleg.

kernel/pid.c renamed from kernel/pid.c~ +4 -3
@@ -206,15 +206,16 @@ static fastcall int __detach_pid(task_t 
 
 void fastcall detach_pid(task_t *task, enum pid_type type)
 {
-	int nr;
+	int tmp, nr;
 
 	nr = __detach_pid(task, type);
 	if (!nr)
 		return;
 
-	for (type = 0; type < PIDTYPE_MAX; ++type)
-		if (find_pid(type, nr))
+	for (tmp = PIDTYPE_MAX; --tmp >= 0; )
+		if (tmp != type && find_pid(tmp, nr))
 			return;
+
 	free_pidmap(nr);
 }