Subject: Re: [Patch] numa: introduce CONFIG_NUMA_SYSFS for drivers/base/node.c

From: Cong Wang <[email-masked]>
Date: Thu, 25 Aug 2011 11:31:45 +0800

于 2011年08月25日 10:14, Randy Dunlap 写道:
> On Wed, 24 Aug 2011 11:34:45 +0800 Cong Wang wrote:
>
>> Hi, Andrew,
>>
>> Do you think my patch below is better?
>
> Hi,
>
> This causes build errors for me because node.o is not being built:
>
> arch/x86/built-in.o: In function `topology_init':
> topology.c:(.init.text+0x3668): undefined reference to `register_one_node'
> drivers/built-in.o: In function `unregister_cpu':
> (.text+0x7aecc): undefined reference to `unregister_cpu_under_node'
> drivers/built-in.o: In function `register_cpu':
> (.cpuinit.text+0xc1): undefined reference to `register_cpu_under_node'

Ah, this is because I missed the part in include/linux/node.h. :)

Below is the updated version.

Thanks for testing!
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 99a375a..e382338 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_HAS_DMA)	+= dma-mapping.o
 obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
 obj-$(CONFIG_ISA)	+= isa.o
 obj-$(CONFIG_FW_LOADER)	+= firmware_class.o
-obj-$(CONFIG_NUMA)	+= node.o
+obj-$(CONFIG_NUMA_SYSFS)	+= node.o
 obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o
 obj-$(CONFIG_SMP)	+= topology.o
 ifeq ($(CONFIG_SYSFS),y)
diff --git a/include/linux/node.h b/include/linux/node.h
index 92370e2..a0cc5f9 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -32,7 +32,7 @@ typedef  void (*node_registration_func_t)(struct node *);
 
 extern int register_node(struct node *, int, struct node *);
 extern void unregister_node(struct node *node);
-#ifdef CONFIG_NUMA
+#ifdef defined(CONFIG_NUMA) && defined(CONFIG_SYSFS)
 extern int register_one_node(int nid);
 extern void unregister_one_node(int nid);
 extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
diff --git a/mm/Kconfig b/mm/Kconfig
index f2f1ca1..77345e7 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -340,6 +340,16 @@ choice
 	  benefit.
 endchoice
 
+config NUMA_SYSFS
+	bool "Enable NUMA sysfs interface for user-space"
+	depends on NUMA
+	depends on SYSFS
+	default y
+	help
+	  This enables NUMA sysfs interface, /sys/devices/system/node/*
+	  files, for user-space tools, like numactl. If you have enabled
+	  NUMA, probably you also need this one.
+
 #
 # UP and nommu archs use km based percpu allocator
 #