[PATCH] numastat: fix bad column calculation in show_process_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	When system has non contiguous numa node number, double_add writing in bad area in table struct.

	[root@ibm-p8-03-lp1 numactl]# numastat qemu-kvm

	Per-node process memory usage (in MBs) for PID 33331 (qemu-kvm)
        	                   Node 0          Node 3           Total
                	  --------------- --------------- ---------------
	Huge                         0.00            0.00            0.00
	Heap                         0.00            0.00           23.75
	24                           0.00            0.00            0.62
	1                            0.00            0.00           47.62
	----------------  --------------- --------------- ---------------
	Total                        0.00            0.00           72.00
	*** Error in `numastat': double free or corruption (!prev): 0x00000100077301c0 ***
	======= Backtrace: =========
	/lib64/libc.so.6(cfree+0x44c)[0x3fff8df24dec]
	numastat[0x100025b0]
	numastat[0x1000444c]
	numastat[0x100014c4]
	/lib64/libc.so.6(+0x24700)[0x3fff8deb4700]
	/lib64/libc.so.6(__libc_start_main+0xc4)[0x3fff8deb48f4]
	======= Memory map: ========
	10000000-10010000 r-xp 00000000 fd:00 16136                              /usr/bin/numastat
	10010000-10020000 r--p 00000000 fd:00 16136                              /usr/bin/numastat
	10020000-10030000 rw-p 00010000 fd:00 16136                              /usr/bin/numastat
	10007730000-10007760000 rw-p 00000000 00:00 0                            [heap]
	3fff8de80000-3fff8de90000 rw-p 00000000 00:00 0
	3fff8de90000-3fff8e050000 r-xp 00000000 fd:00 33616617                   /usr/lib64/libc-2.17.so
	3fff8e050000-3fff8e060000 r--p 001b0000 fd:00 33616617                   /usr/lib64/libc-2.17.so
	3fff8e060000-3fff8e070000 rw-p 001c0000 fd:00 33616617                   /usr/lib64/libc-2.17.so
	3fff8e070000-3fff8e080000 rw-p 00000000 00:00 0
	3fff8e080000-3fff8e0a0000 r-xp 00000000 00:00 0                          [vdso]
	3fff8e0a0000-3fff8e0d0000 r-xp 00000000 fd:00 35349218                   /usr/lib64/ld-2.17.so
	3fff8e0d0000-3fff8e0e0000 r--p 00020000 fd:00 35349218                   /usr/lib64/ld-2.17.so
	3fff8e0e0000-3fff8e0f0000 rw-p 00030000 fd:00 35349218                   /usr/lib64/ld-2.17.so
	3fffeeef0000-3fffeef20000 rw-p 00000000 00:00 0                          [stack]
	(SIGABRT)

	After fix:
	[root@ibm-p8-03-lp1 numactl]# numastat qemu-kvm

	Per-node process memory usage (in MBs) for PID 33331 (qemu-kvm)
        	                   Node 0          Node 3           Total
                	  --------------- --------------- ---------------
	Huge                         0.00            0.00            0.00
	Heap                         0.00           23.75           23.75
	Stack                        0.00            0.62            0.62
	Private                      0.00           47.62           47.62
	----------------  --------------- --------------- ---------------
	Total                        0.00           72.00           72.00
	[root@ibm-p8-03-lp1 numactl]#

Signed-off-by: Petr Oros <poros@xxxxxxxxxx>
---
 numastat.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/numastat.c b/numastat.c
index 1924dba..ffc8891 100644
--- a/numastat.c
+++ b/numastat.c
@@ -1054,7 +1054,13 @@ void show_process_info() {
 					} else {
 						tmp_row = header_rows + pid_ix;
 					}
-					int tmp_col = header_cols + node_num;
+					int tmp_col = header_cols;
+					for (int ix = 0; (ix < num_nodes); ix++) {
+						if (node_ix_map[ix] == node_num) {
+							tmp_col = tmp_col + ix;
+							break;
+						}
+					}
 					double_addto(&table, tmp_row, tmp_col, value);
 					double_addto(&table, tmp_row, total_col_ix, value);
 					double_addto(&table, total_row_ix, tmp_col, value);
-- 
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux