diff mbox series

[v1,4/4] RISC-V: Support nr_cpus command line option.

Message ID 20190319222028.4293-4-atish.patra@wdc.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/4] RISC-V: Add RISC-V specific arch_match_cpu_phys_id | expand

Commit Message

Atish Patra March 19, 2019, 10:20 p.m. UTC
If nr_cpus command line option is set, maximum possible cpu should be
set to that value.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
 arch/riscv/kernel/smpboot.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Damien Le Moal March 19, 2019, 11:56 p.m. UTC | #1
On 2019/03/20 7:20, Atish Patra wrote:
> If nr_cpus command line option is set, maximum possible cpu should be
> set to that value.
> 
> Signed-off-by: Atish Patra <atish.patra@wdc.com>
> ---
>  arch/riscv/kernel/smpboot.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
> index 609475c5..a8fe590c 100644
> --- a/arch/riscv/kernel/smpboot.c
> +++ b/arch/riscv/kernel/smpboot.c
> @@ -86,11 +86,19 @@ void __init setup_smp(void)
>  		}
>  
>  		cpuid_to_hartid_map(cpuid) = hart;
> -		set_cpu_possible(cpuid, true);

This looks weird: the code being changed does not match what patch 3/4 did.

>  		cpuid++;
>  	}
>  
>  	BUG_ON(!found_boot_cpu);
> +
> +	if (cpuid > nr_cpu_ids)
> +		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",

"The total number of cpus [%d] is greater than nr_cpus option value [%d]\n"

> +			cpuid, nr_cpu_ids);
> +
> +	for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
> +		if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
> +			set_cpu_possible(cpuid, true);
> +	}
>  }
>  
>  int __cpu_up(unsigned int cpu, struct task_struct *tidle)
>
Damien Le Moal March 19, 2019, 11:58 p.m. UTC | #2
On 2019/03/20 8:56, Damien Le Moal wrote:
> On 2019/03/20 7:20, Atish Patra wrote:
>> If nr_cpus command line option is set, maximum possible cpu should be
>> set to that value.
>>
>> Signed-off-by: Atish Patra <atish.patra@wdc.com>
>> ---
>>  arch/riscv/kernel/smpboot.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
>> index 609475c5..a8fe590c 100644
>> --- a/arch/riscv/kernel/smpboot.c
>> +++ b/arch/riscv/kernel/smpboot.c
>> @@ -86,11 +86,19 @@ void __init setup_smp(void)
>>  		}
>>  
>>  		cpuid_to_hartid_map(cpuid) = hart;
>> -		set_cpu_possible(cpuid, true);
> 
> This looks weird: the code being changed does not match what patch 3/4 did.

Arg... Ignore this one. My bad. Morning here, I need more coffee :)

> 
>>  		cpuid++;
>>  	}
>>  
>>  	BUG_ON(!found_boot_cpu);
>> +
>> +	if (cpuid > nr_cpu_ids)
>> +		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",
> 
> "The total number of cpus [%d] is greater than nr_cpus option value [%d]\n"
> 
>> +			cpuid, nr_cpu_ids);
>> +
>> +	for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
>> +		if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
>> +			set_cpu_possible(cpuid, true);
>> +	}
>>  }
>>  
>>  int __cpu_up(unsigned int cpu, struct task_struct *tidle)
>>
> 
>
Atish Patra March 20, 2019, 1:29 a.m. UTC | #3
On 3/19/19 4:58 PM, Damien Le Moal wrote:
> On 2019/03/20 8:56, Damien Le Moal wrote:
>> On 2019/03/20 7:20, Atish Patra wrote:
>>> If nr_cpus command line option is set, maximum possible cpu should be
>>> set to that value.
>>>
>>> Signed-off-by: Atish Patra <atish.patra@wdc.com>
>>> ---
>>>   arch/riscv/kernel/smpboot.c | 10 +++++++++-
>>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
>>> index 609475c5..a8fe590c 100644
>>> --- a/arch/riscv/kernel/smpboot.c
>>> +++ b/arch/riscv/kernel/smpboot.c
>>> @@ -86,11 +86,19 @@ void __init setup_smp(void)
>>>   		}
>>>   
>>>   		cpuid_to_hartid_map(cpuid) = hart;
>>> -		set_cpu_possible(cpuid, true);
>>
>> This looks weird: the code being changed does not match what patch 3/4 did.
> 
> Arg... Ignore this one. My bad. Morning here, I need more coffee :)
> 
:).

>>
>>>   		cpuid++;
>>>   	}
>>>   
>>>   	BUG_ON(!found_boot_cpu);
>>> +
>>> +	if (cpuid > nr_cpu_ids)
>>> +		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",
>>
>> "The total number of cpus [%d] is greater than nr_cpus option value [%d]\n"
>>

ok. I will fix it in v2.

Regards,
Atish
>>> +			cpuid, nr_cpu_ids);
>>> +
>>> +	for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
>>> +		if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
>>> +			set_cpu_possible(cpuid, true);
>>> +	}
>>>   }
>>>   
>>>   int __cpu_up(unsigned int cpu, struct task_struct *tidle)
>>>
>>
>>
> 
>
diff mbox series

Patch

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 609475c5..a8fe590c 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -86,11 +86,19 @@  void __init setup_smp(void)
 		}
 
 		cpuid_to_hartid_map(cpuid) = hart;
-		set_cpu_possible(cpuid, true);
 		cpuid++;
 	}
 
 	BUG_ON(!found_boot_cpu);
+
+	if (cpuid > nr_cpu_ids)
+		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",
+			cpuid, nr_cpu_ids);
+
+	for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
+		if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
+			set_cpu_possible(cpuid, true);
+	}
 }
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)