Skip to content

Commit 4799824

Browse files
durgajagadeeshdj_palli
andauthored
numatop: update to 2.4 (#11596)
Co-authored-by: dj_palli <dj_palli@microsoft.com>
1 parent de7c633 commit 4799824

13 files changed

Lines changed: 420 additions & 97 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 06c6d857654fdd4230604b4cd4cc2c127757574d Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 22:57:13 +0100
4+
Subject: [PATCH 1/9] common: Use sym_type_t in elf64_binary_read() signature
5+
6+
This silences the enum-int-mismatch warning.
7+
---
8+
common/os/sym.c | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/common/os/sym.c b/common/os/sym.c
12+
index 9ead1fb..f0b5706 100644
13+
--- a/common/os/sym.c
14+
+++ b/common/os/sym.c
15+
@@ -463,7 +463,7 @@ L_EXIT:
16+
}
17+
18+
static int
19+
-elf64_binary_read(sym_binary_t *binary, unsigned int sym_type)
20+
+elf64_binary_read(sym_binary_t *binary, sym_type_t sym_type)
21+
{
22+
Elf64_Ehdr ehdr;
23+
Elf64_Shdr shdr;
24+
--
25+
2.44.0
26+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From 6316116c1e05031e53a1f5196ed92559c3123cc2 Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:00:10 +0100
4+
Subject: [PATCH 2/9] common: Add format strings to mvwprintw() calls
5+
6+
This silences the format-security warning.
7+
---
8+
common/reg.c | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/common/reg.c b/common/reg.c
12+
index 1a87161..ad37274 100644
13+
--- a/common/reg.c
14+
+++ b/common/reg.c
15+
@@ -240,7 +240,7 @@ reg_line_write(win_reg_t *r, int line, reg_align_t align, char *content)
16+
}
17+
18+
if (len > 0) {
19+
- (void) mvwprintw(r->hdl, line, pos_x, content);
20+
+ (void) mvwprintw(r->hdl, line, pos_x, "%s", content);
21+
}
22+
23+
if (r->mode != 0) {
24+
@@ -267,7 +267,7 @@ reg_highlight_write(win_reg_t *r, int line, int align, char *content)
25+
}
26+
27+
if (len > 0) {
28+
- (void) mvwprintw(r->hdl, line, pos_x, content);
29+
+ (void) mvwprintw(r->hdl, line, pos_x, "%s", content);
30+
}
31+
32+
(void) wattroff(r->hdl, A_REVERSE | A_BOLD);
33+
--
34+
2.44.0
35+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 79c4cbbdfb603cf52f2b1416d2e1048074eb5a2f Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:02:15 +0100
4+
Subject: [PATCH 3/9] common: Remove unnecessary temp buffer
5+
6+
---
7+
common/win.c | 5 +----
8+
1 file changed, 1 insertion(+), 4 deletions(-)
9+
10+
diff --git a/common/win.c b/common/win.c
11+
index d0a8f3b..cdc5817 100644
12+
--- a/common/win.c
13+
+++ b/common/win.c
14+
@@ -484,14 +484,11 @@ topnproc_data_show(dyn_win_t *win)
15+
static void
16+
load_msg_show(void)
17+
{
18+
- char content[64];
19+
win_reg_t r;
20+
21+
- (void) snprintf(content, sizeof (content), "Loading ...");
22+
-
23+
(void) reg_init(&r, 0, 1, g_scr_width, g_scr_height - 1, A_BOLD);
24+
reg_erase(&r);
25+
- reg_line_write(&r, 1, ALIGN_LEFT, content);
26+
+ reg_line_write(&r, 1, ALIGN_LEFT, "Loading ...");
27+
reg_refresh(&r);
28+
reg_win_destroy(&r);
29+
}
30+
--
31+
2.44.0
32+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 5e8f0af6241fdadc7dd52a26c18df0789ebf03e8 Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:03:02 +0100
4+
Subject: [PATCH 4/9] common: Use memcpy() to the process name to a line
5+
6+
The copy will either collect the whole string, and potentially a little
7+
more, but from a safe location, or a truncated string with a null char
8+
guaranteed by the memset() call above.
9+
10+
This silences the stringop-truncation warning.
11+
---
12+
common/win.c | 9 +++------
13+
1 file changed, 3 insertions(+), 6 deletions(-)
14+
15+
diff --git a/common/win.c b/common/win.c
16+
index cdc5817..d97da43 100644
17+
--- a/common/win.c
18+
+++ b/common/win.c
19+
@@ -355,8 +355,7 @@ topnproc_data_save(track_proc_t *proc, int intval, topnproc_line_t *line)
20+
/*
21+
* Cut off the process name if it's too long.
22+
*/
23+
- (void) strncpy(line->proc_name, proc->name, sizeof (line->proc_name));
24+
- line->proc_name[WIN_PROCNAME_SIZE - 1] = 0;
25+
+ memcpy(line->proc_name, proc->name, sizeof (line->proc_name) - 1);
26+
line->pid = proc->pid;
27+
line->nlwp = proc_nlwp(proc);
28+
29+
@@ -2892,8 +2891,7 @@ pqos_cmt_proc_data_save(track_proc_t *proc, track_lwp_t *lwp, int intval,
30+
{
31+
(void) memset(line, 0, sizeof (pqos_cmt_proc_line_t));
32+
33+
- (void) strncpy(line->proc_name, proc->name, sizeof (line->proc_name));
34+
- line->proc_name[WIN_PROCNAME_SIZE - 1] = 0;
35+
+ memcpy(line->proc_name, proc->name, sizeof (line->proc_name) - 1);
36+
line->pid = proc->pid;
37+
line->nlwp = proc_nlwp(proc);
38+
39+
@@ -3216,8 +3214,7 @@ pqos_mbm_proc_data_save(track_proc_t *proc, track_lwp_t *lwp, int intval,
40+
{
41+
(void) memset(line, 0, sizeof (pqos_mbm_proc_line_t));
42+
43+
- (void) strncpy(line->proc_name, proc->name, sizeof (line->proc_name));
44+
- line->proc_name[WIN_PROCNAME_SIZE - 1] = 0;
45+
+ memcpy(line->proc_name, proc->name, sizeof (line->proc_name) - 1);
46+
line->pid = proc->pid;
47+
line->nlwp = proc_nlwp(proc);
48+
49+
--
50+
2.44.0
51+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From c46ebd47907a77bfbcfa5ac8dacf7536102ae3af Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:07:07 +0100
4+
Subject: [PATCH 5/9] common: Replace malloc()+strncpy() with strdup()
5+
6+
This silences the stringop-truncation warning.
7+
---
8+
common/os/os_util.c | 4 +---
9+
1 file changed, 1 insertion(+), 3 deletions(-)
10+
11+
diff --git a/common/os/os_util.c b/common/os/os_util.c
12+
index f442729..3fdb4ca 100644
13+
--- a/common/os/os_util.c
14+
+++ b/common/os/os_util.c
15+
@@ -387,12 +387,10 @@ str_int_extract(char *str, int *arr, int arr_size, int *num)
16+
int len = strlen(str);
17+
boolean_t ret = B_FALSE;
18+
19+
- if ((scopy = malloc(len + 1)) == NULL) {
20+
+ if ((scopy = strdup(str)) == NULL) {
21+
return (B_FALSE);
22+
}
23+
24+
- strncpy(scopy, str, len);
25+
- scopy[len] = 0;
26+
cur = scopy;
27+
28+
while (cur < (scopy + len)) {
29+
--
30+
2.44.0
31+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
From 48a9a5597c638ca580458753fba564f0cfe248ea Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:11:13 +0100
4+
Subject: [PATCH 6/9] common: Build node string with bound checks
5+
6+
A print_buf() function is added to keep track of progress inside the s1
7+
buffer and the remaining space. With s1 acting as a cursor and vsnprintf
8+
taking care of formatting, the temp buffers s2 and s3 are no longer
9+
needed.
10+
11+
This silences the stringop-overflow warning.
12+
---
13+
common/os/os_win.c | 44 ++++++++++++++++++++++++++++++--------------
14+
1 file changed, 30 insertions(+), 14 deletions(-)
15+
16+
diff --git a/common/os/os_win.c b/common/os/os_win.c
17+
index de198ca..29afc19 100644
18+
--- a/common/os/os_win.c
19+
+++ b/common/os/os_win.c
20+
@@ -29,6 +29,7 @@
21+
#include <inttypes.h>
22+
#include <stdlib.h>
23+
#include <sys/types.h>
24+
+#include <stdarg.h>
25+
#include <stdio.h>
26+
#include <unistd.h>
27+
#include <string.h>
28+
@@ -105,6 +106,28 @@ cpuid_cmp(const void *a, const void *b)
29+
return (0);
30+
}
31+
32+
+static void
33+
+print_buf(char **destp, int *sizep, const char *fmt, ...)
34+
+{
35+
+ va_list ap;
36+
+ int len;
37+
+
38+
+ if (*sizep <= 0)
39+
+ return;
40+
+
41+
+ va_start(ap, fmt);
42+
+ len = vsnprintf(*destp, *sizep, fmt, ap);
43+
+ va_end(ap);
44+
+
45+
+ if (len >= *sizep) {
46+
+ *sizep = 0;
47+
+ return;
48+
+ }
49+
+
50+
+ *destp += len;
51+
+ *sizep -= len;
52+
+}
53+
+
54+
/*
55+
* Build a readable string of CPU ID and try to reduce the string length. e.g.
56+
* For cpu1, cpu2, cpu3, cpu4, the string is "CPU(1-4)",
57+
@@ -113,7 +136,6 @@ cpuid_cmp(const void *a, const void *b)
58+
static void
59+
node_cpu_string(node_t *node, char *s1, int size)
60+
{
61+
- char s2[128], s3[128];
62+
int i, j, k, l, cpuid_start;
63+
int *cpuid_arr;
64+
int ncpus;
65+
@@ -140,8 +162,7 @@ node_cpu_string(node_t *node, char *s1, int size)
66+
cpuid_start = cpuid_arr[0];
67+
68+
if (ncpus == 1) {
69+
- (void) snprintf(s2, sizeof (s2), "%d", cpuid_start);
70+
- (void) strncat(s1, s2, strlen(s2));
71+
+ (void) snprintf(s1, size, "%d", cpuid_start);
72+
free(cpuid_arr);
73+
return;
74+
}
75+
@@ -154,33 +175,28 @@ node_cpu_string(node_t *node, char *s1, int size)
76+
if (cpuid_arr[j] != cpuid_start + l) {
77+
if (k < ncpus) {
78+
if (l == 1) {
79+
- (void) snprintf(s2, sizeof (s2), "%d ", cpuid_start);
80+
+ print_buf(&s1, &size, "%d ", cpuid_start);
81+
} else {
82+
- (void) snprintf(s2, sizeof (s2),
83+
+ print_buf(&s1, &size,
84+
"%d-%d ", cpuid_start, cpuid_start + l - 1);
85+
}
86+
} else {
87+
if (l == 1) {
88+
- (void) snprintf(s2, sizeof (s2), "%d",
89+
- cpuid_start);
90+
+ print_buf(&s1, &size, "%d", cpuid_start);
91+
} else {
92+
- (void) snprintf(s2, sizeof (s2), "%d-%d",
93+
+ print_buf(&s1, &size, "%d-%d",
94+
cpuid_start, cpuid_start + l - 1);
95+
}
96+
97+
- (void) snprintf(s3, sizeof (s3), " %d",
98+
- cpuid_arr[j]);
99+
- (void) strncat(s2, s3, strlen(s3));
100+
+ print_buf(&s1, &size, " %d", cpuid_arr[j]);
101+
}
102+
103+
- (void) strncat(s1, s2, strlen(s2));
104+
cpuid_start = cpuid_arr[j];
105+
l = 1;
106+
} else {
107+
if (k == ncpus) {
108+
- (void) snprintf(s2, sizeof (s2), "%d-%d",
109+
+ print_buf(&s1, &size, "%d-%d",
110+
cpuid_start, cpuid_start + l);
111+
- (void) strncat(s1, s2, strlen(s2));
112+
} else {
113+
l++;
114+
}
115+
--
116+
2.44.0
117+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From e21a7f17997f2e611e8f706761065c8ec6576f5c Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:16:27 +0100
4+
Subject: [PATCH 7/9] common: Increase node string buffer size
5+
6+
Since the maximum number of CPUs was doubled, it might be reasonable to
7+
double the size of the buffer for the string representation.
8+
9+
Refs 6f6cc3b24d84c413556639b64a62aca6ad0b21cc
10+
---
11+
common/os/os_win.c | 2 +-
12+
1 file changed, 1 insertion(+), 1 deletion(-)
13+
14+
diff --git a/common/os/os_win.c b/common/os/os_win.c
15+
index 29afc19..c0de320 100644
16+
--- a/common/os/os_win.c
17+
+++ b/common/os/os_win.c
18+
@@ -222,7 +222,7 @@ nodedetail_line_show(win_reg_t *reg, char *title, char *value, int line)
19+
void
20+
os_nodedetail_data(dyn_nodedetail_t *dyn, win_reg_t *seg)
21+
{
22+
- char s1[256], s2[32];
23+
+ char s1[512], s2[32];
24+
node_t *node;
25+
win_countvalue_t value;
26+
node_meminfo_t meminfo;
27+
--
28+
2.44.0
29+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From e0f2421ecf7bd9b4783901eafea1d9f386c025ac Mon Sep 17 00:00:00 2001
2+
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
3+
Date: Mon, 4 Mar 2024 23:19:41 +0100
4+
Subject: [PATCH 8/9] x86: Add missing fields to s_emr_config
5+
6+
It looks as if EMR support had been authored before #66 was merged,
7+
leading to a mismatch between the struct definition and this array
8+
initialization.
9+
10+
This silences the missing-field-initializers warning.
11+
12+
Refs d3fcffc6a9cc2ad61b6f9a902796cb317bec266a
13+
Refs #66
14+
---
15+
x86/skl.c | 10 +++++-----
16+
1 file changed, 5 insertions(+), 5 deletions(-)
17+
18+
diff --git a/x86/skl.c b/x86/skl.c
19+
index 17cfbcc..a80a868 100644
20+
--- a/x86/skl.c
21+
+++ b/x86/skl.c
22+
@@ -64,11 +64,11 @@ static plat_event_config_t s_spr_config[PERF_COUNT_NUM] = {
23+
};
24+
25+
static plat_event_config_t s_emr_config[PERF_COUNT_NUM] = {
26+
- { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0x53, 0, "cpu_clk_unhalted.core" },
27+
- { PERF_TYPE_RAW, 0x012A, 0x53, 0x730000001, "off_core_response_0" },
28+
- { PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, 0x53, 0, "cpu_clk_unhalted.ref" },
29+
- { PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, 0x53, 0, "instr_retired.any" },
30+
- { PERF_TYPE_RAW, 0x012B, 0x53, 0x104000001, "off_core_response_1" }
31+
+ { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0x53, 0, 0, 0, "cpu_clk_unhalted.core" },
32+
+ { PERF_TYPE_RAW, 0x012A, 0x53, 0x730000001, 0, 0, "off_core_response_0" },
33+
+ { PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, 0x53, 0, 0, 0, "cpu_clk_unhalted.ref" },
34+
+ { PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, 0x53, 0, 0, 0, "instr_retired.any" },
35+
+ { PERF_TYPE_RAW, 0x012B, 0x53, 0x104000001, 0, 0, "off_core_response_1" }
36+
};
37+
38+
static plat_event_config_t s_skl_ll = {
39+
--
40+
2.44.0
41+

SPECS-EXTENDED/numatop/as-needed.patch

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)