Skip to contentSkip to conversation

pidhash: temporal debug checks

PATCH In review Oleg Nesterov 1 participant 2 messages Jan 30, 2006

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

PATCH 3/3 pidhash: temporal debug checks

This is only for testing in -mm tree.

Ensure that we really do not use pid == 0.

kernel/pid.c renamed from kernel/pid.c~DBG +7 -1
@@ -138,6 +138,7 @@ struct pid * fastcall find_pid(enum pid_
 
 	hlist_for_each_entry_rcu(pid, elem,
 			&pid_hash[type][pid_hashfn(nr)], pid_chain) {
+		WARN_ON(!pid->nr); /* to be removed soon */
 		if (pid->nr == nr)
 			return pid;
 	}
@@ -148,6 +149,9 @@ int fastcall attach_pid(task_t *task, en
 {
 	struct pid *pid, *task_pid;
 
+	WARN_ON(!task->pid); /* to be removed soon */
+	WARN_ON(!nr); /* to be removed soon */
+
 	task_pid = &task->pids[type];
 	pid = find_pid(type, nr);
 	task_pid->nr = nr;
@@ -168,9 +172,11 @@ static fastcall int __detach_pid(task_t 
 	struct pid *pid, *pid_next;
 	int nr = 0;
 
+	WARN_ON(!task->pid); /* to be removed soon */
+
 	pid = &task->pids[type];
 	if (!hlist_unhashed(&pid->pid_chain)) {
-
+		WARN_ON(!pid->nr); /* to be removed soon */
 		if (list_empty(&pid->pid_list)) {
 			nr = pid->nr;
 			hlist_del_rcu(&pid->pid_chain);
kernel/fork.c renamed from kernel/fork.c~DBG +1 -0
@@ -1210,6 +1210,7 @@ task_t * __devinit fork_idle(int cpu)
 	task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL, NULL, 0);
 	if (!task)
 		return ERR_PTR(-ENOMEM);
+	WARN_ON(task->proc_dentry); /* to be removed soon */
 	init_idle(task, cpu);
 
 	return task;
#1 lore raw

(Rediff after fixing a bug in [PATCH 1/3])

[PATCH 3/3] pidhash: temporal debug checks

This is for testing in -mm tree only. Ensure that we really do not use pid == 0.

kernel/pid.c renamed from kernel/pid.c~DBG +7 -1
@@ -138,6 +138,7 @@ struct pid * fastcall find_pid(enum pid_
 
 	hlist_for_each_entry_rcu(pid, elem,
 			&pid_hash[type][pid_hashfn(nr)], pid_chain) {
+		WARN_ON(!pid->nr); /* to be removed soon */
 		if (pid->nr == nr)
 			return pid;
 	}
@@ -148,6 +149,9 @@ int fastcall attach_pid(task_t *task, en
 {
 	struct pid *pid, *task_pid;
 
+	WARN_ON(!task->pid); /* to be removed soon */
+	WARN_ON(!nr); /* to be removed soon */
+
 	task_pid = &task->pids[type];
 	pid = find_pid(type, nr);
 	task_pid->nr = nr;
@@ -168,9 +172,11 @@ static fastcall int __detach_pid(task_t 
 	struct pid *pid, *pid_next;
 	int nr = 0;
 
+	WARN_ON(!task->pid); /* to be removed soon */
+
 	pid = &task->pids[type];
 	if (!hlist_unhashed(&pid->pid_chain)) {
-
+		WARN_ON(!pid->nr); /* to be removed soon */
 		if (list_empty(&pid->pid_list)) {
 			nr = pid->nr;
 			hlist_del_rcu(&pid->pid_chain);
kernel/fork.c renamed from kernel/fork.c~DBG +1 -0
@@ -1211,6 +1211,7 @@ task_t * __devinit fork_idle(int cpu)
 	if (!task)
 		return ERR_PTR(-ENOMEM);
 
+	WARN_ON(task->proc_dentry); /* to be removed soon */
 	REMOVE_LINKS(task);
 	init_idle(task, cpu);