All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree
@ 2020-01-17  1:52 Zeng Tao
  2020-01-17 10:19 ` Sudeep Holla
  0 siblings, 1 reply; 4+ messages in thread
From: Zeng Tao @ 2020-01-17  1:52 UTC (permalink / raw)
  To: sudeep.holla
  Cc: linuxarm, Zeng Tao, Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel

When the kernel is configured with CONFIG_NR_CPUS smaller than the
number of CPU nodes in the device tree(DT), all the CPU nodes parsing
done to fetch topology information will fail. This is not reasonable
as it is legal to have all the physical CPUs in the system in the DT.

Let us just skip such CPU DT nodes that are not used in the kernel
rather than returning an error.

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
---
Changelog:
v3->v4:
 -Fix the Review comments by sudeep, including subject, commit log, code
 comments, and also apply the stick the Review-by tag.
v2->v3:
 -Fix the Review comments by sudeep, including fix typo, remove redundant check
 logic, change the warning print level etc.
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 | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 5fe44b3..c175fe3 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -248,6 +248,16 @@ 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 basically three kinds of return values:
+ * (1) logic cpu number which is > 0.
+ * (2) -ENODEV when the device tree(DT) node is valid and found in the DT but
+ * there is no possible logical CPU in the kernel to match. This happens
+ * when CONFIG_NR_CPUS is configure to be smaller than the number of
+ * CPU nodes in DT. We need 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;
 	}
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree
  2020-01-17  1:52 [PATCH v4] cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree Zeng Tao
@ 2020-01-17 10:19 ` Sudeep Holla
  2020-01-17 14:21   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Sudeep Holla @ 2020-01-17 10:19 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Zeng Tao, linuxarm, Rafael J. Wysocki, Sudeep Holla, linux-kernel

On Fri, Jan 17, 2020 at 09:52:52AM +0800, Zeng Tao wrote:
> When the kernel is configured with CONFIG_NR_CPUS smaller than the
> number of CPU nodes in the device tree(DT), all the CPU nodes parsing
> done to fetch topology information will fail. This is not reasonable
> as it is legal to have all the physical CPUs in the system in the DT.
>
> Let us just skip such CPU DT nodes that are not used in the kernel
> rather than returning an error.
>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>

Hi Greg,

Can you pick this patch for v5.6 ?

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree
  2020-01-17 10:19 ` Sudeep Holla
@ 2020-01-17 14:21   ` Greg Kroah-Hartman
  2020-01-17 14:23     ` Sudeep Holla
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2020-01-17 14:21 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: Zeng Tao, linuxarm, Rafael J. Wysocki, linux-kernel

On Fri, Jan 17, 2020 at 10:19:57AM +0000, Sudeep Holla wrote:
> On Fri, Jan 17, 2020 at 09:52:52AM +0800, Zeng Tao wrote:
> > When the kernel is configured with CONFIG_NR_CPUS smaller than the
> > number of CPU nodes in the device tree(DT), all the CPU nodes parsing
> > done to fetch topology information will fail. This is not reasonable
> > as it is legal to have all the physical CPUs in the system in the DT.
> >
> > Let us just skip such CPU DT nodes that are not used in the kernel
> > rather than returning an error.
> >
> > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> > Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
> 
> Hi Greg,
> 
> Can you pick this patch for v5.6 ?

oops, didn't realize this was for me, sorry, will go do so now.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree
  2020-01-17 14:21   ` Greg Kroah-Hartman
@ 2020-01-17 14:23     ` Sudeep Holla
  0 siblings, 0 replies; 4+ messages in thread
From: Sudeep Holla @ 2020-01-17 14:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Zeng Tao, linuxarm, Rafael J. Wysocki, Sudeep Holla, linux-kernel

On Fri, Jan 17, 2020 at 03:21:35PM +0100, Greg Kroah-Hartman wrote:
> On Fri, Jan 17, 2020 at 10:19:57AM +0000, Sudeep Holla wrote:
> > On Fri, Jan 17, 2020 at 09:52:52AM +0800, Zeng Tao wrote:
> > > When the kernel is configured with CONFIG_NR_CPUS smaller than the
> > > number of CPU nodes in the device tree(DT), all the CPU nodes parsing
> > > done to fetch topology information will fail. This is not reasonable
> > > as it is legal to have all the physical CPUs in the system in the DT.
> > >
> > > Let us just skip such CPU DT nodes that are not used in the kernel
> > > rather than returning an error.
> > >
> > > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> > > Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
> >
> > Hi Greg,
> >
> > Can you pick this patch for v5.6 ?
>
> oops, didn't realize this was for me, sorry, will go do so now.
>

No worries, it just got baked this morning :). I just dropped you a note
before I could forget.

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-17 14:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17  1:52 [PATCH v4] cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree Zeng Tao
2020-01-17 10:19 ` Sudeep Holla
2020-01-17 14:21   ` Greg Kroah-Hartman
2020-01-17 14:23     ` Sudeep Holla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.