mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Pavel Emelyanov <xemul@openvz.org>
Cc: Ingo Molnar <mingo@elte.hu>, Jesper Juhl <jesper.juhl@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Sukadev Bhattiprolu <sukadev@us.ibm.com>
Subject: Re: fork_idle && pid problems ?
Date: Thu, 17 Apr 2008 20:05:21 +0400	[thread overview]
Message-ID: <20080417160521.GA4482@tv-sign.ru> (raw)
In-Reply-To: <48077D65.1090207@openvz.org>

On 04/17, Pavel Emelyanov wrote:
>
> Oleg Nesterov wrote:
> >> Well, these was some request to make tasks always have pid link
> >> point to not NULL (from Matt?) so we'll need this :)
> > 
> > For now I'd suggest the patch below. If contrary to our expectations
> > there is any usage of idle_task->pids, we will notice ;)
> > 
> > Oleg.
> > 
> > --- kernel/fork.c~	2008-03-07 18:11:27.000000000 +0300
> > +++ kernel/fork.c	2008-04-17 19:34:10.000000000 +0400
> > @@ -1420,6 +1420,9 @@ struct task_struct * __cpuinit fork_idle
> >  	if (!IS_ERR(task))
> >  		init_idle(task, cpu);
> >  
> > +	/* COMMENT */
> > +	memset(task->pids, 0, sizeof task->pids);
> > +
> 
> Hm... Looks ok, but I'd suggest such patch instead:
> 
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1348,6 +1348,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
>  		}
>  		attach_pid(p, PIDTYPE_PID, pid);
>  		nr_threads++;
> +	} else {
> +		p->pids[PIDTYPE_PID].pid = NULL;
> +		p->pids[PIDTYPE_SID].pid = NULL;
> +		p->pids[PIDTYPE_PGID].pid = NULL;
>  	}

This penalizes the "normal" fork()...

> it will cover cases, when we (if ever) call the copy_process from
> other place. Oh, well...

We must not use init_struct_pid as an argument for copy_process(), except
in fork_idle(). Note that the result of copy_process(init_struct_pid) is
not "visible", we can't find it via find_pid() or see it on init_task.tasks.

Not that I have a strong opinion, though. In any case, I think this is
harmless. But "not good" anyway.

Oleg.


      reply	other threads:[~2008-04-17 16:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-16 21:45 Possible mem leak in copy_process() Jesper Juhl
2008-04-17  4:17 ` Arnd Bergmann
2008-04-17 11:57 ` Oleg Nesterov
2008-04-17 13:02   ` Ingo Molnar
2008-04-17 14:02     ` fork_idle && pid problems ? (was: Possible mem leak in copy_process()) Oleg Nesterov
2008-04-17 15:50       ` fork_idle && pid problems ? Pavel Emelyanov
2008-04-17 15:36         ` Oleg Nesterov
2008-04-17 16:40           ` Pavel Emelyanov
2008-04-17 16:05             ` Oleg Nesterov [this message]

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=20080417160521.GA4482@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=ebiederm@xmission.com \
    --cc=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sukadev@us.ibm.com \
    --cc=xemul@openvz.org \
    /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

all inboxes | Powered by JetHome®