aboutsummaryrefslogtreecommitdiffstats
path: root/samples/bpf/tracex2_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'samples/bpf/tracex2_user.c')
-rw-r--r--samples/bpf/tracex2_user.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/samples/bpf/tracex2_user.c b/samples/bpf/tracex2_user.c
index cd0241c1447a..ab5b19e68acf 100644
--- a/samples/bpf/tracex2_user.c
+++ b/samples/bpf/tracex2_user.c
@@ -37,6 +37,8 @@ struct hist_key {
37static void print_hist_for_pid(int fd, void *task) 37static void print_hist_for_pid(int fd, void *task)
38{ 38{
39 struct hist_key key = {}, next_key; 39 struct hist_key key = {}, next_key;
40 unsigned int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
41 long values[nr_cpus];
40 char starstr[MAX_STARS]; 42 char starstr[MAX_STARS];
41 long value; 43 long value;
42 long data[MAX_INDEX] = {}; 44 long data[MAX_INDEX] = {};
@@ -49,7 +51,10 @@ static void print_hist_for_pid(int fd, void *task)
49 key = next_key; 51 key = next_key;
50 continue; 52 continue;
51 } 53 }
52 bpf_lookup_elem(fd, &next_key, &value); 54 bpf_lookup_elem(fd, &next_key, values);
55 value = 0;
56 for (i = 0; i < nr_cpus; i++)
57 value += values[i];
53 ind = next_key.index; 58 ind = next_key.index;
54 data[ind] = value; 59 data[ind] = value;
55 if (value && ind > max_ind) 60 if (value && ind > max_ind)