diff mbox

[v2] arm64: Support hard limit of cpu count by nr_cpus

Message ID 1470636316-24552-1-git-send-email-wangkefeng.wang@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kefeng Wang Aug. 8, 2016, 6:05 a.m. UTC
Enable the hard limit of cpu count by set boot options nr_cpus=x
on arm64, and show a better warning when cpu number exceeds the limit.

Reported-by: Shiyuan Hu <hushiyuan@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---

Changed since v1:
- clip cpu number in smp_init_cpus suggested-by Will and Suzuki, and update
  the warning.

 arch/arm64/kernel/smp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Suzuki K Poulose Aug. 8, 2016, 10:50 a.m. UTC | #1
On 08/08/16 07:05, Kefeng Wang wrote:
> Enable the hard limit of cpu count by set boot options nr_cpus=x
> on arm64, and show a better warning when cpu number exceeds the limit.
>
> Reported-by: Shiyuan Hu <hushiyuan@huawei.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>
> Changed since v1:
> - clip cpu number in smp_init_cpus suggested-by Will and Suzuki, and update
>   the warning.
>
>  arch/arm64/kernel/smp.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 76a6d92..cbfc31c 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -661,9 +661,9 @@ void __init smp_init_cpus(void)
>  		acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
>  				      acpi_parse_gic_cpu_interface, 0);
>
> -	if (cpu_count > NR_CPUS)
> -		pr_warn("no. of cores (%d) greater than configured maximum of %d - clipping\n",
> -			cpu_count, NR_CPUS);
> +	if (cpu_count > nr_cpu_ids)
> +		pr_warn("%d cores exceeds configured maximum of %d - clipping\n",
> +			cpu_count, nr_cpu_ids);

I think we should leave the message as it was, and is better than what you have
changed it to.


With that change,

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Kefeng Wang Aug. 8, 2016, 11:28 a.m. UTC | #2
On 2016/8/8 18:50, Suzuki K Poulose wrote:
> On 08/08/16 07:05, Kefeng Wang wrote:
>> Enable the hard limit of cpu count by set boot options nr_cpus=x
>> on arm64, and show a better warning when cpu number exceeds the limit.
>>
>> Reported-by: Shiyuan Hu <hushiyuan@huawei.com>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>
>> Changed since v1:
>> - clip cpu number in smp_init_cpus suggested-by Will and Suzuki, and update
>>   the warning.
>>
>>  arch/arm64/kernel/smp.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
>> index 76a6d92..cbfc31c 100644
>> --- a/arch/arm64/kernel/smp.c
>> +++ b/arch/arm64/kernel/smp.c
>> @@ -661,9 +661,9 @@ void __init smp_init_cpus(void)
>>          acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
>>                        acpi_parse_gic_cpu_interface, 0);
>>
>> -    if (cpu_count > NR_CPUS)
>> -        pr_warn("no. of cores (%d) greater than configured maximum of %d - clipping\n",
>> -            cpu_count, NR_CPUS);
>> +    if (cpu_count > nr_cpu_ids)
>> +        pr_warn("%d cores exceeds configured maximum of %d - clipping\n",
>> +            cpu_count, nr_cpu_ids);
> 
> I think we should leave the message as it was, and is better than what you have
> changed it to.

The old message is OF only and the old logic shows message when the first cpu number greater than NR_CPUS.
But now the cpu_count is the total cpu counts(get from DT or ACPI), so I change the message.


> 
> 
> With that change,
> 
> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> 
> 
> .
>
Suzuki K Poulose Aug. 8, 2016, 12:52 p.m. UTC | #3
On 08/08/16 12:28, Kefeng Wang wrote:
>
>
> On 2016/8/8 18:50, Suzuki K Poulose wrote:
>> On 08/08/16 07:05, Kefeng Wang wrote:
>>> Enable the hard limit of cpu count by set boot options nr_cpus=x
>>> on arm64, and show a better warning when cpu number exceeds the limit.
>>>
>>> Reported-by: Shiyuan Hu <hushiyuan@huawei.com>
>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>> ---
>>>
>>> Changed since v1:
>>> - clip cpu number in smp_init_cpus suggested-by Will and Suzuki, and update
>>>   the warning.
>>>
>>>  arch/arm64/kernel/smp.c | 8 ++++----
>>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
>>> index 76a6d92..cbfc31c 100644
>>> --- a/arch/arm64/kernel/smp.c
>>> +++ b/arch/arm64/kernel/smp.c
>>> @@ -661,9 +661,9 @@ void __init smp_init_cpus(void)
>>>          acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
>>>                        acpi_parse_gic_cpu_interface, 0);
>>>
>>> -    if (cpu_count > NR_CPUS)
>>> -        pr_warn("no. of cores (%d) greater than configured maximum of %d - clipping\n",
>>> -            cpu_count, NR_CPUS);
>>> +    if (cpu_count > nr_cpu_ids)
>>> +        pr_warn("%d cores exceeds configured maximum of %d - clipping\n",
>>> +            cpu_count, nr_cpu_ids);
>>
>> I think we should leave the message as it was, and is better than what you have
>> changed it to.
>
> The old message is OF only and the old logic shows message when the first cpu number greater than NR_CPUS.

