Skip to contentSkip to conversation

ia64: export node_distance function

PATCH In review Matias Bjørling 3 participants 6 messages Nov 3, 2018 – Nov 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ia64: export node_distance function

The numa_slit variable used by node_distance is available to a module as long as it is linked at compile-time. However, it is not available to loadable modules. Leading to errors such as:

ERROR: "numa_slit" [drivers/nvme/host/nvme-core.ko] undefined!

The error above is caused by the nvme multipath code that makes use of node_distance for its path calculation. When the patch was added, the lightnvm subsystem would select nvme and always compile it in, leading to the node_distance call to always succeed. However, when this requirement was removed, nvme could be compiled in as a module, which exposed this bug.

This patch extracts node_distance to a function and exports it. Since ACPI is depending on node_distance being a simple lookup to numa_slit, the previous behavior is exposed as slit_distance and its users updated.

Fixes f333444708f82 "nvme: take node locality into account when selecting a path"
Fixes 73569e11032f "lightnvm: remove dependencies on BLK_DEV_NVME and PCI"
---
 arch/ia64/include/asm/numa.h | 4 +++-
 arch/ia64/kernel/acpi.c      | 6 +++---
 arch/ia64/mm/numa.c          | 6 ++++++
 3 files changed, 12 insertions(+), 4 deletions(-)
arch/ia64/include/asm/numa.h +3 -1
index ebef7f40aabb..c5c253cb9bd6 100644
@@ -59,7 +59,9 @@ extern struct node_cpuid_s node_cpuid[NR_CPUS];
  */
 
 extern u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
-#define node_distance(from,to) (numa_slit[(from) * MAX_NUMNODES + (to)])
+#define slit_distance(from,to) (numa_slit[(from) * MAX_NUMNODES + (to)])
+extern int __node_distance(int from, int to);
+#define node_distance(from,to) __node_distance(from, to)
 
 extern int paddr_to_nid(unsigned long paddr);
 
arch/ia64/kernel/acpi.c +2 -3
index 1dacbf5e9e09..41eb281709da 100644
@@ -578,8 +578,8 @@ void __init acpi_numa_fixup(void)
 	if (!slit_table) {
 		for (i = 0; i < MAX_NUMNODES; i++)
 			for (j = 0; j < MAX_NUMNODES; j++)
-				node_distance(i, j) = i = j ? LOCAL_DISTANCE :
-							REMOTE_DISTANCE;
+				slit_distance(i, j) = i = j ?
+					LOCAL_DISTANCE : REMOTE_DISTANCE;
 		return;
 	}
 
@@ -592,7 +592,7 @@ void __init acpi_numa_fixup(void)
 			if (!pxm_bit_test(j))
 				continue;
 			node_to = pxm_to_node(j);
-			node_distance(node_from, node_to) +			slit_distance(node_from, node_to)  			    slit_table->entry[i * slit_table->locality_count + j];
 		}
 	}
arch/ia64/mm/numa.c +6 -0
index aa19b7ac8222..5769d4b21270 100644
@@ -36,6 +36,12 @@ struct node_cpuid_s node_cpuid[NR_CPUS]   */
 u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
 
+int __node_distance(int from, int to)
+{
+	return slit_distance(from, to);
+}
+EXPORT_SYMBOL(__node_distance);
+
 /* Identify which cnode a physical address resides on */
 int
 paddr_to_nid(unsigned long paddr)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 71 lines · Matias Bjørling

The numa_slit variable used by node_distance is available to a module as long as it is linked at compile-time. However, it is not available to loadable modules. Leading to errors such as:

ERROR: "numa_slit" [drivers/nvme/host/nvme-core.ko] undefined!

The error above is caused by the nvme multipath code that makes use of node_distance for its path calculation. When the patch was added, the lightnvm subsystem would select nvme and always compile it in, leading to the node_distance call to always succeed. However, when this requirement was removed, nvme could be compiled in as a module, which exposed this bug.

