All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "J.H." <warthog9@kernel.org>,
	users@kernel.org, linux-kernel <linux-kernel@vger.kernel.org>,
	Frank Rowand <frank.rowand@am.sony.com>,
	"yong.zhang0" <yong.zhang0@gmail.com>,
	mingo@kernel.org, Jens Axboe <jaxboe@fusionio.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	scameron@beardog.cce.hp.com,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	hch <hch@infradead.org>
Subject: Re: [kernel.org users] [KORG] Panics on master backend
Date: Wed, 24 Aug 2011 18:08:06 +0200	[thread overview]
Message-ID: <20110824160806.GA12317@redhat.com> (raw)
In-Reply-To: <1314129133.8002.102.camel@twins>

Looking at the next emails, I guess this is already off-topic, but still...

On 08/23, Peter Zijlstra wrote:
>
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -2630,7 +2630,6 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
>  		smp_send_reschedule(cpu);
>  }
>
> -#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
>  static int ttwu_activate_remote(struct task_struct *p, int wake_flags)
>  {
>  	struct rq *rq;
> @@ -2647,7 +2646,6 @@ static int ttwu_activate_remote(struct task_struct *p, int wake_flags)
>  	return ret;
>
>  }
> -#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
>  #endif /* CONFIG_SMP */
>
>  static void ttwu_queue(struct task_struct *p, int cpu)
> @@ -2705,7 +2703,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
>  	 * this task as prev, wait until its done referencing the task.
>  	 */
>  	while (p->on_cpu) {
> -#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
>  		/*
>  		 * In case the architecture enables interrupts in
>  		 * context_switch(), we cannot busy wait, since that
> @@ -2713,11 +2710,11 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
>  		 * tries to wake up @prev. So bail and do a complete
>  		 * remote wakeup.
>  		 */
> -		if (ttwu_activate_remote(p, wake_flags))
> +		if (cpu == smp_processor_id() &&

I think this needs "task_cpu(p) == smp_processor_id()". We can't trust
"cpu", task_cpu() was called before ->on_rq check.

This task_cpu() looks really confusing imho, even if it is fine (afaics).
Perhaps it makes sense to do

	--- x/kernel/sched.c
	+++ x/kernel/sched.c
	@@ -2694,10 +2694,11 @@ try_to_wake_up(struct task_struct *p, un
			goto out;
	 
		success = 1; /* we're going to change ->state */
	-	cpu = task_cpu(p);
	 
	-	if (p->on_rq && ttwu_remote(p, wake_flags))
	+	if (p->on_rq && ttwu_remote(p, wake_flags)) {
	+		cpu = task_cpu(p); /* for ttwu_stat() */
			goto stat;
	+	}
	 
	 #ifdef CONFIG_SMP
		/*

to make this more clear. Or even the patch below, I dunno.

Oleg.

--- x/kernel/sched.c
+++ x/kernel/sched.c
@@ -2446,13 +2446,14 @@ static void update_avg(u64 *avg, u64 sam
 #endif
 
 static void
-ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
+ttwu_stat(struct task_struct *p, int wake_flags)
 {
 #ifdef CONFIG_SCHEDSTATS
 	struct rq *rq = this_rq();
 
 #ifdef CONFIG_SMP
 	int this_cpu = smp_processor_id();
+	int cpu = task_cpu(p);
 
 	if (cpu == this_cpu) {
 		schedstat_inc(rq, ttwu_local);
@@ -2694,7 +2695,6 @@ try_to_wake_up(struct task_struct *p, un
 		goto out;
 
 	success = 1; /* we're going to change ->state */
-	cpu = task_cpu(p);
 
 	if (p->on_rq && ttwu_remote(p, wake_flags))
 		goto stat;
@@ -2739,7 +2739,7 @@ try_to_wake_up(struct task_struct *p, un
 
 	ttwu_queue(p, cpu);
 stat:
-	ttwu_stat(p, cpu, wake_flags);
+	ttwu_stat(p, wake_flags);
 out:
 	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
@@ -2775,7 +2775,7 @@ static void try_to_wake_up_local(struct 
 		ttwu_activate(rq, p, ENQUEUE_WAKEUP);
 
 	ttwu_do_wakeup(rq, p, 0);
-	ttwu_stat(p, smp_processor_id(), 0);
+	ttwu_stat(p, 0);
 out:
 	raw_spin_unlock(&p->pi_lock);
 }


  parent reply	other threads:[~2011-08-24 16:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23 18:09 [KORG] Panics on master backend J.H.
2011-08-23 19:52 ` [kernel.org users] " Peter Zijlstra
2011-08-23 21:32   ` James Bottomley
2011-08-24  9:59     ` Peter Zijlstra
2011-08-24 16:08   ` Oleg Nesterov [this message]
2011-08-25 10:24     ` Peter Zijlstra
2011-08-25 13:54       ` Oleg Nesterov
2011-08-26  6:01         ` Yong Zhang
2011-08-26 13:57           ` Oleg Nesterov
2011-08-29  2:29             ` Yong Zhang
2011-08-29 13:06         ` Peter Zijlstra
2011-08-29 14:38           ` Oleg Nesterov

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=20110824160806.GA12317@redhat.com \
    --to=oleg@redhat.com \
    --cc=frank.rowand@am.sony.com \
    --cc=hch@infradead.org \
    --cc=jaxboe@fusionio.com \
    --cc=jejb@parisc-linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=scameron@beardog.cce.hp.com \
    --cc=tglx@linutronix.de \
    --cc=users@kernel.org \
    --cc=warthog9@kernel.org \
    --cc=yong.zhang0@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.