From: ebiederm@xmission.com (Eric W. Biederman)
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] exec: Cleanup exec from a non thread group leader.
Date: Mon, 30 Jan 2006 13:27:30 -0700 [thread overview]
Message-ID: <m1zmld5uml.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <43DDFDE3.58C01234@tv-sign.ru> (Oleg Nesterov's message of "Mon, 30 Jan 2006 14:52:03 +0300")
Oleg Nesterov <oleg@tv-sign.ru> writes:
> Eric W. Biederman wrote:
>>
>> And for good measure we set the thread group leaders
>> exit_signal to -1 so it will self reap. We are actually
>> past the point where that matters but it can't hurt, and
>> it might help someday.
>> ...
>> leader->exit_state = EXIT_DEAD;
>> + leader->exit_signal = -1;
>
> I disagree. The leader is already practically reaped, it is EXIT_DEAD.
> I think this change will confuse the reader who will try to understand
> why do we need this subtle assignment.
Six of one half dozen of the other. It doesn't matter so I don't
care.
>> void switch_exec_pids(task_t *leader, task_t *thread)
>> {
>> - __detach_pid(leader, PIDTYPE_PID);
>> - __detach_pid(leader, PIDTYPE_TGID);
>> - __detach_pid(leader, PIDTYPE_PGID);
>> - __detach_pid(leader, PIDTYPE_SID);
>> -
>> - __detach_pid(thread, PIDTYPE_PID);
>> - __detach_pid(thread, PIDTYPE_TGID);
>> -
>> - leader->pid = leader->tgid = thread->pid;
>> - thread->pid = thread->tgid;
>> -
>> - attach_pid(thread, PIDTYPE_PID, thread->pid);
>> - attach_pid(thread, PIDTYPE_TGID, thread->tgid);
>> + detach_pid(thread, PIDTYPE_PID);
>> + thread->pid = leader->pid;
>> + attach_pid(thread, PIDTYPE_PID, thread->pid);
>> attach_pid(thread, PIDTYPE_PGID, thread->signal->pgrp);
>> - attach_pid(thread, PIDTYPE_SID, thread->signal->session);
>> - list_add_tail(&thread->tasks, &init_task.tasks);
>
> The last deletion is wrong, I beleive.
list_add_tail is duplicate code. It is already present in the caller.
So it is noise and confusing to leave it here.
But you already noted that in the following email.
>> + attach_pid(thread, PIDTYPE_SID, thread->signal->session);
>>
>> - attach_pid(leader, PIDTYPE_PID, leader->pid);
>> - attach_pid(leader, PIDTYPE_TGID, leader->tgid);
>> - attach_pid(leader, PIDTYPE_PGID, leader->signal->pgrp);
>> - attach_pid(leader, PIDTYPE_SID, leader->signal->session);
>> + detach_pid(leader, PIDTYPE_PID);
>> + detach_pid(leader, PIDTYPE_TGID);
>> + detach_pid(leader, PIDTYPE_PGID);
>> + detach_pid(leader, PIDTYPE_SID);
>> }
>
> I think most of detach_pid()s could be replaced with __detach_pid(),
> this will save unneccesary pid_hash scanning
Actually 90% of the point was to remove the need for __detach_pid.
But you are right __detach_pid would be safe and we know that because
of the ordering. At the same time because we are not the last reference
the code will never do that.
I need to relook at this. To not conflict with your code some of
the detach_pids need to be removed so we don't unhash things twice.
Eric
next prev parent reply other threads:[~2006-01-30 20:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-30 11:52 Oleg Nesterov
2006-01-30 14:48 ` Oleg Nesterov
2006-01-30 20:33 ` Eric W. Biederman
2006-01-31 10:07 ` Oleg Nesterov
2006-01-31 15:35 ` Eric W. Biederman
2006-01-30 20:27 ` Eric W. Biederman [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-01-29 6:23 Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1zmld5uml.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome