From: Nathan Lynch <ntl@pobox.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH -mm][resend] Disable CPU hotplug during suspend
Date: Fri, 28 Jul 2006 13:20:41 -0500 [thread overview]
Message-ID: <20060728182041.GI19076@localdomain> (raw)
In-Reply-To: <200607281015.30048.rjw@sisk.pl>
Hi Rafael-
A couple of minor comments:
> +int cpu_down(unsigned int cpu)
> +{
> + int err = 0;
> +
> + mutex_lock(&cpu_add_remove_lock);
> + if (cpu_hotplug_disabled)
> + err = -EPERM;
> + else
> + err = __cpu_down(cpu);
> +
> mutex_unlock(&cpu_add_remove_lock);
> return err;
> }
> @@ -191,6 +203,11 @@ int __devinit cpu_up(unsigned int cpu)
> void *hcpu = (void *)(long)cpu;
>
> mutex_lock(&cpu_add_remove_lock);
> + if (cpu_hotplug_disabled) {
> + ret = -EPERM;
> + goto out;
> + }
I think -EBUSY would be more appropriate than -EPERM, perhaps?
> +#ifdef CONFIG_SUSPEND_SMP
> +static cpumask_t frozen_cpus;
> +
> +int disable_nonboot_cpus(void)
> +{
> + int cpu, error = 0;
> +
> + /* We take all of the non-boot CPUs down in one shot to avoid races
> + * with the userspace trying to use the CPU hotplug at the same time
> + */
> + mutex_lock(&cpu_add_remove_lock);
> + cpus_clear(frozen_cpus);
> + printk("Disabling non-boot CPUs ...\n");
> + for_each_online_cpu(cpu) {
> + if (cpu == 0)
> + continue;
Assuming cpu 0 is online is not okay in generic code. This should be
something like:
int cpu, first_cpu, error = 0;
/* We take all of the non-boot CPUs down in one shot to avoid races
* with the userspace trying to use the CPU hotplug at the same time
*/
mutex_lock(&cpu_add_remove_lock);
cpus_clear(frozen_cpus);
first_cpu = first_cpu(cpu_online_mask);
printk("Disabling non-boot CPUs ...\n");
for_each_online_cpu(cpu) {
if (cpu == first_cpu)
continue;
> + error = __cpu_down(cpu);
> + if (!error) {
> + cpu_set(cpu, frozen_cpus);
> + printk("CPU%d is down\n", cpu);
> + } else {
> + printk(KERN_ERR "Error taking CPU%d down: %d\n",
> + cpu, error);
> + break;
> + }
> + }
> + if (!error) {
> + BUG_ON(num_online_cpus() > 1);
> + BUG_ON(raw_smp_processor_id() != 0);
Same problem here.
Otherwise, I think the patch looks okay.
next prev parent reply other threads:[~2006-07-28 18:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-28 8:15 [PATCH -mm][resend] Disable CPU hotplug during suspend Rafael J. Wysocki
2006-07-28 18:20 ` Nathan Lynch [this message]
2006-07-28 19:15 ` Rafael J. Wysocki
2006-07-28 21:23 ` Rafael J. Wysocki
2006-07-28 22:40 ` Nathan Lynch
2006-07-29 12:18 ` Rafael J. Wysocki
2006-07-29 21:40 ` Nathan Lynch
2006-07-29 23:07 ` Rafael J. Wysocki
2006-07-29 5:15 ` Andrew Morton
2006-07-29 12:27 ` Rafael J. Wysocki
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=20060728182041.GI19076@localdomain \
--to=ntl@pobox.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/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