cpu-topology: Skip the exist but not possible cpu nodes
Subsystems (2)
PATCH v2 1/1 cpu-topology: Skip the exist but not possible cpu nodes
When CONFIG_NR_CPUS is smaller than the cpu nodes defined in the device tree, all the cpu nodes parsing will fail.
And this is not reasonable for a legal device tree configs. In this patch, skip such cpu nodes rather than return an error. With CONFIG_NR_CPUS = 128 and cpus nodes num in device tree is 130, The following warning messages will be print during boot:
CPU node for /cpus/cpu@128 exist but the possible cpu range is :0-127 CPU node for /cpus/cpu@129 exist but the possible cpu range is :0-127 CPU node for /cpus/cpu@130 exist but the possible cpu range is :0-127
---
Changelog:v1->v2:
-Remove redundant -ENODEV assignment in get_cpu_for_node -Add comment to describe the get_cpu_for_node return values -Add skip process for cpu threads
-Update the commit log with more detail
--- drivers/base/arch_topology.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/base/arch_topology.c +29 -8
@@ -248,22 +248,44 @@ core_initcall(free_raw_capacity);#endif #if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV ) +/* +* This function returns the logic cpu number of the node. +* There are totally three kinds of return values: +* (1) logic cpu number which is > 0. +* (2) -ENDEV when the node is valid one which can be found in the device tree +* but there is no possible cpu nodes to match, when the CONFIG_NR_CPUS is +* smaller than cpus node numbers in device tree, this will happen. It's +* suggested to just ignore this case. +* (3) -EINVAL when other errors occur. +*/ static int __init get_cpu_for_node (struct device_node *node) { -struct device_node *cpu_node; +struct device_node *cpu_node, *t;int cpu; +bool found = false; cpu_node =of_parse_phandle (node,"cpu" ,0 );if (!cpu_node) -return -1 ; +return -EINVAL ; + +for_each_of_cpu_node (t) +if (t == cpu_node) { + found = true; +break ; + } + +if (!found) { +pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); +return -EINVAL ; + } cpu =of_cpu_node_to_id (cpu_node);if (cpu >=0 )topology_parse_cpu_capacity (cpu_node, cpu);else -pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); +pr_warn ("CPU node for %pOF exist but the possible cpu range is :%*pbl\n" , + cpu_node,cpumask_pr_args (cpu_possible_mask)); -of_node_put (cpu_node);return cpu; }
@@ -286,9 +308,8 @@ static int __init parse_core(struct device_node *core, int package_id, cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; cpu_topology[cpu].thread_id = i; - }else { -pr_err ("%pOF: Can't get CPU for thread\n" , - t); + }else if (cpu != -ENODEV ) { +pr_err ("%pOF: Can't get CPU for thread\n" , t);of_node_put (t);return -EINVAL ; }
@@ -307,7 +328,7 @@ static int __init parse_core(struct device_node *core, int package_id, cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; - }else if (leaf) { + }else if (leaf && cpu != -ENODEV ) {pr_err ("%pOF: Can't get CPU for leaf core\n" , core);return -EINVAL ; }
Signature · 1 line
2.8.1
Quoted 28 lines · Zeng Tao
When
CONFIG_NR_CPUSis smaller than the cpu nodes defined in the device tree, all the cpu nodes parsing will fail.
And this is not reasonable for a legal device tree configs. In this patch, skip such cpu nodes rather than return an error. WithCONFIG_NR_CPUS= 128 and cpus nodes num in device tree is 130, The following warning messages will be print during boot:
CPU node for /cpus/cpu@128 exist but the possible cpu range is :0-127 CPU node for /cpus/cpu@129 exist but the possible cpu range is :0-127 CPU node for /cpus/cpu@130 exist but the possible cpu range is :0-127Signed-off-by Zeng Tao <[email protected]>---
Changelog:v1->v2:
-Remove redundant-ENODEVassignment inget_cpu_for_node-Add comment to describe theget_cpu_for_nodereturn values -Add skip process for cpu threads
-Update the commit log with more detail--- drivers/base/arch_topology.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)drivers/base/arch_topology.c +0
-0@@ -248,22 +248,44 @@ core_initcall(free_raw_capacity);#endif
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 258
Quoted 10 lines
drivers/base/arch_topology.c +8
-0#if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV ) +/* +* This function returns the logic cpu number of the node. +* There are totally three kinds of return values: +* (1) logic cpu number which is > 0. +* (2) -ENDEV when the node is valid one which can be found in the device tree +* but there is no possible cpu nodes to match, when the CONFIG_NR_CPUS is +* smaller than cpus node numbers in device tree, this will happen. It's +* suggested to just ignore this case.
s/ENDEV/ENODEV/
Also as I mentioned earlier, I prefer not to add any extra logic here other than the above comment to make it explicit. This triggers unnecessary warnings when someone boots with limited CPUs for valid reasons.
Quoted 24 lines
drivers/base/arch_topology.c +16
-2+* (3) -EINVAL when other errors occur. +*/ static int __init get_cpu_for_node (struct device_node *node) { -struct device_node *cpu_node; +struct device_node *cpu_node, *t;int cpu; +bool found = false; cpu_node =of_parse_phandle (node,"cpu" ,0 );if (!cpu_node) -return -1 ; +return -EINVAL ; + +for_each_of_cpu_node (t) +if (t == cpu_node) { + found = true; +break ; + } + +if (!found) { +pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); +return -EINVAL ; + }
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 266
Quoted 10 lines
drivers/base/arch_topology.c +2
-2cpu =of_cpu_node_to_id (cpu_node);if (cpu >=0 )topology_parse_cpu_capacity (cpu_node, cpu);else -pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); +pr_warn ("CPU node for %pOF exist but the possible cpu range is :%*pbl\n" , + cpu_node,cpumask_pr_args (cpu_possible_mask)); -of_node_put (cpu_node);
Why is this dropped ?
--
Regards,
Sudeep
Quoted 53 lines
-----Original Message-----
From: Sudeep Holla [mailto:[email protected]]
Sent: Monday, January 13, 2020 6:19 PM
To: Zengtao (B)
Cc: Linuxarm; Greg Kroah-Hartman; Rafael J. Wysocki; Sudeep Holla; [email protected]
Subject: Re: [PATCH v2] cpu-topology: Skip the exist but not possible cpu nodesQuoted 1 line · Zeng Tao
When
CONFIG_NR_CPUSis smaller than the cpu nodes defined in thedevice
Quoted 4 lines
tree, all the cpu nodes parsing will fail.
And this is not reasonable for a legal device tree configs. In this patch, skip such cpu nodes rather than return an error. WithCONFIG_NR_CPUS= 128 and cpus nodes num in device tree is130,
Quoted 2 lines
The following warning messages will be print during boot:
CPU node for /cpus/cpu@128 exist but the possible cpu rangeis :0-127
Quoted 1 line
CPU node for /cpus/cpu@129 exist but the possible cpu range
is :0-127
Quoted 1 line
CPU node for /cpus/cpu@130 exist but the possible cpu range
is :0-127
Quoted 11 lines
Signed-off-by Zeng Tao <[email protected]>---
Changelog:v1->v2:
-Remove redundant-ENODEVassignment inget_cpu_for_node-Add comment to describe theget_cpu_for_nodereturn values -Add skip process for cpu threads
-Update the commit log with more detail--- drivers/base/arch_topology.c | 37+++++++++++++++++++++++++++++--------
Review
Quoted 3 lines
1 file changed, 29 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/drivers/base/arch_topology.cdrivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 255
Quoted 12 lines
index 5fe44b3..01f0e21 100644
drivers/base/arch_topology.c +5
-0@@ -248,22 +248,44 @@ core_initcall(free_raw_capacity);#endif #if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV ) +/* +* This function returns the logic cpu number of the node. +* There are totally three kinds of return values: +* (1) logic cpu number which is > 0. +* (2) -ENDEV when the node is valid one which can be found in the device tree
Quoted 7 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 256
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* but there is no possible cpu nodes to match, when the
CONFIG_NR_CPUSisdrivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 257
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* smaller than cpus node numbers in device tree, this will happen. It's
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 258
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* suggested to just ignore this case. s/ENDEV/ENODEV/
Good catch, thanks.
Quoted 6 lines
Also as I mentioned earlier, I prefer not to add any extra logic here other than the above comment to make it explicit. This triggers unnecessary
warnings when someone boots with limited CPUs for valid reasons.
So , what 's your suggestion here? Just keep the comments but remove
the warning message print?
Quoted 33 lines
Quoted 22 lines
drivers/base/arch_topology.c +13
-2+* (3) -EINVAL when other errors occur. +*/ static int __init get_cpu_for_node (struct device_node *node) { -struct device_node *cpu_node; +struct device_node *cpu_node, *t;int cpu; +bool found = false; cpu_node =of_parse_phandle (node,"cpu" ,0 );if (!cpu_node) -return -1 ; +return -EINVAL ; + +for_each_of_cpu_node (t) +if (t == cpu_node) { + found = true; +break ; + } + +if (!found) {drivers/base/arch_topology.c core_initcall(free_raw_capacity);
Quoted 10 lines
drivers/base/arch_topology.c +4
-1+pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); +return -EINVAL ; + } cpu =of_cpu_node_to_id (cpu_node);if (cpu >=0 )topology_parse_cpu_capacity (cpu_node, cpu);else -pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); + pr_warn("CPU node for %pOF exist but the possible cpu rangeis :%*pbl\n",
Quoted 5 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 266
Quoted 3 lines
drivers/base/arch_topology.c +1
-1+ cpu_node, cpumask_pr_args(cpu_possible_mask)); -of_node_put (cpu_node);Why is this dropped ?
It's unnecessary here since no one get the node ref.
Regards
Zengtao
Quoted 63 lines · Zengtao (B)
Quoted 53 lines
-----Original Message-----
From: Sudeep Holla [mailto:[email protected]]
Sent: Monday, January 13, 2020 6:19 PM
To: Zengtao (B)
Cc: Linuxarm; Greg Kroah-Hartman; Rafael J. Wysocki; Sudeep Holla; [email protected]
Subject: Re: [PATCH v2] cpu-topology: Skip the exist but not possible cpu nodesQuoted 1 line · Zeng Tao
When
CONFIG_NR_CPUSis smaller than the cpu nodes defined in thedevice
Quoted 4 lines
tree, all the cpu nodes parsing will fail.
And this is not reasonable for a legal device tree configs. In this patch, skip such cpu nodes rather than return an error. WithCONFIG_NR_CPUS= 128 and cpus nodes num in device tree is130,
Quoted 2 lines
The following warning messages will be print during boot:
CPU node for /cpus/cpu@128 exist but the possible cpu rangeis :0-127
Quoted 1 line
CPU node for /cpus/cpu@129 exist but the possible cpu range
is :0-127
Quoted 1 line
CPU node for /cpus/cpu@130 exist but the possible cpu range
is :0-127
Quoted 11 lines
Signed-off-by Zeng Tao <[email protected]>---
Changelog:v1->v2:
-Remove redundant-ENODEVassignment inget_cpu_for_node-Add comment to describe theget_cpu_for_nodereturn values -Add skip process for cpu threads
-Update the commit log with more detail--- drivers/base/arch_topology.c | 37+++++++++++++++++++++++++++++--------
Review
Quoted 3 lines
1 file changed, 29 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/drivers/base/arch_topology.cdrivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 255
Quoted 12 lines
index 5fe44b3..01f0e21 100644
drivers/base/arch_topology.c +5
-0@@ -248,22 +248,44 @@ core_initcall(free_raw_capacity);#endif #if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV ) +/* +* This function returns the logic cpu number of the node. +* There are totally three kinds of return values: +* (1) logic cpu number which is > 0. +* (2) -ENDEV when the node is valid one which can be found in the device tree
Quoted 7 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 256
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* but there is no possible cpu nodes to match, when the
CONFIG_NR_CPUSisdrivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 257
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* smaller than cpus node numbers in device tree, this will happen. It's
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 258
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* suggested to just ignore this case. s/ENDEV/ENODEV/
Good catch, thanks.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Also as I mentioned earlier, I prefer not to add any extra logic here other than the above comment to make it explicit. This triggers unnecessary
warnings when someone boots with limited CPUs for valid reasons.So , what 's your suggestion here? Just keep the comments but remove
the warning message print?
Yes for all the "found" logic. I am fine to update the existing err
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/base/arch_topology.c +4
-1+* (3) -EINVAL when other errors occur. +*/ static int __init get_cpu_for_node (struct device_node *node) { -struct device_node *cpu_node; +struct device_node *cpu_node, *t;int cpu; +bool found = false;
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
drivers/base/arch_topology.c +4
-1cpu_node =of_parse_phandle (node,"cpu" ,0 );if (!cpu_node) -return -1 ; +return -EINVAL ; + +for_each_of_cpu_node (t) +if (t == cpu_node) {Quoted 8 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 280
Quoted 8 lines
drivers/base/arch_topology.c +8
-0+ found = true; +break ; + } + +if (!found) { +pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); +return -EINVAL ; + }
Drop all the above change.
Quoted 4 lines
Quoted 4 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 284
Quoted 4 lines
drivers/base/arch_topology.c +0
-0cpu =of_cpu_node_to_id (cpu_node);if (cpu >=0 )topology_parse_cpu_capacity (cpu_node, cpu);
You can add here: else if (cpu == -ENODEV)
pr_info(...whatever you have below..)
Other things as is. Warning may be too harsh if one is running with reduced number of CPUs.
Quoted 4 lines
Quoted 4 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity);
Quoted 3 lines
drivers/base/arch_topology.c +1
-1else -pr_crit ("Unable to find CPU node for %pOF\n" , cpu_node); + pr_warn("CPU node for %pOF exist but the possible cpu rangeis :%*pbl\n",
Quoted 8 lines
Quoted 5 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 266
Quoted 3 lines
drivers/base/arch_topology.c +1
-1+ cpu_node, cpumask_pr_args(cpu_possible_mask)); -of_node_put (cpu_node);Why is this dropped ?
It's unnecessary here since no one get the node ref.
Please read the description of of_parse_phandle. If you find other issues with existing code, address it in separate patch and don't mix with the issue in $subject.
--
Regards,
Sudeep
Quoted 84 lines
-----Original Message-----
From: Sudeep Holla [mailto:[email protected]]
Sent: Monday, January 13, 2020 8:21 PM
To: Zengtao (B)
Cc: Linuxarm; Greg Kroah-Hartman; Rafael J. Wysocki; Sudeep Holla; [email protected]
Subject: Re: [PATCH v2] cpu-topology: Skip the exist but not possible cpu nodesQuoted 7 lines · Zengtao (B)
Quoted 7 lines
-----Original Message-----
From: Sudeep Holla [mailto:[email protected]]
Sent: Monday, January 13, 2020 6:19 PM
To: Zengtao (B)
Cc: Linuxarm; Greg Kroah-Hartman; Rafael J. Wysocki; Sudeep Holla; [email protected]
Subject: Re: [PATCH v2] cpu-topology: Skip the exist but not possiblecpu
Quoted 4 lines
Quoted 4 lines
nodes
Quoted 1 line · Zeng Tao
When
CONFIG_NR_CPUSis smaller than the cpu nodes defined inthe
Quoted 5 lines
Quoted 5 lines
device
Quoted 4 lines
tree, all the cpu nodes parsing will fail.
And this is not reasonable for a legal device tree configs. In this patch, skip such cpu nodes rather than return an error. WithCONFIG_NR_CPUS= 128 and cpus nodes num in device treeis
Quoted 30 lines
Quoted 30 lines
130,
Quoted 2 lines
The following warning messages will be print during boot:
CPU node for /cpus/cpu@128 exist but the possible cpu rangeis :0-127
Quoted 1 line
CPU node for /cpus/cpu@129 exist but the possible cpu range
is :0-127
Quoted 1 line
CPU node for /cpus/cpu@130 exist but the possible cpu range
is :0-127
Quoted 11 lines
Signed-off-by Zeng Tao <[email protected]>---
Changelog:v1->v2:
-Remove redundant-ENODEVassignment inget_cpu_for_node-Add comment to describe theget_cpu_for_nodereturn values -Add skip process for cpu threads
-Update the commit log with more detail--- drivers/base/arch_topology.c | 37+++++++++++++++++++++++++++++--------
Review
Quoted 3 lines
1 file changed, 29 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/drivers/base/arch_topology.cQuoted 6 lines
index 5fe44b3..01f0e21 100644
drivers/base/arch_topology.c +0
-0@@ -248,22 +248,44 @@ core_initcall(free_raw_capacity);#endif Quoted 6 lines
Quoted 6 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity);
Quoted 6 lines
drivers/base/arch_topology.c +5
-0#if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV ) +/* +* This function returns the logic cpu number of the node. +* There are totally three kinds of return values: +* (1) logic cpu number which is > 0. +* (2) -ENDEV when the node is valid one which can be found in the
Quoted 4 lines
Quoted 4 lines
device tree
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 256
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* but there is no possible cpu nodes to match, when the
CONFIG_NR_CPUSisQuoted 1 line
drivers/base/arch_topology.c +1
-0+* smaller than cpus node numbers in device tree, this will happen.
Quoted 13 lines
Quoted 4 lines
It's
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 258
Quoted 1 line
drivers/base/arch_topology.c +1
-0+* suggested to just ignore this case. s/ENDEV/ENODEV/
Good catch, thanks.
Quoted 6 lines
Also as I mentioned earlier, I prefer not to add any extra logic here other than the above comment to make it explicit. This triggers unnecessary
warnings when someone boots with limited CPUs for valid reasons.
Quoted 5 lines
Quoted 2 lines
So , what 's your suggestion here? Just keep the comments but remove
the warning message print?Yes for all the "found" logic. I am fine to update the existing err
Find, I will take it.
.
Quoted 24 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/base/arch_topology.c +4
-1+* (3) -EINVAL when other errors occur. +*/ static int __init get_cpu_for_node (struct device_node *node) { -struct device_node *cpu_node; +struct device_node *cpu_node, *t;int cpu; +bool found = false;Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/base/arch_topology.c +2
-1cpu_node =of_parse_phandle (node,"cpu" ,0 );if (!cpu_node) -return -1 ; +return -EINVAL ; +Quoted 8 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity);
Quoted 8 lines
drivers/base/arch_topology.c +8
-0+for_each_of_cpu_node (t) +if (t == cpu_node) { + found = true; +break ; + } + +if (!found) { + pr_crit("Unable to find CPU node for %pOF\n",
cpu_node);
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 280
Quoted 2 lines
drivers/base/arch_topology.c +2
-0+return -EINVAL ; + }Drop all the above change.
Could you help to explain here?
I understand there are two abnormal cases:
1. The cpu node exist in the device tree, but not a possible cpu. This case can be caught by of_cpu_node_to_id's return value.
2. The cpu node does not exist.
This case can be caught by above logic. Or do you think of_parse_phandle's return value is enough?
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 284
Quoted 5 lines
drivers/base/arch_topology.c +0
-0cpu =of_cpu_node_to_id (cpu_node);if (cpu >=0 )topology_parse_cpu_capacity (cpu_node, cpu);You can add here: else if (cpu ==
-ENODEV)
pr_info(...whatever you have below..)Other things as is. Warning may be too harsh if one is running with reduced number of CPUs.
Quoted 2 lines
Quoted 2 lines
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 263
Quoted 2 lines
drivers/base/arch_topology.c +0
-1else - pr_crit("Unable to find CPU node for %pOF\n",
cpu_node);Quoted 1 line
Quoted 1 line
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 285
Quoted 1 line
drivers/base/arch_topology.c +1
-0+ pr_warn("CPU node for %pOF exist but the possible cpurange
Quoted 7 lines
Quoted 6 lines
is :%*pbl\n",
drivers/base/arch_topology.c core_initcall(free_raw_capacity); · line 266
Quoted 3 lines
drivers/base/arch_topology.c +1
-1+ cpu_node, cpumask_pr_args(cpu_possible_mask)); -of_node_put (cpu_node);Why is this dropped ?
Quoted 7 lines
Quoted 2 lines
It's unnecessary here since no one get the node ref.
Please read the description of
of_parse_phandle. If you find other issues with existing code, address it in separate patch and don't mix with the issue in $subject.
^_^, got it , will remove, Thanks
Regards
Zengtao
Quoted 4 lines · Zengtao (B)
Could you help to explain here?
I understand there are two abnormal cases:
1. The cpu node exist in the device tree, but not a possible cpu. This case can be caught by of_cpu_node_to_id's return value.
Yes if of_cpu_node_to_id returns -ENODEV, it means there's no logical CPU associated with this DT node.
Quoted 2 lines
2. The cpu node does not exist. This case can be caught by above logic. Or do you think of_parse_phandle's return value is enough?
Again yes, there's nothing extra needed.
The only change you need is to consider -ENODEV while handling the case(1)
--
Regards,
Sudeep
Quoted 18 lines
-----Original Message-----
From: Sudeep Holla [mailto:[email protected]]
Sent: Tuesday, January 14, 2020 6:30 PM
To: Zengtao (B)
Cc: Linuxarm; Greg Kroah-Hartman; Rafael J. Wysocki; [email protected]; Sudeep Holla
Subject: Re: [PATCH v2] cpu-topology: Skip the exist but not possible cpu nodesQuoted 4 lines · Zengtao (B)
Could you help to explain here?
I understand there are two abnormal cases:
1. The cpu node exist in the device tree, but not a possible cpu. This case can be caught by of_cpu_node_to_id's return value.Yes if
of_cpu_node_to_idreturns-ENODEV, it means there's no logical CPU associated with this DT node.
Quoted 9 lines
Quoted 1 line
2. The cpu node does not exist. This case can be caught by above logic.
Or
Quoted 1 line
do you think of_parse_phandle's return value is enough?
Again yes, there's nothing extra needed.
The only change you need is to consider
-ENODEVwhile handling the case(1)
Thanks very much for your explanation.
So finally it turns into a very simple patch like this, more cleaner:
+/*
+ * This function returns the logic cpu number of the node.
+ * There are basically three kinds of return values:
+ * (1) logic cpu number which is > 0.
+ * (2) -ENDEV when the node is valid one which can be found in the device tree
+ * but there is no possible cpu nodes to match, when the CONFIG_NR_CPUS is
+ * smaller than cpus node numbers in device tree, this will happen. It's
+ * suggested to just ignore this case.
+ * (3) -1 if the node does not exist in the device tree
+ */
static int __init get_cpu_for_node(struct device_node *node)
{
struct device_node *cpu_node;
@@ -261,7 +271,8 @@ static int __init get_cpu_for_node(struct device_node *node)
if (cpu >= 0)
topology_parse_cpu_capacity(cpu_node, cpu);
else- pr_crit("Unable to find CPU node for %pOF\n", cpu_node);
+ pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n",
+ cpu_node, cpumask_pr_args(cpu_possible_mask));
of_node_put(cpu_node);
return cpu;
@@ -286,9 +297,8 @@ static int __init parse_core(struct device_node *core, int package_id,
cpu_topology[cpu].package_id = package_id;
cpu_topology[cpu].core_id = core_id;
cpu_topology[cpu].thread_id = i;- } else {
- pr_err("%pOF: Can't get CPU for thread\n",
- t);
+ } else if (cpu != -ENODEV) {
+ pr_err("%pOF: Can't get CPU for thread\n", t);
of_node_put(t);
return -EINVAL;
}@@ -307,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id,
cpu_topology[cpu].package_id = package_id;
cpu_topology[cpu].core_id = core_id;
- } else if (leaf) {
+ } else if (leaf && cpu != -ENODEV) {
pr_err("%pOF: Can't get CPU for leaf core\n", core);
return -EINVAL;
}Any more suggestions?
Regards
Zengtao
On Tue, Jan 14, 2020 at 12:17:41PM +0000, Zengtao (B) wrote:
[...]
Quoted 7 lines
Thanks very much for your explanation.
So finally it turns into a very simple patch like this, more cleaner:
+/*
+ * This function returns the logic cpu number of the node.
+ * There are basically three kinds of return values:
+ * (1) logic cpu number which is > 0.
+ * (2)-ENDEVwhen the node is valid one which can be found in the device tree
s/ENDEV/ENODEV/ again :)
Quoted 40 lines
+ * but there is no possible cpu nodes to match, when the
CONFIG_NR_CPUSis
+ * smaller than cpus node numbers in device tree, this will happen. It's
+ * suggested to just ignore this case.
+ * (3) -1 if the node does not exist in the device tree
+ */
static int__initget_cpu_for_node(struct device_node *node){ struct device_node *cpu_node;(quoted diff) +5
-5@@ -261,7 +271,8 @@ static int __init get_cpu_for_node(struct device_node *node) if (cpu >= 0) topology_parse_cpu_capacity(cpu_node, cpu); else - pr_crit("Unable to find CPU node for %pOF\n", cpu_node); + pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n", + cpu_node, cpumask_pr_args(cpu_possible_mask)); of_node_put(cpu_node); return cpu;@@ -286,9 +297,8 @@ static int __init parse_core(struct device_node *core, int package_id, cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; cpu_topology[cpu].thread_id = i; - } else { - pr_err("%pOF: Can't get CPU for thread\n", - t); + } else if (cpu != -ENODEV) { + pr_err("%pOF: Can't get CPU for thread\n", t); of_node_put(t); return -EINVAL; }@@ -307,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id, cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; - } else if (leaf) { + } else if (leaf && cpu != -ENODEV) { pr_err("%pOF: Can't get CPU for leaf core\n", core); return -EINVAL; }
Quoted 1 line
Any more suggestions?
None except the above minor nit. I will wait for v3 before I give ack/review tag. Thanks for the patience.
--
Regards,
Sudeep