lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 12 Jun 2013 08:32:49 -0400
From:	Youquan Song <youquan.song@...ux.intel.com>
To:	Dave Hansen <dave@...1.net>
Cc:	Youquan Song <youquan.song@...ux.intel.com>,
	Toshi Kani <toshi.kani@...com>,
	"Rafael J. Wysocki" <rjw@...k.pl>, youquan.song@...el.com,
	LKML <linux-kernel@...r.kernel.org>,
	Stephen Rothwell <sfr@...b.auug.org.au>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	akpm@...ux-foundation.org
Subject: Re: cpu hotplug:  possible_cpus broken (again?) next-20130607

> On 06/12/2013 05:03 AM, Youquan Song wrote:
> > +#ifdef CONFIG_SMP
> > +              /* return when cpu number greater than maximum number of
> > CPUs */
> > +               if (setup_max_cpus <= num_online_cpus() + 1) {
> > +                       cpu_hotplug_driver_unlock();
> > +                       return -EINVAL;
> > +               }
> > +#endif
> >                 from_nid = cpu_to_node(cpuid);
> >                 ret = cpu_up(cpuid);
> 
> Your patch is line-wrapped.
> 
> Also, the #ifdef is unnecessary.  If CONFIG_SMP is off:
> 
> 	static const unsigned int setup_max_cpus = NR_CPUS;
> 	#define num_online_cpus() 1U
> 
> The compiler will take care of optimizing out the the if() without the
> explicit #ifdef.
> 
> Also, the +1 looks goofy to me.  Doesn't this do the same thing (and
> isn't it much easier to read)?
> 
> 	if (num_online_cpus() >= setup_max_cpus)
> 

Thanks. Here is a formal patch for it. please review and try.

Subject: [PATCH] core: Fix maxcpus boot option broken

maxcpus boot option to limit maximum number of CPUs on system, but this option
is broken at recent kernel. Though we use maxcpus to limit CPUs number, but
current kernel will register all of present CPUs in sysfs.
udev will enumerate all registered cpu at sysfs, and it will bring up the CPU
if the CPU is offline. So the maxcpus option is broken.

This patch will limit the online cpus number not over limitation of maxcpus
option. So it will keep the maxcpus limitation when udev enumeration
or other intention of bring up CPUs over the limitation by method like  
echo 1 > /sys/devices/system/cpu/online 

Signed-off-by: Youquan Song <youquan.song@...el.com>
---
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 3d48fc8..e32fffa 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -60,6 +60,13 @@ static ssize_t __ref store_online(struct device *dev,
 			kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
 		break;
 	case '1':
+	       /* Return when online cpu number equal or greater than
+		*  maximum number of CPUs */
+		if (num_online_cpus() >= setup_max_cpus) {
+			cpu_hotplug_driver_unlock();
+			return -EINVAL;
+		}
+
 		from_nid = cpu_to_node(cpuid);
 		ret = cpu_up(cpuid);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