Skip to contentSkip to conversation

move daemonized kernel threads into the swapper's session

PATCH In review Oleg Nesterov 2 participants 4 messages Nov 26, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 move daemonized kernel threads into the swapper's session

Any reason why daemonized kthread still uses 1,1 special pids? This patch sets 0,0 pids, this matches kthread_create'ed threads.

kernel/exit.c renamed from kernel/exit.c~3_daemonize_swapper +1 -1
@@ -390,7 +390,7 @@ void daemonize(const char *name, ...)
 		get_nsproxy(&init_nsproxy);
 		switch_task_namespaces(current, &init_nsproxy);
 	}
-	set_special_pids(find_pid(1));
+	set_special_pids(&init_struct_pid);
 	proc_clear_tty(current);
 
 	/* Block and flush all signals */
#1 lore raw
Quoted 2 lines · Oleg Nesterov

Any reason why daemonized kthread still uses 1,1 special pids?

Actually, I guess the reason is that this was not possible before. Now that set_special_pids uses "struct pid" we can do this.

Perhaps it is better to move the callsite to reparent_to_kthreadd() and kill set_sepcial_pids().

Oleg.

Acked-by on v1 3/3
#2 lore raw
In reply to Oleg Nesterov
Quoted 2 lines · Oleg Nesterov

Any reason why daemonized kthread still uses 1,1 special pids? This patch sets 0,0 pids, this matches kthread_create'ed threads.

You got it in your reply...

Quoted 1 line

Hmm. I wonder if we could ensure kernel_thread always returns a global pid_t, and then reallocate the struct pid for the task we have just daemonized so that it only has a single pid in the init_pid_ns.

That would remove our capturing of child pid namespaces.

Eric

#3 lore raw
Quoted 4 lines · [email protected] (Eric W. Biederman) writes:

Hmm. I wonder if we could ensure kernel_thread always returns a global pid_t, and then reallocate the struct pid for the task we have just daemonized so that it only has a single pid in the init_pid_ns.

Well we can't reallocate the struct pid, if anyone was using it we would have problems, but we can certainly remove all pid_t values except for those in the init_pid_ns.

We definitely have some serious issues with kernel_thread and signal sending though.

Eric