Skip to contentSkip to conversation

sched fixes

PATCH Applied Yury Norov 2 participants 15 messages Aug 19, 2023 – Sep 15, 2023

Subsystems (5)
lore
Share & tools
lore

Yury Norov

author maintainer
#0 lore raw

v2 cover sched fixes

Fixes for recently introduced sched_numa_find_nth_cpu(), and minor improvements in sched/fair.

v1: https://lore.kernel.org/lkml/[email protected]/T/
v2:
- fix wording in commit messages;
- move nearest node search inside rcu lock section in sched_numa_find_nth_cpu();
- move NUMA_NO_NODE handling inside sched_numa_find_nth_cpu();
- rewrite comment for sched_numa_find_nth_cpu().
- add review tag from Yicong Yang.

Yury Norov (6):
numa: generalize numa_map_to_online_node() sched/fair: fix opencoded numa_nearest_node()
sched: fix sched_numa_find_nth_cpu() in CPU-less case
sched: fix sched_numa_find_nth_cpu() in non-NUMA case
sched: handle NUMA_NO_NODE in sched_numa_find_nth_cpu()
sched: fix sched_numa_find_nth_cpu() comment

 include/linux/numa.h     |  7 +++++--
 include/linux/topology.h |  2 +-
 kernel/sched/fair.c      | 14 +-------------
 kernel/sched/topology.c  | 25 +++++++++++++++++--------
 lib/cpumask.c            |  4 +---
 mm/mempolicy.c           | 18 +++++++++++-------
 6 files changed, 36 insertions(+), 34 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v2 1/6 numa: generalize numa_map_to_online_node()

The function in fact searches the nearest node for a given one, based on a N_ONLINE state. This is a common pattern to search for a nearest node.

This patch converts numa_map_to_online_node() to numa_nearest_node() so that others won't need to opencode the logic.

---
 include/linux/numa.h |  7 +++++--
 mm/mempolicy.c       | 18 +++++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)
include/linux/numa.h +5 -2
index 59df211d051f..fb30a42f0700 100644
@@ -25,7 +25,7 @@
 #include <asm/sparsemem.h>
 
 /* Generic implementation available */
-int numa_map_to_online_node(int node);
+int numa_nearest_node(int node, unsigned int state);
 
 #ifndef memory_add_physaddr_to_nid
 static inline int memory_add_physaddr_to_nid(u64 start)
@@ -44,10 +44,11 @@ static inline int phys_to_target_node(u64 start)
 }
 #endif
 #else /* !CONFIG_NUMA */
-static inline int numa_map_to_online_node(int node)
+static inline int numa_nearest_node(int node, unsigned int state)
 {
 	return NUMA_NO_NODE;
 }
+
 static inline int memory_add_physaddr_to_nid(u64 start)
 {
 	return 0;
@@ -58,6 +59,8 @@ static inline int phys_to_target_node(u64 start)
 }
 #endif
 
+#define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE)
+
 #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
 extern const struct attribute_group arch_node_dev_group;
 #endif
