public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Tang Chen <tangchen@cn.fujitsu.com>
Cc: tony.luck@intel.com, bp@amd64.org, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com, x86@kernel.org,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
	Miao Xie <miaox@cn.fujitsu.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: Re: [PATCH] Do not change worker's running cpu in cmci_rediscover().
Date: Tue, 16 Oct 2012 16:08:24 -0700	[thread overview]
Message-ID: <20121016230824.GG16166@google.com> (raw)
In-Reply-To: <1348737586-7018-1-git-send-email-tangchen@cn.fujitsu.com>

Hello,

Sorry about the delay.  Was traveling.

On Thu, Sep 27, 2012 at 05:19:46PM +0800, Tang Chen wrote:
> 1. cmci_rediscover() is only called by the CPU_POST_DEAD event handler, which
> means the corresponding cpu has already dead. As a result, it won't be accessed
> in the for_each_online_cpu loop.
> So, we could change the if(cpu == dying) statement into a BUG_ON().

Let's please move this to a separate patch and use WARN_ON_ONCE()
instead.

> 2. cmci_rediscover() used set_cpus_allowed_ptr() to change the current process's
> running cpu, and migrate itself to the dest cpu. But worker processes are not
> allowed to be migrated. If current is a worker, the worker will be migrated to
> another cpu, but the corresponding  worker_pool is still on the original cpu.
> 
> In this case, the following BUG_ON in try_to_wake_up_local() will be triggered:
> BUG_ON(rq != this_rq());
> 
> This will cause the kernel panic.
> 
> This patch removes the set_cpus_allowed_ptr() call, and put the cmci rediscover
> jobs onto all the other cpus using system_wq. This could bring some delay for
> the jobs.
...
> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>

After separating out the fix part into a separate patch, please add
Cc: stable@vger.kernel.org.

>  void cmci_rediscover(int dying)
>  {
> -	int banks;
> -	int cpu;
> -	cpumask_var_t old;
> +	int cpu, banks;
>  
>  	if (!cmci_supported(&banks))
>  		return;
> -	if (!alloc_cpumask_var(&old, GFP_KERNEL))
> -		return;
> -	cpumask_copy(old, &current->cpus_allowed);
>  
>  	for_each_online_cpu(cpu) {
> -		if (cpu == dying)
> -			continue;
> -		if (set_cpus_allowed_ptr(current, cpumask_of(cpu)))
> +		BUG_ON(cpu == dying);
> +
> +		if (cpu == smp_processor_id()) {
> +			cmci_rediscover_work_func(NULL);
>  			continue;
> -		/* Recheck banks in case CPUs don't all have the same */
> -		if (cmci_supported(&banks))
> -			cmci_discover(banks, 0);
> -	}
> +		}
>  
> -	set_cpus_allowed_ptr(current, old);
> -	free_cpumask_var(old);
> +		work_on_cpu(cpu, cmci_rediscover_work_func, NULL);
> +	}

The change looks correct to me but fails to apply to the current
mainline.

Thanks!

-- 
tejun

  parent reply	other threads:[~2012-10-16 23:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27  9:19 [PATCH] Do not change worker's running cpu in cmci_rediscover() Tang Chen
2012-09-28  7:54 ` Lai Jiangshan
2012-10-08  5:45   ` Tang Chen
2012-10-16 23:08 ` Tejun Heo [this message]
2012-10-18  3:42   ` Tang Chen

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=20121016230824.GG16166@google.com \
    --to=tj@kernel.org \
    --cc=bp@amd64.org \
    --cc=hpa@zytor.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaox@cn.fujitsu.com \
    --cc=mingo@redhat.com \
    --cc=tangchen@cn.fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.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