All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: liguang <lig.fnst@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
	Anton Vorontsov <anton.vorontsov@linaro.org>
Subject: Re: [PATCH] cpu: rid cpu_hotplug_disabled check for cpu_down()
Date: Mon, 29 Apr 2013 10:00:40 +0530	[thread overview]
Message-ID: <517DF770.6020402@linux.vnet.ibm.com> (raw)
In-Reply-To: <1367203791-9723-1-git-send-email-lig.fnst@cn.fujitsu.com>

On 04/29/2013 08:19 AM, liguang wrote:
> in cpu_down(), _cpu_down() will do
> "
>         if (num_online_cpus() == 1)
>                  return -EBUSY;
> "
> when cpu_hotplug_disabled was set, num_online_cpus
> will return 1 for there's only 1 boot cpu.
> so, it's unnecessary to check cpu_hotplug_disabled
> here.
>

The 2 checks serve very different purposes; they are not the same!

The num_online_cpus() check is to ensure that the user doesn't do
something insane like trying to offline the last online CPU in the
system.

Whereas, the flag 'cpu_hotplug_disabled' is used to prevent user-
triggered CPU hotplug (such as those initiated through sysfs).
This is useful in cases where the system itself wants to initiate CPU
hotplug and it doesn't want annoying races with CPU hotplug going
on in parallel due to other reasons. One such case is suspend/resume.
That's why, if you have noticed, the suspend/resume code invokes the
_cpu_down() version, in order to bypass the flag and get its job done.

So, no, I think the check needs to stay.

Regards,
Srivatsa S. Bhat

> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  kernel/cpu.c |    6 ------
>  1 files changed, 0 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index b5e4ab2..cd166d3 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -330,14 +330,8 @@ int __ref cpu_down(unsigned int cpu)
> 
>  	cpu_maps_update_begin();
> 
> -	if (cpu_hotplug_disabled) {
> -		err = -EBUSY;
> -		goto out;
> -	}
> -
>  	err = _cpu_down(cpu, 0);
> 
> -out:
>  	cpu_maps_update_done();
>  	return err;
>  }
> 


  reply	other threads:[~2013-04-29  4:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29  2:49 [PATCH] cpu: rid cpu_hotplug_disabled check for cpu_down() liguang
2013-04-29  4:30 ` Srivatsa S. Bhat [this message]
2013-04-29  4:42   ` li guang
2013-04-29  4:59     ` Srivatsa S. Bhat
2013-04-29  5:20       ` li guang

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=517DF770.6020402@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anton.vorontsov@linaro.org \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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.