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] [day] [month] [year] [list]
Date:   Thu, 11 Apr 2019 11:42:08 -0700
From:   Atish Patra <atish.patra@....com>
To:     Christoph Hellwig <hch@...radead.org>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Albert Ou <aou@...s.berkeley.edu>,
        Andreas Schwab <schwab@...e.de>,
        Anup Patel <anup@...infault.org>,
        Dmitriy Cherkasov <dmitriy@...-tech.org>,
        Johan Hovold <johan@...nel.org>,
        "linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
        Palmer Dabbelt <palmer@...ive.com>,
        Paul Walmsley <paul.walmsley@...ive.com>
Subject: Re: [PATCH v2 3/4] RISC-V: Implement nosmp commandline option.

On 4/11/19 12:01 AM, Christoph Hellwig wrote:
> On Wed, Apr 10, 2019 at 04:04:42PM -0700, Atish Patra wrote:
>> nosmp command line option sets max_cpus to zero. No secondary harts
>> will boot if this is enabled. But present cpu mask will still point to
>> all possible masks.
>>
>> Fix present cpu mask for nosmp usecase.
>>
>> Signed-off-by: Atish Patra <atish.patra@....com>
>> ---
>>   arch/riscv/kernel/smpboot.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
>> index eb533b5c2c8c..a8ad200581aa 100644
>> --- a/arch/riscv/kernel/smpboot.c
>> +++ b/arch/riscv/kernel/smpboot.c
>> @@ -47,6 +47,17 @@ void __init smp_prepare_boot_cpu(void)
>>   
>>   void __init smp_prepare_cpus(unsigned int max_cpus)
>>   {
>> +	int cpuid;
>> +
>> +	/* This covers non-smp usecase mandated by "nosmp" option */
>> +	if (max_cpus == 0)
>> +		return;
>> +
>> +	for_each_possible_cpu(cpuid) {
>> +		if (cpuid == smp_processor_id())
>> +			continue;
>> +		set_cpu_present(cpuid, true);
>> +	}
> 
> Most other architectures seem to use init_cpu_present() here.
> 

I did a quick grep through other archs. Mostly, init_cpu_present is 
preferred when you update a entire cpumask or cpu 0.
We can just use cpu_possible_mask and init_cpu_present together to avoid 
the loop. It will just set the current boot cpu bit once more.

But looking at ARM64 code, we may have to bring back the loop when we 
have some implementation similar cpu_ops.

Regards,
Atish

> Otherwise this looks fine to me.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