mm/mempolicy.c +11 -7
index c53f8beeb507..0fc9a3b1d765 100644
@@ -131,22 +131,26 @@ static struct mempolicy default_policy = {
 static struct mempolicy preferred_node_policy[MAX_NUMNODES];
 
 /**
- * numa_map_to_online_node - Find closest online node
+ * numa_nearest_node - Find nearest node by state
  * @node: Node id to start the search
+ * @state: State to filter the search
  *
- * Lookup the next closest node by distance if @nid is not online.
+ * Lookup the closest node by distance if @nid is not in state.
  *
- * Return: this @node if it is online, otherwise the closest node by distance
+ * Return: this @node if it is in state, otherwise the closest node by distance
  */
-int numa_map_to_online_node(int node)
+int numa_nearest_node(int node, unsigned int state)
 {
 	int min_dist = INT_MAX, dist, n, min_node;
 
-	if (node == NUMA_NO_NODE || node_online(node))
+	if (state >= NR_NODE_STATES)
+		return -EINVAL;
+
+	if (node == NUMA_NO_NODE || node_state(node, state))
 		return node;
 
 	min_node = node;
-	for_each_online_node(n) {
+	for_each_node_state(n, state) {
 		dist = node_distance(node, n);
 		if (dist < min_dist) {
 			min_dist = dist;
@@ -156,7 +160,7 @@ int numa_map_to_online_node(int node)
 
 	return min_node;
 }
-EXPORT_SYMBOL_GPL(numa_map_to_online_node);
+EXPORT_SYMBOL_GPL(numa_nearest_node);
 
 struct mempolicy *get_task_policy(struct task_struct *p)
 {
Signature · 1 line
2.39.2
merge bot Applied
#2 lore raw

[tip: sched/core] numa: Generalize numa_map_to_online_node()

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     b1f099b1cf51d553c510c6c8141c27d9ba7ea1fe
Gitweb:        https://git.kernel.org/tip/b1f099b1cf51d553c510c6c8141c27d9ba7ea1fe
Author:        Yury Norov <[email protected]>
AuthorDate:    Sat, 19 Aug 2023 07:12:33 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Fri, 15 Sep 2023 13:48:09 +02:00

numa: Generalize numa_map_to_online_node()

The function in fact searches the nearest node for a given one, based on a N_ONLINE state. This is a common pattern to search for a nearest node.

This patch converts numa_map_to_online_node() to numa_nearest_node() so that others won't need to opencode the logic.

---
 include/linux/numa.h |  7 +++++--
 mm/mempolicy.c       | 18 +++++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)
include/linux/numa.h +5 -2
index 59df211..fb30a42 100644
@@ -25,7 +25,7 @@
 #include <asm/sparsemem.h>
 
 /* Generic implementation available */
-int numa_map_to_online_node(int node);
+int numa_nearest_node(int node, unsigned int state);
 
 #ifndef memory_add_physaddr_to_nid
 static inline int memory_add_physaddr_to_nid(u64 start)
@@ -44,10 +44,11 @@ static inline int phys_to_target_node(u64 start)
 }
 #endif
 #else /* !CONFIG_NUMA */
-static inline int numa_map_to_online_node(int node)
+static inline int numa_nearest_node(int node, unsigned int state)
 {
 	return NUMA_NO_NODE;
 }
+
 static inline int memory_add_physaddr_to_nid(u64 start)
 {
 	return 0;
@@ -58,6 +59,8 @@ static inline int phys_to_target_node(u64 start)
 }
 #endif
 
+#define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE)
+
 #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
 extern const struct attribute_group arch_node_dev_group;
 #endif
mm/mempolicy.c +11 -7
index 42b5567..d4c0fff 100644
@@ -131,22 +131,26 @@ static struct mempolicy default_policy = {
 static struct mempolicy preferred_node_policy[MAX_NUMNODES];
 
 /**
- * numa_map_to_online_node - Find closest online node
+ * numa_nearest_node - Find nearest node by state
  * @node: Node id to start the search
+ * @state: State to filter the search
  *
- * Lookup the next closest node by distance if @nid is not online.
+ * Lookup the closest node by distance if @nid is not in state.
  *
- * Return: this @node if it is online, otherwise the closest node by distance
+ * Return: this @node if it is in state, otherwise the closest node by distance
  */
-int numa_map_to_online_node(int node)
+int numa_nearest_node(int node, unsigned int state)
 {
 	int min_dist = INT_MAX, dist, n, min_node;
 
-	if (node == NUMA_NO_NODE || node_online(node))
+	if (state >= NR_NODE_STATES)
+		return -EINVAL;
+
+	if (node == NUMA_NO_NODE || node_state(node, state))
 		return node;
 
 	min_node = node;
-	for_each_online_node(n) {
+	for_each_node_state(n, state) {
 		dist = node_distance(node, n);
 		if (dist < min_dist) {
 			min_dist = dist;
@@ -156,7 +160,7 @@ int numa_map_to_online_node(int node)
 
 	return min_node;
 }
-EXPORT_SYMBOL_GPL(numa_map_to_online_node);
+EXPORT_SYMBOL_GPL(numa_nearest_node);
 
 struct mempolicy *get_task_policy(struct task_struct *p)
 {
author maintainer
#3 lore raw

PATCH v2 2/6 sched/fair: fix opencoded numa_nearest_node()

In reply to Yury Norov

task_numa_placement() searches for a nearest node to migrate by calling for_each_node_state(). Now that we have numa_nearest_node(), switch to using it.

---
 kernel/sched/fair.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
kernel/sched/fair.c +1 -13
index b3e25be58e2b..e7b7cf87937b 100644
@@ -2645,19 +2645,7 @@ static void task_numa_placement(struct task_struct *p)
 	}
 
 	/* Cannot migrate task to CPU-less node */
-	if (max_nid != NUMA_NO_NODE && !node_state(max_nid, N_CPU)) {
-		int near_nid = max_nid;
-		int distance, near_distance = INT_MAX;
-
-		for_each_node_state(nid, N_CPU) {
-			distance = node_distance(max_nid, nid);
-			if (distance < near_distance) {
-				near_nid = nid;
-				near_distance = distance;
-			}
-		}
-		max_nid = near_nid;
-	}
+	max_nid = numa_nearest_node(max_nid, N_CPU);
 
 	if (ng) {
 		numa_group_count_active_nodes(ng);
Signature · 1 line
2.39.2
merge bot Applied
#4 lore raw

[tip: sched/core] sched/fair: Fix open-coded numa_nearest_node()

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     d1db9fb432d50b0eecdfdd85d17cc15a59cc093b
Gitweb:        https://git.kernel.org/tip/d1db9fb432d50b0eecdfdd85d17cc15a59cc093b
Author:        Yury Norov <[email protected]>
AuthorDate:    Sat, 19 Aug 2023 07:12:34 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Fri, 15 Sep 2023 13:48:10 +02:00

sched/fair: Fix open-coded numa_nearest_node()

task_numa_placement() searches for a nearest node to migrate by calling for_each_node_state(). Now that we have numa_nearest_node(), switch to using it.

---
 kernel/sched/fair.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
kernel/sched/fair.c +1 -13
index 8dbff6e..41cfd61 100644
@@ -2847,19 +2847,7 @@ static void task_numa_placement(struct task_struct *p)
 	}
 
 	/* Cannot migrate task to CPU-less node */
-	if (max_nid != NUMA_NO_NODE && !node_state(max_nid, N_CPU)) {
-		int near_nid = max_nid;
-		int distance, near_distance = INT_MAX;
-
-		for_each_node_state(nid, N_CPU) {
-			distance = node_distance(max_nid, nid);
-			if (distance < near_distance) {
-				near_nid = nid;
-				near_distance = distance;
-			}
-		}
-		max_nid = near_nid;
-	}
+	max_nid = numa_nearest_node(max_nid, N_CPU);
 
 	if (ng) {
 		numa_group_count_active_nodes(ng);
author maintainer
#5 lore raw

PATCH v2 3/6 sched: fix sched_numa_find_nth_cpu() in CPU-less case

In reply to Yury Norov

When the node provided by user is CPU-less, corresponding record in sched_domains_numa_masks is not set. Trying to dereference it in the following code leads to kernel crash.

To avoid it, start searching from the nearest node with CPUs.

---
 kernel/sched/topology.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/sched/topology.c +5 -1
index d3a3b2646ec4..c6e89afa0d65 100644
@@ -2113,12 +2113,16 @@ static int hop_cmp(const void *a, const void *b)
  */
 int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
-	struct __cmp_key k = { .cpus = cpus, .node = node, .cpu = cpu };
+	struct __cmp_key k = { .cpus = cpus, .cpu = cpu };
 	struct cpumask ***hop_masks;
 	int hop, ret = nr_cpu_ids;
 
 	rcu_read_lock();
 
+	/* CPU-less node entries are uninitialized in sched_domains_numa_masks */
+	node = numa_nearest_node(node, N_CPU);
+	k.node = node;
+
 	k.masks = rcu_dereference(sched_domains_numa_masks);
 	if (!k.masks)
 		goto unlock;
Signature · 1 line
2.39.2
merge bot Applied
#6 lore raw

[tip: sched/core] sched/topology: Fix sched_numa_find_nth_cpu() in CPU-less case

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     617f2c38cb5ce60226042081c09e2ee3a90d03f8
Gitweb:        https://git.kernel.org/tip/617f2c38cb5ce60226042081c09e2ee3a90d03f8
Author:        Yury Norov <[email protected]>
AuthorDate:    Sat, 19 Aug 2023 07:12:35 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Fri, 15 Sep 2023 13:48:10 +02:00

sched/topology: Fix sched_numa_find_nth_cpu() in CPU-less case

When the node provided by user is CPU-less, corresponding record in sched_domains_numa_masks is not set. Trying to dereference it in the following code leads to kernel crash.

To avoid it, start searching from the nearest node with CPUs.

---
 kernel/sched/topology.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/sched/topology.c +5 -1
index 05a5bc6..423d089 100644
@@ -2122,12 +2122,16 @@ static int hop_cmp(const void *a, const void *b)
  */
 int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
-	struct __cmp_key k = { .cpus = cpus, .node = node, .cpu = cpu };
+	struct __cmp_key k = { .cpus = cpus, .cpu = cpu };
 	struct cpumask ***hop_masks;
 	int hop, ret = nr_cpu_ids;
 
 	rcu_read_lock();
 
+	/* CPU-less node entries are uninitialized in sched_domains_numa_masks */
+	node = numa_nearest_node(node, N_CPU);
+	k.node = node;
+
 	k.masks = rcu_dereference(sched_domains_numa_masks);
 	if (!k.masks)
 		goto unlock;
author maintainer
#7 lore raw

PATCH v2 4/6 sched: fix sched_numa_find_nth_cpu() in non-NUMA case

In reply to Yury Norov

When CONFIG_NUMA is enabled, sched_numa_find_nth_cpu() searches for a CPU in sched_domains_numa_masks. The masks includes only online CPUs, so effectively offline CPUs are skipped.

When CONFIG_NUMA is disabled, the fallback function should be consistent.

Fixes cd7f55359c90 ("sched: add sched_numa_find_nth_cpu()")
---
 include/linux/topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/topology.h +1 -1
index fea32377f7c7..52f5850730b3 100644
@@ -251,7 +251,7 @@ extern const struct cpumask *sched_numa_hop_mask(unsigned int node, unsigned int
 #else
 static __always_inline int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
-	return cpumask_nth(cpu, cpus);
+	return cpumask_nth_and(cpu, cpus, cpu_online_mask);
 }
 
 static inline const struct cpumask *
Signature · 1 line
2.39.2
merge bot Applied
#8 lore raw

[tip: sched/core] sched/topology: Fix sched_numa_find_nth_cpu() in non-NUMA case

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     8ab63d418d4339d996f80d02a00dbce0aa3ff972
Gitweb:        https://git.kernel.org/tip/8ab63d418d4339d996f80d02a00dbce0aa3ff972
Author:        Yury Norov <[email protected]>
AuthorDate:    Sat, 19 Aug 2023 07:12:36 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Fri, 15 Sep 2023 13:48:10 +02:00

sched/topology: Fix sched_numa_find_nth_cpu() in non-NUMA case

When CONFIG_NUMA is enabled, sched_numa_find_nth_cpu() searches for a CPU in sched_domains_numa_masks. The masks includes only online CPUs, so effectively offline CPUs are skipped.

When CONFIG_NUMA is disabled, the fallback function should be consistent.

Fixes cd7f55359c90 ("sched: add sched_numa_find_nth_cpu()")
Cc Mel Gorman <[email protected]>
---
 include/linux/topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/topology.h +1 -1
index fea3237..52f5850 100644
@@ -251,7 +251,7 @@ extern const struct cpumask *sched_numa_hop_mask(unsigned int node, unsigned int
 #else
 static __always_inline int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
-	return cpumask_nth(cpu, cpus);
+	return cpumask_nth_and(cpu, cpus, cpu_online_mask);
 }
 
 static inline const struct cpumask *
author maintainer
#9 lore raw

PATCH v2 5/6 sched: handle NUMA_NO_NODE in sched_numa_find_nth_cpu()

In reply to Yury Norov

sched_numa_find_nth_cpu() doesn't handle NUMA_NO_NODE properly, and may crash kernel if passed with it. On the other hand, the only user of sched_numa_find_nth_cpu() has to check NUMA_NO_NODE case explicitly.

It would be easier for users if this logic will get moved into sched_numa_find_nth_cpu().

---
 kernel/sched/topology.c | 3 +++
 lib/cpumask.c           | 4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)
kernel/sched/topology.c +3 -0
index c6e89afa0d65..bc6802700103 100644
@@ -2117,6 +2117,9 @@ int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 	struct cpumask ***hop_masks;
 	int hop, ret = nr_cpu_ids;
 
+	if (node == NUMA_NO_NODE)
+		return cpumask_nth_and(cpu, cpus, cpu_online_mask);
+
 	rcu_read_lock();
 
 	/* CPU-less node entries are uninitialized in sched_domains_numa_masks */
lib/cpumask.c +1 -3
index 19277c6d551f..e77ee9d46f71 100644
@@ -147,9 +147,7 @@ unsigned int cpumask_local_spread(unsigned int i, int node)
 	/* Wrap: we always want a cpu. */
 	i %= num_online_cpus();
 
-	cpu = (node == NUMA_NO_NODE) ?
-		cpumask_nth(i, cpu_online_mask) :
-		sched_numa_find_nth_cpu(cpu_online_mask, i, node);
+	cpu = sched_numa_find_nth_cpu(cpu_online_mask, i, node);
 
 	WARN_ON(cpu >= nr_cpu_ids);
 	return cpu;
Signature · 1 line
2.39.2
merge bot Applied
#10 lore raw

[tip: sched/core] sched/topology: Handle NUMA_NO_NODE in sched_numa_find_nth_cpu()

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     9ecea9ae4d3127a09fb5dfcea87f248937a39ff5
Gitweb:        https://git.kernel.org/tip/9ecea9ae4d3127a09fb5dfcea87f248937a39ff5
Author:        Yury Norov <[email protected]>
AuthorDate:    Sat, 19 Aug 2023 07:12:37 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Fri, 15 Sep 2023 13:48:11 +02:00

sched/topology: Handle NUMA_NO_NODE in sched_numa_find_nth_cpu()

sched_numa_find_nth_cpu() doesn't handle NUMA_NO_NODE properly, and may crash kernel if passed with it. On the other hand, the only user of sched_numa_find_nth_cpu() has to check NUMA_NO_NODE case explicitly.

It would be easier for users if this logic will get moved into sched_numa_find_nth_cpu().

---
 kernel/sched/topology.c | 3 +++
 lib/cpumask.c           | 4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)
kernel/sched/topology.c +3 -0
index 423d089..a60ecf4 100644
@@ -2126,6 +2126,9 @@ int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 	struct cpumask ***hop_masks;
 	int hop, ret = nr_cpu_ids;
 
+	if (node == NUMA_NO_NODE)
+		return cpumask_nth_and(cpu, cpus, cpu_online_mask);
+
 	rcu_read_lock();
 
 	/* CPU-less node entries are uninitialized in sched_domains_numa_masks */
lib/cpumask.c +1 -3
index a7fd02b..34335c1 100644
@@ -146,9 +146,7 @@ unsigned int cpumask_local_spread(unsigned int i, int node)
 	/* Wrap: we always want a cpu. */
 	i %= num_online_cpus();
 
-	cpu = (node == NUMA_NO_NODE) ?
-		cpumask_nth(i, cpu_online_mask) :
-		sched_numa_find_nth_cpu(cpu_online_mask, i, node);
+	cpu = sched_numa_find_nth_cpu(cpu_online_mask, i, node);
 
 	WARN_ON(cpu >= nr_cpu_ids);
 	return cpu;
author maintainer
#11 lore raw

PATCH v2 6/6 sched: fix sched_numa_find_nth_cpu() comment

In reply to Yury Norov

Reword sched_numa_find_nth_cpu() comment and make it kernel-doc compatible.

---
 kernel/sched/topology.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
kernel/sched/topology.c +9 -7
index bc6802700103..789b281d2380 100644
@@ -2103,13 +2103,15 @@ static int hop_cmp(const void *a, const void *b)
 	return -1;
 }
 
-/*
- * sched_numa_find_nth_cpu() - given the NUMA topology, find the Nth next cpu
- *                             closest to @cpu from @cpumask.
- * cpumask: cpumask to find a cpu from
- * cpu: Nth cpu to find
- *
- * returns: cpu, or nr_cpu_ids when nothing found.
+/**
+ * sched_numa_find_nth_cpu() - given the NUMA topology, find the Nth closest CPU
+ *                             from @cpus to @cpu, taking into account distance
+ *                             from a given @node.
+ * @cpus: cpumask to find a cpu from
+ * @cpu: CPU to start searching
+ * @node: NUMA node to order CPUs by distance
+ *
+ * Return: cpu, or nr_cpu_ids when nothing found.
  */
 int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
Signature · 1 line
2.39.2
merge bot Applied
#12 lore raw

[tip: sched/core] sched/topology: Fix sched_numa_find_nth_cpu() comment

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     6d08ad2166f7770341ea56afad45fa41cd16ae62
Gitweb:        https://git.kernel.org/tip/6d08ad2166f7770341ea56afad45fa41cd16ae62
Author:        Yury Norov <[email protected]>
AuthorDate:    Sat, 19 Aug 2023 07:12:38 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Fri, 15 Sep 2023 13:48:11 +02:00

sched/topology: Fix sched_numa_find_nth_cpu() comment

Reword sched_numa_find_nth_cpu() comment and make it kernel-doc compatible.

---
 kernel/sched/topology.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
kernel/sched/topology.c +9 -7
index a60ecf4..a7b50bb 100644
@@ -2112,13 +2112,15 @@ static int hop_cmp(const void *a, const void *b)
 	return -1;
 }
 
-/*
- * sched_numa_find_nth_cpu() - given the NUMA topology, find the Nth next cpu
- *                             closest to @cpu from @cpumask.
- * cpumask: cpumask to find a cpu from
- * cpu: Nth cpu to find
- *
- * returns: cpu, or nr_cpu_ids when nothing found.
+/**
+ * sched_numa_find_nth_cpu() - given the NUMA topology, find the Nth closest CPU
+ *                             from @cpus to @cpu, taking into account distance
+ *                             from a given @node.
+ * @cpus: cpumask to find a cpu from
+ * @cpu: CPU to start searching
+ * @node: NUMA node to order CPUs by distance
+ *
+ * Return: cpu, or nr_cpu_ids when nothing found.
  */
 int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
author maintainer
#13 lore raw
In reply to Yury Norov

Ping?

Quoted 30 lines · Yury Norov

Fixes for recently introduced sched_numa_find_nth_cpu(), and minor improvements in sched/fair.

v1: https://lore.kernel.org/lkml/[email protected]/T/
v2:
- fix wording in commit messages;
- move nearest node search inside rcu lock section in sched_numa_find_nth_cpu();
- move NUMA_NO_NODE handling inside sched_numa_find_nth_cpu();
- rewrite comment for sched_numa_find_nth_cpu().
- add review tag from Yicong Yang.

Yury Norov (6):
numa: generalize numa_map_to_online_node() sched/fair: fix opencoded numa_nearest_node()
sched: fix sched_numa_find_nth_cpu() in CPU-less case
sched: fix sched_numa_find_nth_cpu() in non-NUMA case
sched: handle NUMA_NO_NODE in sched_numa_find_nth_cpu()
sched: fix sched_numa_find_nth_cpu() comment

 include/linux/numa.h     |  7 +++++--
 include/linux/topology.h |  2 +-
 kernel/sched/fair.c      | 14 +-------------
 kernel/sched/topology.c  | 25 +++++++++++++++++--------
 lib/cpumask.c            |  4 +---
 mm/mempolicy.c           | 18 +++++++++++-------
 6 files changed, 36 insertions(+), 34 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#14 lore raw

Another ping...

Quoted 33 lines · Yury Norov

Ping?

Quoted 30 lines · Yury Norov

Fixes for recently introduced sched_numa_find_nth_cpu(), and minor improvements in sched/fair.

v1: https://lore.kernel.org/lkml/[email protected]/T/
v2:
- fix wording in commit messages;
- move nearest node search inside rcu lock section in sched_numa_find_nth_cpu();
- move NUMA_NO_NODE handling inside sched_numa_find_nth_cpu();
- rewrite comment for sched_numa_find_nth_cpu().
- add review tag from Yicong Yang.

Yury Norov (6):
numa: generalize numa_map_to_online_node() sched/fair: fix opencoded numa_nearest_node()
sched: fix sched_numa_find_nth_cpu() in CPU-less case
sched: fix sched_numa_find_nth_cpu() in non-NUMA case
sched: handle NUMA_NO_NODE in sched_numa_find_nth_cpu()
sched: fix sched_numa_find_nth_cpu() comment

 include/linux/numa.h     |  7 +++++--
 include/linux/topology.h |  2 +-
 kernel/sched/fair.c      | 14 +-------------
 kernel/sched/topology.c  | 25 +++++++++++++++++--------
 lib/cpumask.c            |  4 +---
 mm/mempolicy.c           | 18 +++++++++++-------
 6 files changed, 36 insertions(+), 34 deletions(-)
Signature · 1 line
2.39.2