Thread (9 messages) 9 messages, 2 authors, 2021-08-18
STALE1781d
Revisions (4)
  1. rfc [diff vs current]
  2. v1 [diff vs current]
  3. v2 current
  4. v3 [diff vs current]

[PATCH V2 6/7] lib/group_cpus: allow to group cpus in case of !CONFIG_SMP

From: Ming Lei <hidden>
Date: 2021-08-18 09:34:47
Also in: lkml
Subsystem: irq subsystem, library code, the rest · Maintainers: Thomas Gleixner, Andrew Morton, Linus Torvalds

Allows group_cpus_evenly() to be called in case of !CONFIG_SMP by simply
assigning all CPUs into the 1st group.

Signed-off-by: Ming Lei <redacted>
---
 lib/group_cpus.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/lib/group_cpus.c b/lib/group_cpus.c
index f7165b38c9d0..b34f7d309f9c 100644
--- a/lib/group_cpus.c
+++ b/lib/group_cpus.c
@@ -327,6 +327,7 @@ static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps,
 	return done;
 }
 
+#ifdef CONFIG_SMP
 /**
  * group_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality
  * @numgrps: number of groups
@@ -411,4 +412,17 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps)
 	}
 	return masks;
 }
+#else
+struct cpumask *group_cpus_evenly(unsigned int numgrps)
+{
+	struct cpumask *masks = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
+
+	if (!masks)
+		return NULL;
+
+	/* assign all CPUs(cpu 0) to the 1st group only */
+	cpumask_copy(&masks[0], cpu_possible_mask);
+	return masks;
+}
+#endif
 EXPORT_SYMBOL_GPL(group_cpus_evenly);
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help