Skip to contentSkip to conversation

Remove the likely(pid) check in copy_process

PATCH New [email protected] 1 participant 1 message Mar 13, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 4/5 Remove the likely(pid) check in copy_process

From: Sukadev Bhattiprolu <[email protected]>
Subject: [PATCH 4/5] Remove the likely(pid) check in copy_process

Now that we pass in a struct pid parameter to copy_process() and even the swapper (pid_t == 0) has a valid struct pid, we no longer need this check.

Changelog:
Per Eric Biederman's comments, moved this out to a separate patch for easier review.

---
 kernel/fork.c |   34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)
kernel/fork.c +16 -18
Index: lx26-20-mm2c/kernel/fork.c
===================================================================
@@ -1249,26 +1249,24 @@ static struct task_struct *copy_process(
 		}
 	}
 
-	if (likely(p->pid)) {
-		add_parent(p);
-		tracehook_init_task(p);
-
-		if (thread_group_leader(p)) {
-			pid_t pgid = process_group(current);
-			pid_t sid = process_session(current);
-
-			p->signal->tty = current->signal->tty;
-			p->signal->pgrp = pgid;
-			set_signal_session(p->signal, process_session(current));
-			attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
-			attach_pid(p, PIDTYPE_SID, find_pid(sid));
+	add_parent(p);
+	tracehook_init_task(p);
 
-			list_add_tail_rcu(&p->tasks, &init_task.tasks);
-			__get_cpu_var(process_counts)++;
-		}
-		attach_pid(p, PIDTYPE_PID, pid);
-		nr_threads++;
+	if (thread_group_leader(p)) {
+		pid_t pgid = process_group(current);
+		pid_t sid = process_session(current);
+
+		p->signal->tty = current->signal->tty;
+		p->signal->pgrp = pgid;
+		set_signal_session(p->signal, process_session(current));
+		attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
+		attach_pid(p, PIDTYPE_SID, find_pid(sid));
+
+		list_add_tail_rcu(&p->tasks, &init_task.tasks);
+		__get_cpu_var(process_counts)++;
 	}
+	attach_pid(p, PIDTYPE_PID, pid);
+	nr_threads++;
 
 	total_forks++;
 	spin_unlock(&current->sighand->siglock);