Home » Mailing lists » Devel » [RFC][PATCH] Use task_pgrp()/task_session() in copy_process
[RFC][PATCH] Use task_pgrp()/task_session() in copy_process [message #17128] |
Thu, 11 January 2007 15:58  |
Sukadev Bhattiprolu
Messages: 413 Registered: August 2006
|
Senior Member |
|
|
I am trying to replace process_group() and process_session() calls in
copy_process() with task_pgrp() and task_session().
Since task_pid() task_pgrp(), task_session() for the swapper are NULL, I
had to treat swapper as special in this patch and would like some comments.
Should we instead do some magic in start_kernel() so we don't have to treat
swapper special or maybe move the check for pid_t == 0 into task_pgrp()/
task_session() ?
P.S: For find_attach_pid()/attach_pid(), pls see my recent patches to Containers@
and LKML.
---
From: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Replace process_group() and process_session() with container-friendly task_pgrp() and
task_session().
Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: containers@lists.osdl.org
---
kernel/fork.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
Index: lx26-20-rc2-mm1/kernel/fork.c
===================================================================
--- lx26-20-rc2-mm1.orig/kernel/fork.c 2007-01-11 07:18:03.383853328 -0800
+++ lx26-20-rc2-mm1/kernel/fork.c 2007-01-11 07:19:55.550801360 -0800
@@ -1248,8 +1248,13 @@ static struct task_struct *copy_process(
p->signal->tty = current->signal->tty;
p->signal->pgrp = process_group(current);
set_signal_session(p->signal, process_session(current));
- find_attach_pid(p, PIDTYPE_PGID, process_group(p));
- find_attach_pid(p, PIDTYPE_SID, process_session(p));
+ if (current->pid) {
+ attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
+ attach_pid(p, PIDTYPE_SID, task_session(current));
+ } else {
+ find_attach_pid(p, PIDTYPE_PGID, process_group(current));
+ find_attach_pid(p, PIDTYPE_SID, process_session(current));
+ }
list_add_tail_rcu(&p->tasks, &init_task.tasks);
__get_cpu_var(process_counts)++;
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
|
|
|
Re: [RFC][PATCH] Use task_pgrp()/task_session() in copy_process [message #17131 is a reply to message #17128] |
Thu, 11 January 2007 18:04   |
Dave Hansen
Messages: 240 Registered: October 2005
|
Senior Member |
|
|
On Thu, 2007-01-11 at 07:58 -0800, Sukadev Bhattiprolu wrote:
> ===================================================================
> --- lx26-20-rc2-mm1.orig/kernel/fork.c 2007-01-11 07:18:03.383853328 -0800
> +++ lx26-20-rc2-mm1/kernel/fork.c 2007-01-11 07:19:55.550801360 -0800
> @@ -1248,8 +1248,13 @@ static struct task_struct *copy_process(
> p->signal->tty = current->signal->tty;
> p->signal->pgrp = process_group(current);
> set_signal_session(p->signal, process_session(current));
> - find_attach_pid(p, PIDTYPE_PGID, process_group(p));
> - find_attach_pid(p, PIDTYPE_SID, process_session(p));
> + if (current->pid) {
> + attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
> + attach_pid(p, PIDTYPE_SID, task_session(current));
> + } else {
> + find_attach_pid(p, PIDTYPE_PGID, process_group(current));
> + find_attach_pid(p, PIDTYPE_SID, process_session(current));
> + }
>
> list_add_tail_rcu(&p->tasks, &init_task.tasks);
> __get_cpu_var(process_counts)++;
I know I've asked this before (and I know I'm going to ask it again),
but why do we need both task_pgrp() and process_group() to both have
similar-sounding names and both take the same kind of argument? :) This
stuff _really_ needs to get cleaned up. It makes reviewing these
patches much harder.
In general, you should keep the hacks (which this is) to boot and
init-time stuff. If you can initialize a structure so that it plays
nicely for the rest of its life, do that. Don't put special cases in
common code that everybody will have to look at.
> Since task_pid() task_pgrp(), task_session() for the swapper are NULL, I
> had to treat swapper as special in this patch and would like some comments.
Can you do some research and find out _why_ these are NULL, and why they
need to be kept NULL?
-- Dave
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
|
|
|
Re: [RFC][PATCH] Use task_pgrp()/task_session() in copy_process [message #17133 is a reply to message #17131] |
Thu, 11 January 2007 19:44   |
Sukadev Bhattiprolu
Messages: 413 Registered: August 2006
|
Senior Member |
|
|
Dave Hansen [haveblue@us.ibm.com] wrote:
| On Thu, 2007-01-11 at 07:58 -0800, Sukadev Bhattiprolu wrote:
| > ===================================================================
| > --- lx26-20-rc2-mm1.orig/kernel/fork.c 2007-01-11 07:18:03.383853328 -0800
| > +++ lx26-20-rc2-mm1/kernel/fork.c 2007-01-11 07:19:55.550801360 -0800
| > @@ -1248,8 +1248,13 @@ static struct task_struct *copy_process(
| > p->signal->tty = current->signal->tty;
| > p->signal->pgrp = process_group(current);
| > set_signal_session(p->signal, process_session(current));
| > - find_attach_pid(p, PIDTYPE_PGID, process_group(p));
| > - find_attach_pid(p, PIDTYPE_SID, process_session(p));
| > + if (current->pid) {
| > + attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
| > + attach_pid(p, PIDTYPE_SID, task_session(current));
| > + } else {
| > + find_attach_pid(p, PIDTYPE_PGID, process_group(current));
| > + find_attach_pid(p, PIDTYPE_SID, process_session(current));
| > + }
| >
| > list_add_tail_rcu(&p->tasks, &init_task.tasks);
| > __get_cpu_var(process_counts)++;
|
| I know I've asked this before (and I know I'm going to ask it again),
| but why do we need both task_pgrp() and process_group() to both have
| similar-sounding names and both take the same kind of argument? :) This
| stuff _really_ needs to get cleaned up. It makes reviewing these
| patches much harder.
We are phasing out process_group(), process_session() which return a
pid_t. I guess it also points to not having a special case for swapper.
|
| In general, you should keep the hacks (which this is) to boot and
| init-time stuff. If you can initialize a structure so that it plays
| nicely for the rest of its life, do that. Don't put special cases in
| common code that everybody will have to look at.
|
| > Since task_pid() task_pgrp(), task_session() for the swapper are NULL, I
| > had to treat swapper as special in this patch and would like some comments.
|
| Can you do some research and find out _why_ these are NULL, and why they
| need to be kept NULL?
task_struct for swapper is initialized by hand (INIT_TASK, INIT_SIGNALS
etc) but no struct pid is ever allocated and attached to the swapper.
This is normally done in copy_process() and so is done for all other
processes starting with pid_t = 1 (/sbin/init).
I am trying to understand if there is a history to it and if they need to
be kept NULL.
|
| -- Dave
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
|
|
|
|
Re: [RFC][PATCH] Use task_pgrp()/task_session() in copy_process [message #17137 is a reply to message #17136] |
Thu, 11 January 2007 21:19  |
ebiederm
Messages: 1354 Registered: February 2006
|
Senior Member |
|
|
ebiederm@xmission.com (Eric W. Biederman) writes:
>
> So it probably makes sense for pidmap_init to initialize the
> pid for the session and group of the idle task. And then there
> are no special cases left.
Well that almost works except if we did that alloc_pid could not
successfully allocate pid 1. Grumble getting those special cases
out of the boot path is a pain.
If we had a non-hashed struct pid (init_pid?) that we filled in
early (statically?), that would keep copy_process happy.
Then we would need to call setsid() in the kernel right after
the fork to assign a legitimate session and process group
to pid == 1.
Since the idle thread is not doing anything it shouldn't matter,
although we can attach the idle thread after the fork to session
and process group == 1 or set them to NULL if there is a corner case
is anything that cares.
Eric
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
|
|
|
Goto Forum:
Current Time: Sat Jul 19 01:06:57 GMT 2025
Total time taken to generate the page: 0.04023 seconds
|