OpenVZ Forum


Home » Mailing lists » Devel » [RFC][PATCH] Use task_pgrp()/task_session() in copy_process
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 Go to previous messageGo to previous message
Dave Hansen is currently offline  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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: + rename-attach_pid-to-find_attach_pid.patch added to -mm tree
Next Topic: + attach_pid-with-struct-pid-parameter.patch added to -mm tree
Goto Forum:
  


Current Time: Mon Jul 21 09:29:47 GMT 2025

Total time taken to generate the page: 0.07177 seconds