linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Oros <poros@redhat.com>
To: linux-numa@vger.kernel.org
Subject: [PATCH] numastat: fix bad column calculation in show_process_info
Date: Thu, 25 May 2017 13:36:32 +0200	[thread overview]
Message-ID: <20170525113632.11638-1-poros@redhat.com> (raw)

	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

             reply	other threads:[~2017-05-25 11:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25 11:36 Petr Oros [this message]
2017-05-25 18:30 ` [PATCH] numastat: fix bad column calculation in show_process_info Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170525113632.11638-1-poros@redhat.com \
    --to=poros@redhat.com \
    --cc=linux-numa@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).