diff --git a/0033-Move-all-curses-calls-into-display-threads.patch b/0038-Move-all-curses-calls-into-display-threads.patch similarity index 98% rename from 0033-Move-all-curses-calls-into-display-threads.patch rename to 0038-Move-all-curses-calls-into-display-threads.patch index c2375e0..1f2e0b9 100644 --- a/0033-Move-all-curses-calls-into-display-threads.patch +++ b/0038-Move-all-curses-calls-into-display-threads.patch @@ -1,7 +1,7 @@ From eb42e7eb07892e91939e3875a124d5f485697ae9 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 18 Nov 2024 08:04:04 -0800 -Subject: [PATCH] Move all curses calls into display threads +Subject: [PATCH 1/5] Move all curses calls into display threads Curses is not thread safe, but currently both the cons and the disp thread can issue curses calls concurrently. @@ -256,5 +256,5 @@ index f9d28de..f934406 100644 typedef struct _disp_ctl { -- -2.41.0 +2.49.0 diff --git a/0034-Avoid-race-on-submitting-display-commands.patch b/0039-Avoid-race-on-submitting-display-commands.patch similarity index 92% rename from 0034-Avoid-race-on-submitting-display-commands.patch rename to 0039-Avoid-race-on-submitting-display-commands.patch index 92e52bf..4abb880 100644 --- a/0034-Avoid-race-on-submitting-display-commands.patch +++ b/0039-Avoid-race-on-submitting-display-commands.patch @@ -1,7 +1,7 @@ From 8dfa30ea03111981ce5cbc793960688d93f17b68 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Tue, 19 Nov 2024 11:02:35 -0800 -Subject: [PATCH] Avoid race on submitting display commands +Subject: [PATCH 3/5] Avoid race on submitting display commands Doesn't work for quitting, but we can ignore it here. --- @@ -28,5 +28,5 @@ index 78bf9e9..c542b77 100644 (void) pthread_cond_signal(&s_disp_ctl.cond); } -- -2.41.0 +2.49.0 diff --git a/0040-Increase-PID-column-width.patch b/0040-Increase-PID-column-width.patch new file mode 100644 index 0000000..908b77c --- /dev/null +++ b/0040-Increase-PID-column-width.patch @@ -0,0 +1,210 @@ +From 5f303ce5c19c5d2f17970797ab467aa32dc93cdc Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Tue, 19 Nov 2024 10:29:44 -0800 +Subject: [PATCH 4/5] Increase PID column width + +Newer Linux distributions enable a >16bit pid_t, so need more digits to +display. + +Fixes #94 +--- + common/win.c | 44 ++++++++++++++++++++++---------------------- + 1 file changed, 22 insertions(+), 22 deletions(-) + +diff --git a/common/win.c b/common/win.c +index c3e8492..03d096d 100644 +--- a/common/win.c ++++ b/common/win.c +@@ -68,7 +68,7 @@ topnproc_caption_build(char *buf, int size) + case SORT_KEY_CPU: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_CPU); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RPI, + CAPTION_LPI, CAPTION_RL, CAPTION_CPI, tmp); + break; +@@ -76,7 +76,7 @@ topnproc_caption_build(char *buf, int size) + case SORT_KEY_CPI: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_CPI); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RPI, + CAPTION_LPI, CAPTION_RL, tmp, CAPTION_CPU); + break; +@@ -84,7 +84,7 @@ topnproc_caption_build(char *buf, int size) + case SORT_KEY_RPI: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_RPI); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, tmp, + CAPTION_LPI, CAPTION_RL, CAPTION_CPI, CAPTION_CPU); + break; +@@ -92,7 +92,7 @@ topnproc_caption_build(char *buf, int size) + case SORT_KEY_LPI: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_LPI); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RPI, + tmp, CAPTION_RL, CAPTION_CPI, CAPTION_CPU); + break; +@@ -100,14 +100,14 @@ topnproc_caption_build(char *buf, int size) + case SORT_KEY_RL: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_RL); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RPI, + CAPTION_LPI, tmp, CAPTION_CPI, CAPTION_CPU); + break; + + default: + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RPI, + CAPTION_LPI, CAPTION_RL, CAPTION_CPI, CAPTION_CPU); + break; +@@ -120,7 +120,7 @@ topnproc_data_build(char *buf, int size, topnproc_line_t *line) + win_countvalue_t *value = &line->value; + + (void) snprintf(buf, size, +- "%6d%15s%11.1f%11.1f%11.1f%11.2f%10.1f", ++ "%10d%15s%11.1f%11.1f%11.1f%11.2f%10.1f", + line->pid, line->proc_name, value->rpi, value->lpi, + value->rl, value->cpi, value->cpu * 100); + } +@@ -164,7 +164,7 @@ rawnum_caption_build(char *buf, int size) + case SORT_KEY_CPU: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_CPU); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, + CAPTION_LMA, CAPTION_RL, CAPTION_CPI, tmp); + break; +@@ -172,7 +172,7 @@ rawnum_caption_build(char *buf, int size) + case SORT_KEY_CPI: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_CPI); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, + CAPTION_LMA, CAPTION_RL, tmp, CAPTION_CPU); + break; +@@ -180,7 +180,7 @@ rawnum_caption_build(char *buf, int size) + case SORT_KEY_RMA: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_RMA); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, tmp, + CAPTION_LMA, CAPTION_RL, CAPTION_CPI, CAPTION_CPU); + break; +@@ -188,7 +188,7 @@ rawnum_caption_build(char *buf, int size) + case SORT_KEY_LMA: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_LMA); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, + tmp, CAPTION_RL, CAPTION_CPI, CAPTION_CPU); + break; +@@ -196,14 +196,14 @@ rawnum_caption_build(char *buf, int size) + case SORT_KEY_RL: + (void) snprintf(tmp, sizeof (tmp), "*%s", CAPTION_RL); + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, + CAPTION_LMA, tmp, CAPTION_CPI, CAPTION_CPU); + break; + + default: + (void) snprintf(buf, size, +- "%6s%15s%11s%11s%11s%11s%11s", ++ "%10s%15s%11s%11s%11s%11s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, + CAPTION_LMA, CAPTION_RL, CAPTION_CPI, CAPTION_CPU); + break; +@@ -216,7 +216,7 @@ rawnum_data_build(char *buf, int size, topnproc_line_t *line) + win_countvalue_t *value = &line->value; + + (void) snprintf(buf, size, +- "%6d%15s%11.1f%11.1f%11.1f%11.2f%10.1f", ++ "%10d%15s%11.1f%11.1f%11.1f%11.2f%10.1f", + line->pid, line->proc_name, value->rma, value->lma, + value->rl, value->cpi, value->cpu * 100); + } +@@ -1154,7 +1154,7 @@ static void + topnlwp_caption_build(char *buf, int size) + { + (void) snprintf(buf, size, +- "%6s%10s%10s%11s%11s%10s%10s%10s", ++ "%10s%10s%10s%11s%11s%10s%10s%10s", + CAPTION_LWP, CAPTION_RPI, CAPTION_LPI, + CAPTION_RMA, CAPTION_LMA, CAPTION_RL, + CAPTION_CPI, CAPTION_CPU); +@@ -1169,7 +1169,7 @@ topnlwp_data_build(char *buf, int size, topnlwp_line_t *line) + (void) snprintf(tmp, sizeof (tmp), "%d", line->lwpid); + + (void) snprintf(buf, size, +- "%6s%10.1f%10.1f%11.1f%11.1f%10.1f%10.2f%9.1f", ++ "%10s%10.1f%10.1f%11.1f%11.1f%10.1f%10.2f%9.1f", + tmp, value->rpi, value->lpi, value->rma, + value->lma, value->rl, value->cpi, value->cpu * 100); + } +@@ -2859,7 +2859,7 @@ pqos_cmt_proc_data_build(char *buf, int size, + snprintf(tmp, sizeof(tmp), "*%s", id); + + snprintf(buf, size, +- "%6s%15s%11.1f%11.1f%21.1f%10.1f", ++ "%10s%15s%11.1f%11.1f%21.1f%10.1f", + tmp, line->proc_name, + value->rma, value->lma, + ratio(line->llc_occupancy, +@@ -2970,12 +2970,12 @@ pqos_cmt_caption_build(int lwpid, char *buf, int size) + { + if (lwpid == 0) + snprintf(buf, size, +- "%6s%15s%11s%11s%21s%11s", ++ "%10s%15s%11s%11s%21s%11s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, CAPTION_LMA, + CAPTION_LLC_OCCUPANCY, CAPTION_CPU); + else + snprintf(buf, size, +- "%6s%15s%11s%11s%21s%11s", ++ "%10s%15s%11s%11s%21s%11s", + CAPTION_LWP, CAPTION_PROC, CAPTION_RMA, CAPTION_LMA, + CAPTION_LLC_OCCUPANCY, CAPTION_CPU); + } +@@ -3183,7 +3183,7 @@ pqos_mbm_proc_data_build(char *buf, int size, + ratio(line->localbw_scaled, 1048576)); + + snprintf(buf, size, +- "%6s%15s%10.1f%10.1f%14s%14s%9.1f", ++ "%10s%15s%10.1f%10.1f%14s%14s%9.1f", + id, line->proc_name, + value->rma, value->lma, + total_bw, local_bw, +@@ -3295,12 +3295,12 @@ pqos_mbm_caption_build(int lwpid, char *buf, int size) + { + if (lwpid == 0) + snprintf(buf, size, +- "%6s%15s%10s%10s%14s%14s%10s", ++ "%10s%15s%10s%10s%14s%14s%10s", + CAPTION_PID, CAPTION_PROC, CAPTION_RMA, CAPTION_LMA, + CAPTION_TOTAL_BW, CAPTION_LOCAL_BW, CAPTION_CPU); + else + snprintf(buf, size, +- "%6s%15s%10s%10s%14s%14s%10s", ++ "%10s%15s%10s%10s%14s%14s%10s", + CAPTION_LWP, CAPTION_PROC, CAPTION_RMA, CAPTION_LMA, + CAPTION_TOTAL_BW, CAPTION_LOCAL_BW, CAPTION_CPU); + } +-- +2.49.0 + diff --git a/0041-common-Ignore-samples-for-exiting-tasks.patch b/0041-common-Ignore-samples-for-exiting-tasks.patch new file mode 100644 index 0000000..339d7df --- /dev/null +++ b/0041-common-Ignore-samples-for-exiting-tasks.patch @@ -0,0 +1,37 @@ +From 636bf0ee924034d51e63a20325353f2e9384b3de Mon Sep 17 00:00:00 2001 +From: Sandipan Das +Date: Thu, 10 Jul 2025 11:57:03 +0530 +Subject: [PATCH 5/5] common: Ignore samples for exiting tasks + +After the inclusion of Linux commit 1d953111b648 ("perf/core: Don't +report zero PIDs for exiting tasks"), perf samples will report PID as +-1 for exiting tasks. + +Such samples lead to segmentation faults during process lookup when +proc_find_nolock() is called with -1 as the PID. Process data at the +the hash table index returned by PROC_HASHTBL_INDEX() is invalid and +any dereference of the corresponding track_proc_t pointer results in +a bad access. Hence, ignore samples for exiting tasks. + +Fixes: 972a9d0 ("Reconstruct code for better OS-independent.") +Signed-off-by: Sandipan Das +--- + common/os/pfwrapper.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/common/os/pfwrapper.c b/common/os/pfwrapper.c +index 10042d9..780458e 100644 +--- a/common/os/pfwrapper.c ++++ b/common/os/pfwrapper.c +@@ -497,7 +497,7 @@ ll_sample_read(struct perf_event_mmap_page *mhdr, int size, + * { u64 data_src; } + * }; + */ +- if (mmap_buffer_read(mhdr, &id, sizeof (id)) == -1) { ++ if (mmap_buffer_read(mhdr, &id, sizeof (id)) == -1 || id.pid == -1U) { + debug_print(NULL, 2, "ll_sample_read: read pid/tid failed.\n"); + goto L_EXIT; + } +-- +2.49.0 + diff --git a/numatop.spec b/numatop.spec index 13ddb04..af688d1 100644 --- a/numatop.spec +++ b/numatop.spec @@ -42,11 +42,13 @@ Patch29: 0029-common-use-mount-umount-system-calls-rather-than-usi.patch Patch30: 0030-common-remove-executing-commands-for-directory-and-f.patch Patch31: 0031-powerpc-util-fix-build-warning-cast-LHS-of-expressio.patch Patch32: 0032-common-os-map-Fix-overflow-warning.patch -Patch33: 0033-Move-all-curses-calls-into-display-threads.patch -Patch34: 0034-Avoid-race-on-submitting-display-commands.patch Patch35: 0035-Remove-EMR-specific-events-configuration.patch Patch36: 0036-Support-Intel-Granite-Rapids-platform.patch Patch37: 0037-Support-Intel-Sierra-Forest-platform.patch +Patch38: 0038-Move-all-curses-calls-into-display-threads.patch +Patch39: 0039-Avoid-race-on-submitting-display-commands.patch +Patch40: 0040-Increase-PID-column-width.patch +Patch41: 0041-common-Ignore-samples-for-exiting-tasks.patch BuildRequires: autoconf