I think you misunderstood "of" (as in plain english) with OF (as in Open Firmware). To avoid
the confusion, how about making it :

"Number of cores (%d) exceeds configured maximum of %d - clipping\n" ?

Certainly a message like :

"5 cores exceeds configured maximum of %d..." doesn't look nice.


Suzuki

> But now the cpu_count is the total cpu counts(get from DT or ACPI), so I change the message.
>
>
>>
>>
>> With that change,
>>
>> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>
>>
>> .
>>
>
Kefeng Wang Aug. 9, 2016, 1:15 a.m. UTC | #4
On 2016/8/8 20:52, Suzuki K Poulose wrote:
> On 08/08/16 12:28, Kefeng Wang wrote:
>>
>>
>> On 2016/8/8 18:50, Suzuki K Poulose wrote:
>>> On 08/08/16 07:05, Kefeng Wang wrote:
>>>> Enable the hard limit of cpu count by set boot options nr_cpus=x
>>>> on arm64, and show a better warning when cpu number exceeds the limit.
>>>>
>>>> Reported-by: Shiyuan Hu <hushiyuan@huawei.com>
>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>>> ---
>>>>
>>>> Changed since v1:
>>>> - clip cpu number in smp_init_cpus suggested-by Will and Suzuki, and update
>>>>   the warning.
>>>>
>>>>  arch/arm64/kernel/smp.c | 8 ++++----
>>>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
>>>> index 76a6d92..cbfc31c 100644
>>>> --- a/arch/arm64/kernel/smp.c
>>>> +++ b/arch/arm64/kernel/smp.c
>>>> @@ -661,9 +661,9 @@ void __init smp_init_cpus(void)
>>>>          acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
>>>>                        acpi_parse_gic_cpu_interface, 0);
>>>>
>>>> -    if (cpu_count > NR_CPUS)
>>>> -        pr_warn("no. of cores (%d) greater than configured maximum of %d - clipping\n",
>>>> -            cpu_count, NR_CPUS);
>>>> +    if (cpu_count > nr_cpu_ids)
>>>> +        pr_warn("%d cores exceeds configured maximum of %d - clipping\n",
>>>> +            cpu_count, nr_cpu_ids);
>>>
>>> I think we should leave the message as it was, and is better than what you have
>>> changed it to.
>>
>> The old message is OF only and the old logic shows message when the first cpu number greater than NR_CPUS.
> 
> I think you misunderstood "of" (as in plain english) with OF (as in Open Firmware). To avoid
> the confusion, how about making it :
> 
> "Number of cores (%d) exceeds configured maximum of %d - clipping\n" ?

Er, I do misunderstood it, my bad, will use this one, thanks :)

Kefeng
> 
> Certainly a message like :
> 
> "5 cores exceeds configured maximum of %d..." doesn't look nice.
> 
> 
> Suzuki
> 
>> But now the cpu_count is the total cpu counts(get from DT or ACPI), so I change the message.
>>
>>
>>>
>>>
>>> With that change,
>>>
>>> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>>
>>>
>>> .
>>>
>>
> 
> 
> .
>
diff mbox

Patch

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 76a6d92..cbfc31c 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -661,9 +661,9 @@  void __init smp_init_cpus(void)
 		acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
 				      acpi_parse_gic_cpu_interface, 0);
 
-	if (cpu_count > NR_CPUS)
-		pr_warn("no. of cores (%d) greater than configured maximum of %d - clipping\n",
-			cpu_count, NR_CPUS);
+	if (cpu_count > nr_cpu_ids)
+		pr_warn("%d cores exceeds configured maximum of %d - clipping\n",
+			cpu_count, nr_cpu_ids);
 
 	if (!bootcpu_valid) {
 		pr_err("missing boot CPU MPIDR, not enabling secondaries\n");
@@ -677,7 +677,7 @@  void __init smp_init_cpus(void)
 	 * with entries in cpu_logical_map while initializing the cpus.
 	 * If the cpu set-up fails, invalidate the cpu_logical_map entry.
 	 */
-	for (i = 1; i < NR_CPUS; i++) {
+	for (i = 1; i < nr_cpu_ids; i++) {
 		if (cpu_logical_map(i) != INVALID_HWID) {
 			if (smp_cpu_setup(i))
 				cpu_logical_map(i) = INVALID_HWID;