OSDN Git Service

tools/bpftool: recognize bpf_prog_info run_time_ns and run_cnt
authorAlexei Starovoitov <ast@kernel.org>
Mon, 25 Feb 2019 22:28:42 +0000 (14:28 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 27 Feb 2019 16:22:51 +0000 (17:22 +0100)
$ bpftool p s
1: kprobe  tag a56587d488d216c9  gpl run_time_ns 79786 run_cnt 8
loaded_at 2019-02-22T12:22:51-0800  uid 0
xlated 352B  not jited  memlock 4096B

$ bpftool --json --pretty p s
[{
        "id": 1,
        "type": "kprobe",
        "tag": "a56587d488d216c9",
        "gpl_compatible": true,
        "run_time_ns": 79786,
        "run_cnt": 8,
        "loaded_at": 1550866971,
        "uid": 0,
        "bytes_xlated": 352,
        "jited": false,
        "bytes_memlock": 4096
    }
]

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/Documentation/bpftool-prog.rst
tools/bpf/bpftool/prog.c

index 12bc1e2..9386bd6 100644 (file)
@@ -171,7 +171,7 @@ EXAMPLES
 
 ::
 
-    10: xdp  name some_prog  tag 005a3d2123620c8b  gpl
+    10: xdp  name some_prog  tag 005a3d2123620c8b  gpl run_time_ns 81632 run_cnt 10
             loaded_at 2017-09-29T20:11:00+0000  uid 0
             xlated 528B  jited 370B  memlock 4096B  map_ids 10
 
@@ -184,6 +184,8 @@ EXAMPLES
             "type": "xdp",
             "tag": "005a3d2123620c8b",
             "gpl_compatible": true,
+            "run_time_ns": 81632,
+            "run_cnt": 10,
             "loaded_at": 1506715860,
             "uid": 0,
             "bytes_xlated": 528,
index db978c8..0c35dd5 100644 (file)
@@ -214,6 +214,10 @@ static void print_prog_json(struct bpf_prog_info *info, int fd)
                     info->tag[4], info->tag[5], info->tag[6], info->tag[7]);
 
        jsonw_bool_field(json_wtr, "gpl_compatible", info->gpl_compatible);
+       if (info->run_time_ns) {
+               jsonw_uint_field(json_wtr, "run_time_ns", info->run_time_ns);
+               jsonw_uint_field(json_wtr, "run_cnt", info->run_cnt);
+       }
 
        print_dev_json(info->ifindex, info->netns_dev, info->netns_ino);
 
@@ -277,6 +281,9 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd)
        fprint_hex(stdout, info->tag, BPF_TAG_SIZE, "");
        print_dev_plain(info->ifindex, info->netns_dev, info->netns_ino);
        printf("%s", info->gpl_compatible ? "  gpl" : "");
+       if (info->run_time_ns)
+               printf(" run_time_ns %lld run_cnt %lld",
+                      info->run_time_ns, info->run_cnt);
        printf("\n");
 
        if (info->load_time) {