Skip to content

Commit a47a126

Browse files
Eric Dumazettorvalds
authored andcommitted
vmallocinfo: add NUMA information
Christoph recently added /proc/vmallocinfo file to get information about vmalloc allocations. This patch adds NUMA specific information, giving number of pages allocated on each memory node. This should help to check that vmalloc() is able to respect NUMA policies. Example of output on a four nodes machine (one cpu per node) 1) network hash tables are evenly spreaded on four nodes (OK) (Same point for inodes and dentries hash tables) 2) iptables tables (x_tables) are correctly allocated on each cpu node (OK). 3) sys_swapon() allocates its memory from one node only. 4) each loaded module is using memory on one node. Sysadmins could tune their setup to change points 3) and 4) if necessary. grep "pages=" /proc/vmallocinfo 0xffffc20000000000-0xffffc20000201000 2101248 alloc_large_system_hash+0x204/0x2c0 pages=512 vmalloc N0=128 N1=128 N2=128 N3=128 0xffffc20000201000-0xffffc20000302000 1052672 alloc_large_system_hash+0x204/0x2c0 pages=256 vmalloc N0=64 N1=64 N2=64 N3=64 0xffffc2000031a000-0xffffc2000031d000 12288 alloc_large_system_hash+0x204/0x2c0 pages=2 vmalloc N1=1 N2=1 0xffffc2000031f000-0xffffc2000032b000 49152 cramfs_uncompress_init+0x2e/0x80 pages=11 vmalloc N0=3 N1=3 N2=2 N3=3 0xffffc2000033e000-0xffffc20000341000 12288 sys_swapon+0x640/0xac0 pages=2 vmalloc N0=2 0xffffc20000341000-0xffffc20000344000 12288 xt_alloc_table_info+0xfe/0x130 [x_tables] pages=2 vmalloc N0=2 0xffffc20000344000-0xffffc20000347000 12288 xt_alloc_table_info+0xfe/0x130 [x_tables] pages=2 vmalloc N1=2 0xffffc20000347000-0xffffc2000034a000 12288 xt_alloc_table_info+0xfe/0x130 [x_tables] pages=2 vmalloc N2=2 0xffffc2000034a000-0xffffc2000034d000 12288 xt_alloc_table_info+0xfe/0x130 [x_tables] pages=2 vmalloc N3=2 0xffffc20004381000-0xffffc20004402000 528384 alloc_large_system_hash+0x204/0x2c0 pages=128 vmalloc N0=32 N1=32 N2=32 N3=32 0xffffc20004402000-0xffffc20004803000 4198400 alloc_large_system_hash+0x204/0x2c0 pages=1024 vmalloc vpages N0=256 N1=256 N2=256 N3=256 0xffffc20004803000-0xffffc20004904000 1052672 alloc_large_system_hash+0x204/0x2c0 pages=256 vmalloc N0=64 N1=64 N2=64 N3=64 0xffffc20004904000-0xffffc20004bec000 3047424 sys_swapon+0x640/0xac0 pages=743 vmalloc vpages N0=743 0xffffffffa0000000-0xffffffffa000f000 61440 sys_init_module+0xc27/0x1d00 pages=14 vmalloc N1=14 0xffffffffa000f000-0xffffffffa0014000 20480 sys_init_module+0xc27/0x1d00 pages=4 vmalloc N0=4 0xffffffffa0014000-0xffffffffa0017000 12288 sys_init_module+0xc27/0x1d00 pages=2 vmalloc N0=2 0xffffffffa0017000-0xffffffffa0022000 45056 sys_init_module+0xc27/0x1d00 pages=10 vmalloc N1=10 0xffffffffa0022000-0xffffffffa0028000 24576 sys_init_module+0xc27/0x1d00 pages=5 vmalloc N3=5 0xffffffffa0028000-0xffffffffa0050000 163840 sys_init_module+0xc27/0x1d00 pages=39 vmalloc N1=39 0xffffffffa0050000-0xffffffffa0052000 8192 sys_init_module+0xc27/0x1d00 pages=1 vmalloc N1=1 0xffffffffa0052000-0xffffffffa0056000 16384 sys_init_module+0xc27/0x1d00 pages=3 vmalloc N1=3 0xffffffffa0056000-0xffffffffa0081000 176128 sys_init_module+0xc27/0x1d00 pages=42 vmalloc N3=42 0xffffffffa0081000-0xffffffffa00ae000 184320 sys_init_module+0xc27/0x1d00 pages=44 vmalloc N3=44 0xffffffffa00ae000-0xffffffffa00b1000 12288 sys_init_module+0xc27/0x1d00 pages=2 vmalloc N3=2 0xffffffffa00b1000-0xffffffffa00b9000 32768 sys_init_module+0xc27/0x1d00 pages=7 vmalloc N0=7 0xffffffffa00b9000-0xffffffffa00c4000 45056 sys_init_module+0xc27/0x1d00 pages=10 vmalloc N3=10 0xffffffffa00c6000-0xffffffffa00e0000 106496 sys_init_module+0xc27/0x1d00 pages=25 vmalloc N2=25 0xffffffffa00e0000-0xffffffffa00f1000 69632 sys_init_module+0xc27/0x1d00 pages=16 vmalloc N2=16 0xffffffffa00f1000-0xffffffffa00f4000 12288 sys_init_module+0xc27/0x1d00 pages=2 vmalloc N3=2 0xffffffffa00f4000-0xffffffffa00f7000 12288 sys_init_module+0xc27/0x1d00 pages=2 vmalloc N3=2 [akpm@linux-foundation.org: fix comment] Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cce7708 commit a47a126

3 files changed

Lines changed: 77 additions & 2 deletions

File tree

