Home » Mailing lists » Devel » [RFC][PATCH 0/15] Pid namespaces
Re: [PATCH 14/15] Destroy pid namespace on init's death [message #15417 is a reply to message #15377] |
Mon, 30 July 2007 11:56   |
Pavel Emelianov
Messages: 1149 Registered: September 2006
|
Senior Member |
|
|
Oleg Nesterov wrote:
> On 07/26, Pavel Emelyanov wrote:
>> @@ -895,6 +915,7 @@ fastcall NORET_TYPE void do_exit(long co
>> {
>> struct task_struct *tsk = current;
>> int group_dead;
>> + struct pid_namespace *pid_ns = tsk->nsproxy->pid_ns;
>>
>> profile_task_exit(tsk);
>>
>> @@ -905,9 +926,10 @@ fastcall NORET_TYPE void do_exit(long co
>> if (unlikely(!tsk->pid))
>> panic("Attempted to kill the idle task!");
>> if (unlikely(tsk == task_child_reaper(tsk))) {
>> - if (task_active_pid_ns(tsk) != &init_pid_ns)
>> - task_active_pid_ns(tsk)->child_reaper =
>> - init_pid_ns.child_reaper;
>> + if (pid_ns != &init_pid_ns) {
>> + zap_pid_ns_processes(pid_ns);
>> + pid_ns->child_reaper = init_pid_ns.child_reaper;
>> + }
>> else
>> panic("Attempted to kill init!");
>
> No, no, this is wrong. Yes, the current code is buggy too, I'll send
> the fix.
>
> I think this code should be moved below under the "if (group_dead)",
> and we should use tsk->group_leader.
>
>> +void zap_pid_ns_processes(struct pid_namespace *pid_ns)
>> +{
>> + int i;
>> + int nr;
>> + int nfree;
>> + int options = WNOHANG|WEXITED|__WALL;
>> +
>> +repeat:
>> + /*
>> + * We know pid == 1 is terminating. Find remaining pid_ts
>> + * in the namespace, signal them and then wait for them
>> + * exit.
>> + */
>> + nr = next_pidmap(pid_ns, 1);
>> + while (nr > 0) {
>> + kill_proc_info(SIGKILL, SEND_SIG_PRIV, nr);
>> + nr = next_pidmap(pid_ns, nr);
>> + }
>> +
>> + nr = next_pidmap(pid_ns, 1);
>> + while (nr > 0) {
>> + do_wait(nr, options, NULL, NULL, NULL);
>
> When the first child of init exits, it sends SIGCHLD. After that,
> do_wait() will never sleep, so we are doing a busy-wait loop.
> Not good, especially when we have a niced child, can livelock.
>
>> + nr = next_pidmap(pid_ns, nr);
>> + }
>> +
>> + nfree = 0;
>> + for (i = 0; i < PIDMAP_ENTRIES; i++)
>> + nfree += atomic_read(&pid_ns->pidmap[i].nr_free);
>> +
>> + /*
>> + * If pidmap has entries for processes other than 0 and 1, retry.
>> + */
>> + if (nfree < (BITS_PER_PAGE * PIDMAP_ENTRIES - 2))
>> + goto repeat;
>
> This doesn't look right.
>
> Suppose that some "struct pid" was pinned from the parent namespace.
> In that case zap_pid_ns_processes() will burn CPU until put_pid(), bad.
Nope. struct pid can be pinned, but the pidmap "fingerprint" cannot.
So as soon as the release_task() is called the pidmap becomes free and
we can proceed.
However I agree with the "burn CPU" issue - wait must sleep if needed.
> I think we can rely on forget_original_child() and do something like
> this:
>
> zap_active_ns_processes(void)
> {
> // kill all tasks in our ns and below
> kill(-1, SIGKILL);
That would be too slow to walk through all the tasks in a node searching
for a couple of them we need. fing_ge_pid() looks better to me.
> do {
> clear_thread_flag(TIF_SIGPENDING);
> } while (wait(NULL) != -ECHLD);
> }
>
> Oleg.
>
>
Thanks,
Pavel
|
|
|
 |
|
[RFC][PATCH 0/15] Pid namespaces
|
 |
|
[PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
By: dev on Thu, 26 July 2007 16:59
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
By: xemul on Fri, 27 July 2007 06:38
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
Re: [PATCH 1/15] Move exit_task_namespaces()
|
 |
|
[PATCH 2/15] Introduce MS_KERNMOUNT flag
|
 |
|
[PATCH 3/15] kern_siginfo helper
|
 |
|
Re: [PATCH 3/15] kern_siginfo helper
|
 |
|
Re: [PATCH 3/15] kern_siginfo helper
|
 |
|
Re: [PATCH 3/15] kern_siginfo helper
|
 |
|
[PATCH 4/15] Make proc_flust_task() flush entries from multiple proc trees
|
 |
|
[PATCH 5/15] Introduce struct upid
|
 |
|
Re: [PATCH 5/15] Introduce struct upid
|
 |
|
Re: [PATCH 5/15] Introduce struct upid
|
 |
|
[PATCH 6/15] Make alloc_pid(), free_pid() and put_pid() work with struct upid
|
 |
|
Re: [PATCH 6/15] Make alloc_pid(), free_pid() and put_pid() work with struct upid
|
 |
|
Re: [PATCH 6/15] Make alloc_pid(), free_pid() and put_pid() work with struct upid
|
 |
|
[PATCH 7/15] Helpers to obtain pid numbers
|
 |
|
Re: [PATCH 7/15] Helpers to obtain pid numbers
|
 |
|
Re: [PATCH 7/15] Helpers to obtain pid numbers
|
 |
|
Re: [PATCH 7/15] Helpers to obtain pid numbers
|
 |
|
Re: [PATCH 7/15] Helpers to obtain pid numbers
|
 |
|
[PATCH 8/15] Helpers to find the task by its numerical ids
|
 |
|
Re: [PATCH 8/15] Helpers to find the task by its numerical ids
|
 |
|
Re: [PATCH 8/15] Helpers to find the task by its numerical ids
|
 |
|
Re: [PATCH 8/15] Helpers to find the task by its numerical ids
|
 |
|
Re: [PATCH 8/15] Helpers to find the task by its numerical ids
|
 |
|
[PATCH 9/15] Move alloc_pid() after the namespace is cloned
|
 |
|
Re: [PATCH 9/15] Move alloc_pid() after the namespace is cloned
|
 |
|
Re: [PATCH 9/15] Move alloc_pid() after the namespace is cloned
|
 |
|
Re: [PATCH 9/15] Move alloc_pid() after the namespace is cloned
|
 |
|
Re: [PATCH 9/15] Move alloc_pid() after the namespace is cloned
|
 |
|
[PATCH 10/15] Make each namespace has its own proc tree
|
 |
|
Re: [PATCH 10/15] Make each namespace has its own proc tree
|
 |
|
Re: [PATCH 10/15] Make each namespace has its own proc tree
|
 |
|
Re: [PATCH 10/15] Make each namespace has its own proc tree
|
 |
|
Re: [PATCH 10/15] Make each namespace has its own proc tree
|
 |
|
[PATCH 11/15] Signal semantics
|
 |
|
Re: [PATCH 11/15] Signal semantics
|
 |
|
Re: [PATCH 11/15] Signal semantics
|
 |
|
Re: [PATCH 11/15] Signal semantics
By: serue on Fri, 27 July 2007 19:59
|
 |
|
Re: [PATCH 11/15] Signal semantics
|
 |
|
Re: [PATCH 11/15] Signal semantics
|
 |
|
Re: [PATCH 11/15] Signal semantics
|
 |
|
Re: [PATCH 11/15] Signal semantics
By: serue on Wed, 01 August 2007 16:13
|
 |
|
Re: [PATCH 11/15] Signal semantics
By: dev on Thu, 02 August 2007 08:35
|
 |
|
Re: [PATCH 11/15] Signal semantics
By: serue on Thu, 02 August 2007 20:09
|
 |
|
Re: [PATCH 11/15] Signal semantics
|
 |
|
[PATCH 12/15] Miscelaneous stuff for pid namespaces
|
 |
|
Re: [PATCH 12/15] Miscelaneous stuff for pid namespaces
|
 |
|
Re: [PATCH 12/15] Miscelaneous stuff for pid namespaces
|
 |
|
[PATCH 13/15] Clone the pid namespace
|
 |
|
[PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
By: dev on Thu, 02 August 2007 08:37
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
By: serue on Thu, 02 August 2007 19:13
|
 |
|
Re: [PATCH 14/15] Destroy pid namespace on init's death
|
 |
|
[PATCH 15/15] Hooks over the code to show correct values to user
|
 |
|
Re: [PATCH 15/15] Hooks over the code to show correct values to user
|
 |
|
Re: [PATCH 15/15] Hooks over the code to show correct values to user
|
 |
|
Re: [PATCH 15/15] Hooks over the code to show correct values to user
|
 |
|
Re: [PATCH 15/15] Hooks over the code to show correct values to user
|
 |
|
Re: [PATCH 15/15] Hooks over the code to show correct values to user
|
 |
|
Re: [RFC][PATCH 0/15] Pid namespaces
|
 |
|
Re: [RFC][PATCH 0/15] Pid namespaces
|
 |
|
Re: [RFC][PATCH 0/15] Pid namespaces
|
Goto Forum:
Current Time: Sat Sep 06 09:39:01 GMT 2025
Total time taken to generate the page: 0.14532 seconds
|