summaryrefslogtreecommitdiffstats
path: root/samples/bpf/tracex2_user.c
diff options
context:
space:
mode:
authorAlexei Starovoitov2016-02-02 07:39:58 +0100
committerDavid S. Miller2016-02-06 09:34:36 +0100
commit3059303f59cf90a84e7fdef154ff0b215bcfaa97 (patch)
treebacdf1b8025256fc591b1fd935a99f0b6af7466f /samples/bpf/tracex2_user.c
parentsamples/bpf: unit test for BPF_MAP_TYPE_PERCPU_ARRAY (diff)
downloadkernel-qcow2-linux-3059303f59cf90a84e7fdef154ff0b215bcfaa97.tar.gz
kernel-qcow2-linux-3059303f59cf90a84e7fdef154ff0b215bcfaa97.tar.xz
kernel-qcow2-linux-3059303f59cf90a84e7fdef154ff0b215bcfaa97.zip
samples/bpf: update tracex[23] examples to use per-cpu maps
Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
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 {
static void print_hist_for_pid(int fd, void *task)
{
struct hist_key key = {}, next_key;
+ unsigned int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
+ long values[nr_cpus];
char starstr[MAX_STARS];
long value;
long data[MAX_INDEX] = {};
@@ -49,7 +51,10 @@ static void print_hist_for_pid(int fd, void *task)
key = next_key;
continue;
}
- bpf_lookup_elem(fd, &next_key, &value);
+ bpf_lookup_elem(fd, &next_key, values);
+ value = 0;
+ for (i = 0; i < nr_cpus; i++)
+ value += values[i];
ind = next_key.index;
data[ind] = value;
if (value && ind > max_ind)