‎Documentation/filesystems/proc.txt‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ Table 1-4: Kernel info in /proc
296296
uptime System uptime
297297
version Kernel version
298298
video bttv info of video resources (2.4)
299+
vmallocinfo Show vmalloced areas
299300
..............................................................................
300301

301302
You can, for example, check which interrupts are currently in use and what
@@ -557,6 +558,49 @@ VmallocTotal: total size of vmalloc memory area
557558
VmallocUsed: amount of vmalloc area which is used
558559
VmallocChunk: largest contigious block of vmalloc area which is free
559560

561+
..............................................................................
562+
563+
vmallocinfo:
564+
565+
Provides information about vmalloced/vmaped areas. One line per area,
566+
containing the virtual address range of the area, size in bytes,
567+
caller information of the creator, and optional information depending
568+
on the kind of area :
569+
570+
pages=nr number of pages
571+
phys=addr if a physical address was specified
572+
ioremap I/O mapping (ioremap() and friends)
573+
vmalloc vmalloc() area
574+
vmap vmap()ed pages
575+
user VM_USERMAP area
576+
vpages buffer for pages pointers was vmalloced (huge area)
577+
N<node>=nr (Only on NUMA kernels)
578+
Number of pages allocated on memory node <node>
579+
580+
> cat /proc/vmallocinfo
581+
0xffffc20000000000-0xffffc20000201000 2101248 alloc_large_system_hash+0x204 ...
582+
/0x2c0 pages=512 vmalloc N0=128 N1=128 N2=128 N3=128
583+
0xffffc20000201000-0xffffc20000302000 1052672 alloc_large_system_hash+0x204 ...
584+
/0x2c0 pages=256 vmalloc N0=64 N1=64 N2=64 N3=64
585+
0xffffc20000302000-0xffffc20000304000 8192 acpi_tb_verify_table+0x21/0x4f...
586+
phys=7fee8000 ioremap
587+
0xffffc20000304000-0xffffc20000307000 12288 acpi_tb_verify_table+0x21/0x4f...
588+
phys=7fee7000 ioremap
589+
0xffffc2000031d000-0xffffc2000031f000 8192 init_vdso_vars+0x112/0x210
590+
0xffffc2000031f000-0xffffc2000032b000 49152 cramfs_uncompress_init+0x2e ...
591+
/0x80 pages=11 vmalloc N0=3 N1=3 N2=2 N3=3
592+
0xffffc2000033a000-0xffffc2000033d000 12288 sys_swapon+0x640/0xac0 ...
593+
pages=2 vmalloc N1=2
594+
0xffffc20000347000-0xffffc2000034c000 20480 xt_alloc_table_info+0xfe ...
595+
/0x130 [x_tables] pages=4 vmalloc N0=4
596+
0xffffffffa0000000-0xffffffffa000f000 61440 sys_init_module+0xc27/0x1d00 ...
597+
pages=14 vmalloc N2=14
598+
0xffffffffa000f000-0xffffffffa0014000 20480 sys_init_module+0xc27/0x1d00 ...
599+
pages=4 vmalloc N1=4
600+
0xffffffffa0014000-0xffffffffa0017000 12288 sys_init_module+0xc27/0x1d00 ...
601+
pages=2 vmalloc N1=2
602+
0xffffffffa0017000-0xffffffffa0022000 45056 sys_init_module+0xc27/0x1d00 ...
603+
pages=10 vmalloc N0=10
560604

561605
1.3 IDE devices in /proc/ide
562606
----------------------------

‎fs/proc/proc_misc.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,25 @@ static const struct file_operations proc_slabstats_operations = {
464464
#ifdef CONFIG_MMU
465465
static int vmalloc_open(struct inode *inode, struct file *file)
466466
{
467-
return seq_open(file, &vmalloc_op);
467+
unsigned int *ptr = NULL;
468+
int ret;
469+
470+
if (NUMA_BUILD)
471+
ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
472+
ret = seq_open(file, &vmalloc_op);
473+
if (!ret) {
474+
struct seq_file *m = file->private_data;
475+
m->private = ptr;
476+
} else
477+
kfree(ptr);
478+
return ret;
468479
}
469480

470481
static const struct file_operations proc_vmalloc_operations = {
471482
.open = vmalloc_open,
472483
.read = seq_read,
473484
.llseek = seq_lseek,
474-
.release = seq_release,
485+
.release = seq_release_private,
475486
};
476487
#endif
477488

‎mm/vmalloc.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,25 @@ static void s_stop(struct seq_file *m, void *p)
931931
read_unlock(&vmlist_lock);
932932
}
933933

934+
static void show_numa_info(struct seq_file *m, struct vm_struct *v)
935+
{
936+
if (NUMA_BUILD) {
937+
unsigned int nr, *counters = m->private;
938+
939+
if (!counters)
940+
return;
941+
942+
memset(counters, 0, nr_node_ids * sizeof(unsigned int));
943+
944+
for (nr = 0; nr < v->nr_pages; nr++)
945+
counters[page_to_nid(v->pages[nr])]++;
946+
947+
for_each_node_state(nr, N_HIGH_MEMORY)
948+
if (counters[nr])
949+
seq_printf(m, " N%u=%u", nr, counters[nr]);
950+
}
951+
}
952+
934953
static int s_show(struct seq_file *m, void *p)
935954
{
936955
struct vm_struct *v = p;
@@ -967,6 +986,7 @@ static int s_show(struct seq_file *m, void *p)
967986
if (v->flags & VM_VPAGES)
968987
seq_printf(m, " vpages");
969988

989+
show_numa_info(m, v);
970990
seq_putc(m, '\n');
971991
return 0;
972992
}

0 commit comments

Comments
 (0)