This patch extracts node_distance to a function and exports it. Since ACPI is depending on node_distance being a simple lookup to numa_slit, the previous behavior is exposed as slit_distance and its users updated.

Fixes f333444708f82 "nvme: take node locality into account when selecting a path"
Fixes 73569e11032f "lightnvm: remove dependencies on BLK_DEV_NVME and PCI"
---
  arch/ia64/include/asm/numa.h | 4 +++-
  arch/ia64/kernel/acpi.c      | 6 +++---
  arch/ia64/mm/numa.c          | 6 ++++++
  3 files changed, 12 insertions(+), 4 deletions(-)
arch/ia64/include/asm/numa.h +3 -1
index ebef7f40aabb..c5c253cb9bd6 100644
@@ -59,7 +59,9 @@ extern struct node_cpuid_s node_cpuid[NR_CPUS];
   */
 
  extern u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
-#define node_distance(from,to) (numa_slit[(from) * MAX_NUMNODES + (to)])
+#define slit_distance(from,to) (numa_slit[(from) * MAX_NUMNODES + (to)])
+extern int __node_distance(int from, int to);
+#define node_distance(from,to) __node_distance(from, to)
 
  extern int paddr_to_nid(unsigned long paddr);
 
arch/ia64/kernel/acpi.c +2 -3
index 1dacbf5e9e09..41eb281709da 100644
@@ -578,8 +578,8 @@ void __init acpi_numa_fixup(void)
  	if (!slit_table) {
  		for (i = 0; i < MAX_NUMNODES; i++)
  			for (j = 0; j < MAX_NUMNODES; j++)
-				node_distance(i, j) = i = j ? LOCAL_DISTANCE :
-							REMOTE_DISTANCE;
+				slit_distance(i, j) = i = j ?
+					LOCAL_DISTANCE : REMOTE_DISTANCE;
  		return;
  	}
 
@@ -592,7 +592,7 @@ void __init acpi_numa_fixup(void)
  			if (!pxm_bit_test(j))
  				continue;
  			node_to = pxm_to_node(j);
-			node_distance(node_from, node_to) > +			slit_distance(node_from, node_to) >   			    slit_table->entry[i * slit_table->locality_count + j];
  		}
  	}
arch/ia64/mm/numa.c +0 -0
index aa19b7ac8222..5769d4b21270 100644
@@ -36,6 +36,12 @@ struct node_cpuid_s node_cpuid[NR_CPUS] >    */
  u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
 

arch/ia64/mm/numa.c struct node_cpuid_s node_cpuid[NR_CPUS] > */ · line 47

Quoted 10 lines
arch/ia64/mm/numa.c +6 -0
+int __node_distance(int from, int to)
+{
+	return slit_distance(from, to);
+}
+EXPORT_SYMBOL(__node_distance);
+
  /* Identify which cnode a physical address resides on */
  int
  paddr_to_nid(unsigned long paddr)
 

Tony and Fenghua, could you please take a look at the above patch? kbuild has been bugging me for a fix.

#2 lore raw

PATCH 1/1 ia64: export node_distance function

In reply to Matias Bjørling

From: Matias Bjørling <[email protected]>

The numa_slit variable used by node_distance is available to a module as long as it is linked at compile-time. However, it is not available to loadable modules. Leading to errors such as:

ERROR: "numa_slit" [drivers/nvme/host/nvme-core.ko] undefined!

The error above is caused by the nvme multipath code that makes use of node_distance for its path calculation. When the patch was added, the lightnvm subsystem would select nvme and always compile it in, leading to the node_distance call to always succeed. However, when this requirement was removed, nvme could be compiled in as a module, which exposed this bug.

This patch extracts node_distance to a function and exports it. Since ACPI is depending on node_distance being a simple lookup to numa_slit, the previous behavior is exposed as slit_distance and its users updated.

