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:	Fri, 12 Dec 2008 22:11:35 +1030
From:	Rusty Russell <rusty@...tcorp.com.au>
To:	Mike Travis <travis@....com>
Cc:	Ingo Molnar <mingo@...hat.com>, "H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] cpumask: use maxcpus=NUM to extend the cpu limit as well as restrict the limit

On Thursday 11 December 2008 21:58:09 Mike Travis wrote:
> Impact: allow adding additional cpus.
> 
> Use maxcpus=NUM kernel parameter to extend the number of possible cpus as well
> as (currently) limit them.  Any cpus >= number of present cpus will disabled.
...

These two bits of logic are very similar: can we merge them?

> -	possible = num_processors + disabled_cpus;
> -	if (possible > NR_CPUS)
> -		possible = NR_CPUS;
> +	if (setup_max_cpus == -1)	/* not specified */
> +		possible = num_processors + disabled_cpus;
> +	else if (setup_max_cpus == 0)	/* UP mode forced */
> +		possible = 1;
> +	else				/* user specified */
> +		possible = setup_max_cpus;
> +
> +	if (possible > CONFIG_NR_CPUS) {
> +		printk(KERN_WARNING
> +			"%d Processors exceeds NR_CPUS limit of %d\n",
> +			possible, CONFIG_NR_CPUS);
> +		possible = CONFIG_NR_CPUS;
> +	}
...
> -extern unsigned int setup_max_cpus;
> +extern int setup_max_cpus;
> +static inline int maxcpus(void)
> +{
> +	int maxcpus = setup_max_cpus;
> +
> +	if (maxcpus == -1 || maxcpus > CONFIG_NR_CPUS)
> +		maxcpus = CONFIG_NR_CPUS;
> +	else if (maxcpus == 0)
> +		maxcpus = 1;
> +
> +	return maxcpus;
> +}

If this didn't trunacte to CONFIG_NR_CPUS, it could still be used here:

> @@ -425,7 +423,7 @@ static void __init smp_init(void)
>  
>  	/* FIXME: This should be done in userspace --RR */
>  	for_each_present_cpu(cpu) {
> -		if (num_online_cpus() >= setup_max_cpus)
> +		if (num_online_cpus() >= maxcpus())
>  			break;
>  		if (!cpu_online(cpu))
>  			cpu_up(cpu);

And it turns out noone actually uses the smp_cpus_done() arg, so
I don't know what the semantics are supposed to be.

> @@ -433,7 +431,7 @@ static void __init smp_init(void)
>  
>  	/* Any cleanup work */
>  	printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
> -	smp_cpus_done(setup_max_cpus);
> +	smp_cpus_done(maxcpus());

Cheers,
Rusty.
--
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