linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Cedric Le Goater <clg@vnet.ibm.com>,
	Dave Hansen <haveblue@us.ibm.com>,
	Eric Biederman <ebiederm@xmission.com>,
	Herbert Poetzl <herbert@13thfloor.at>,
	Ingo Molnar <mingo@elte.hu>,
	Mathias Krause <Mathias.Krause@secunet.com>,
	Roland McGrath <roland@redhat.com>,
	Sukadev Bhattiprolu <sukadev@us.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] pids: fix fork_idle() to setup ->pids correctly
Date: Tue, 11 May 2010 03:54:10 -0500	[thread overview]
Message-ID: <20100511085410.GA22688@us.ibm.com> (raw)
In-Reply-To: <20100510195038.GD5249@redhat.com>

Quoting Oleg Nesterov (oleg@redhat.com):
> copy_process(pid => &init_struct_pid) doesn't do attach_pid/etc.
> 
> It shouldn't, but this means that the idle threads run with the wrong
> pids copied from the caller's task_struct. In x86 case the caller is
> either kernel_init() thread or keventd.
> 
> In particular, this means that after the series of cpu_up/cpu_down an
> idle thread (which never exits) can run with .pid pointing to nowhere.
> 
> Change fork_idle() to initialize idle->pids[] correctly. We only set
> .pid = &init_struct_pid but do not add .node to list, INIT_TASK() does
> the same for the boot-cpu idle thread (swapper).
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: Serge E. Hallyn <serue@us.ibm.com>

> ---
> 
>  kernel/fork.c |   14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> --- 34-rc1/kernel/fork.c~3_FORK_IDLE_SET_PIDS	2010-03-24 18:07:03.000000000 +0100
> +++ 34-rc1/kernel/fork.c	2010-05-10 20:45:33.000000000 +0200
> @@ -1339,6 +1339,16 @@ noinline struct pt_regs * __cpuinit __at
>  	return regs;
>  }
> 
> +static inline void init_idle_pids(struct pid_link *links)
> +{
> +	enum pid_type type;
> +
> +	for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) {
> +		INIT_HLIST_NODE(&links[type].node); /* not really needed */
> +		links[type].pid = &init_struct_pid;
> +	}
> +}
> +
>  struct task_struct * __cpuinit fork_idle(int cpu)
>  {
>  	struct task_struct *task;
> @@ -1346,8 +1356,10 @@ struct task_struct * __cpuinit fork_idle
> 
>  	task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL,
>  			    &init_struct_pid, 0);
> -	if (!IS_ERR(task))
> +	if (!IS_ERR(task)) {
> +		init_idle_pids(task->pids);
>  		init_idle(task, cpu);
> +	}
> 
>  	return task;
>  }

  reply	other threads:[~2010-05-11  8:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4BE01C86.3050908@secunet.com>
2010-05-09 18:45 ` kernel panic on kill(0, SIGTERM) with PGID == 0 Oleg Nesterov
2010-05-09 19:06   ` Oleg Nesterov
2010-05-10  7:20   ` Mathias Krause
2010-05-10 19:49     ` [PATCH 0/4] swapper fixes (Was: kernel panic on kill(0, SIGTERM) with PGID == 0) Oleg Nesterov
2010-05-10 19:49       ` [PATCH 1/4] INIT_TASK() should initialize ->thread_group list Oleg Nesterov
2010-05-11  7:52         ` Serge E. Hallyn
2010-05-12  2:15         ` Sukadev Bhattiprolu
2010-05-12 15:54           ` Oleg Nesterov
2010-05-10 19:50       ` [PATCH 2/4] pids: init_struct_pid.tasks should never see the swapper process Oleg Nesterov
2010-05-11  9:54         ` Serge E. Hallyn
2010-05-12 16:03           ` Oleg Nesterov
2010-05-10 19:50       ` [PATCH 3/4] pids: fix fork_idle() to setup ->pids correctly Oleg Nesterov
2010-05-11  8:54         ` Serge E. Hallyn [this message]
2010-05-10 19:51       ` [PATCH 4/4] INIT_SIGHAND: use SIG_DFL instead of NULL Oleg Nesterov
2010-05-11  8:54         ` Serge E. Hallyn
2010-05-10 21:08       ` [PATCH 0/4] swapper fixes (Was: kernel panic on kill(0, SIGTERM) with PGID == 0) Andrew Morton
2010-05-10 21:41         ` Oleg Nesterov
2010-05-10 23:55       ` Roland McGrath

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=20100511085410.GA22688@us.ibm.com \
    --to=serue@us.ibm.com \
    --cc=Mathias.Krause@secunet.com \
    --cc=akpm@linux-foundation.org \
    --cc=clg@vnet.ibm.com \
    --cc=ebiederm@xmission.com \
    --cc=haveblue@us.ibm.com \
    --cc=herbert@13thfloor.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=sukadev@us.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).