Fixes f333444708f82 "nvme: take node locality into account when selecting a path"
Fixes 73569e11032f "lightnvm: remove dependencies on BLK_DEV_NVME and PCI"
---
 arch/ia64/include/asm/numa.h | 4 +++-
 arch/ia64/kernel/acpi.c      | 6 +++---
 arch/ia64/mm/numa.c          | 6 ++++++
 3 files changed, 12 insertions(+), 4 deletions(-)
arch/ia64/include/asm/numa.h +3 -1
index ebef7f40aabb..c5c253cb9bd6 100644
@@ -59,7 +59,9 @@ extern struct node_cpuid_s node_cpuid[NR_CPUS];
  */
 
 extern u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
-#define node_distance(from,to) (numa_slit[(from) * MAX_NUMNODES + (to)])
+#define slit_distance(from,to) (numa_slit[(from) * MAX_NUMNODES + (to)])
+extern int __node_distance(int from, int to);
+#define node_distance(from,to) __node_distance(from, to)
 
 extern int paddr_to_nid(unsigned long paddr);
 
arch/ia64/kernel/acpi.c +2 -3
index 1dacbf5e9e09..41eb281709da 100644
@@ -578,8 +578,8 @@ void __init acpi_numa_fixup(void)
 	if (!slit_table) {
 		for (i = 0; i < MAX_NUMNODES; i++)
 			for (j = 0; j < MAX_NUMNODES; j++)
-				node_distance(i, j) = i = j ? LOCAL_DISTANCE :
-							REMOTE_DISTANCE;
+				slit_distance(i, j) = i = j ?
+					LOCAL_DISTANCE : REMOTE_DISTANCE;
 		return;
 	}
 
@@ -592,7 +592,7 @@ void __init acpi_numa_fixup(void)
 			if (!pxm_bit_test(j))
 				continue;
 			node_to = pxm_to_node(j);
-			node_distance(node_from, node_to) +			slit_distance(node_from, node_to)  			    slit_table->entry[i * slit_table->locality_count + j];
 		}
 	}
arch/ia64/mm/numa.c +6 -0
index 3861d6e32d5f..a03803506b0c 100644
@@ -36,6 +36,12 @@ struct node_cpuid_s node_cpuid[NR_CPUS]   */
 u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
 
+int __node_distance(int from, int to)
+{
+	return slit_distance(from, to);
+}
+EXPORT_SYMBOL(__node_distance);
+
 /* Identify which cnode a physical address resides on */
 int
 paddr_to_nid(unsigned long paddr)
Signature · 1 line
2.19.1
#3 lore raw
In reply to Matias Bjørling
Quoted 4 lines · Tony Luck

The numa_slit variable used by node_distance is available to a module as long as it is linked at compile-time. However, it is not available to loadable modules. Leading to errors such as:

[...]

Tony: Just checking - you aren't planning on doing a git pull request, and want me to apply this directly as a patch?

Linus

#4 lore raw
In reply to Matias Bjørling

Correct. Unless you’d prefer it as a git pull.

Sent from my iPhone

Quoted 13 lines · Linus Torvalds
Quoted 6 lines · Tony Luck

The numa_slit variable used by node_distance is available to a module as long as it is linked at compile-time. However, it is not available to loadable modules. Leading to errors such as:

[...]

Tony: Just checking - you aren't planning on doing a git pull request, and want me to apply this directly as a patch?

Linus

#5 lore raw
In reply to Matias Bjørling
Quoted 2 lines · Tony

Correct. Unless you’d prefer it as a git pull.

I have applied it as a patch - it's just that if you're somebody I know sends me git pull requests _too_, then it's generally best to tell me explicitly that this patch is supposed to be applied as a patch.

Otherwise it's ambiguous - am I cc'd for some informational reason and I'll get it later in a git pull request, or did you send it to me explicitly because you're _not_ planning on sending it as a git pull..

Put another way: if I'm not sure what I'm supposed to do about a patch, mistakes happen (ie I can go "ok, I saw it, I'll archive it and get it later through git").

Linus