Skip to content

Commit a814ead

Browse files
committed
add a tool to read numa node physical address range
1 parent bd4132a commit a814ead

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
obj-m += numa_info.o
2+
3+
all:
4+
@echo "Building kernel module..."
5+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
6+
@echo "Checking if numa_info module is loaded..."
7+
@if lsmod | grep -q numa_info; then \
8+
echo "Unloading existing numa_info module..."; \
9+
sudo rmmod numa_info; \
10+
fi
11+
@echo "Loading numa_info module..."
12+
sudo insmod numa_info.ko
13+
@echo "Checking kernel logs for numa_info_init..."
14+
sudo dmesg | grep numa_info_init
15+
16+
clean:
17+
@echo "Cleaning up..."
18+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
19+
@echo "Checking if numa_info module is loaded..."
20+
@if lsmod | grep -q numa_info; then \
21+
echo "Unloading numa_info module..."; \
22+
sudo rmmod numa_info; \
23+
fi
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <linux/module.h>
2+
#include <linux/kernel.h>
3+
#include <linux/init.h>
4+
#include <linux/numa.h>
5+
6+
static int __init numa_info_init(void)
7+
{
8+
int i, online_numa_node_count;
9+
unsigned long long node_start_t, node_end_t;
10+
11+
online_numa_node_count = num_online_nodes();
12+
pr_info("%s: Total online NUMA nodes: %d\n", __func__, online_numa_node_count);
13+
14+
for (i = 0; i < online_numa_node_count; i++) {
15+
node_start_t = (unsigned long long)node_start_pfn(i) << PAGE_SHIFT;
16+
node_end_t = (unsigned long long)node_end_pfn(i) << PAGE_SHIFT;
17+
pr_info("%s: NUMA node [%d] start [0x%llx] end [0x%llx]\n",
18+
__func__, i, node_start_t, node_end_t);
19+
}
20+
21+
return 0;
22+
}
23+
24+
static void __exit numa_info_exit(void)
25+
{
26+
pr_info("%s: Module unloaded\n", __func__);
27+
}
28+
29+
module_init(numa_info_init);
30+
module_exit(numa_info_exit);
31+
32+
MODULE_LICENSE("GPL");
33+
MODULE_AUTHOR("CXL_Perf");
34+
MODULE_DESCRIPTION("Print NUMA node physical address ranges");

0 commit comments

Comments
 (0)