diff mbox series

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

Message ID 20210928005558.243352-7-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show
Series genirq/affinity: abstract new API from managed irq affinity spread | expand

Commit Message

Ming Lei Sept. 28, 2021, 12:55 a.m. UTC
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 <ming.lei@redhat.com>
---
 lib/Makefile     |  2 +-
 lib/group_cpus.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Sept. 28, 2021, 5:27 a.m. UTC | #1
On Tue, Sep 28, 2021 at 08:55:57AM +0800, Ming Lei wrote:
> 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 <ming.lei@redhat.com>

I would hav folded this into the previous patch, but otherwise:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/lib/Makefile b/lib/Makefile
index ff1cbe4958a1..3dbdc7f01215 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -338,7 +338,7 @@  obj-$(CONFIG_SBITMAP) += sbitmap.o
 
 obj-$(CONFIG_PARMAN) += parman.o
 
-obj-$(CONFIG_SMP) += group_cpus.o
+obj-y += group_cpus.o
 
 # GCC library routines
 obj-$(CONFIG_GENERIC_LIB_ASHLDI3) += ashldi3.o
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);