linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] numastat: fix bad column calculation in show_process_info
@ 2017-05-25 11:36 Petr Oros
  2017-05-25 18:30 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Oros @ 2017-05-25 11:36 UTC (permalink / raw)
  To: linux-numa

	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@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] numastat: fix bad column calculation in show_process_info
  2017-05-25 11:36 [PATCH] numastat: fix bad column calculation in show_process_info Petr Oros
@ 2017-05-25 18:30 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2017-05-25 18:30 UTC (permalink / raw)
  To: Petr Oros; +Cc: linux-numa

On Thu, May 25, 2017 at 01:36:32PM +0200, Petr Oros wrote:
> 	When system has non contiguous numa node number, double_add writing in bad area in table struct.

Should be already covered in

commit b608687037d873ad82d6318f231b3d6612e8601d
Author: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Date:   Wed Dec 21 12:48:11 2016 +0530

    Segment fault when numa nodes not sequential or contiguous
        

in https://github.com/numactl/numactl

Please check.

-Andi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-25 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-25 11:36 [PATCH] numastat: fix bad column calculation in show_process_info Petr Oros
2017-05-25 18:30 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).