Skip to content

Commit

Permalink
tools: remove unnecessary calls to bpf_probe_read
Browse files Browse the repository at this point in the history
Most of these calls have been rendered useless by a9f96c0 ("Recognize
context member dereferences despite array accesses (iovisor#1828)").
  • Loading branch information
pchaigno committed Jul 1, 2018
1 parent 44c28bf commit 8d78edd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
4 changes: 1 addition & 3 deletions tools/runqlat.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,9 @@
struct task_struct *prev = (struct task_struct *)ctx->args[1];
struct task_struct *next = (struct task_struct *)ctx->args[2];
u32 pid, tgid;
long state;
// ivcsw: treat like an enqueue event and store timestamp
bpf_probe_read(&state, sizeof(long), &prev->state);
if (state == TASK_RUNNING) {
if (prev->state == TASK_RUNNING) {
tgid = prev->tgid;
pid = prev->pid;
if (!(FILTER || pid == 0)) {
Expand Down
6 changes: 1 addition & 5 deletions tools/runqslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@
{
// TP_PROTO(struct task_struct *p)
struct task_struct *p = (struct task_struct *)ctx->args[0];
u32 tgid, pid;
bpf_probe_read(&tgid, sizeof(tgid), &p->tgid);
bpf_probe_read(&pid, sizeof(pid), &p->pid);
return trace_enqueue(tgid, pid);
return trace_enqueue(p->tgid, p->pid);
}
RAW_TRACEPOINT_PROBE(sched_wakeup_new)
Expand Down
8 changes: 4 additions & 4 deletions tools/tcpaccept.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@
if (sk_lingertime_offset - gso_max_segs_offset == 4)
// 4.10+ with little endian
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
bpf_probe_read(&protocol, 1, (void *)((u64)&newsk->sk_gso_max_segs) - 3);
protocol = *(u8 *)((u64)&newsk->sk_gso_max_segs - 3);
else
// pre-4.10 with little endian
bpf_probe_read(&protocol, 1, (void *)((u64)&newsk->sk_wmem_queued) - 3);
protocol = *(u8 *)((u64)&newsk->sk_wmem_queued - 3);
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
// 4.10+ with big endian
bpf_probe_read(&protocol, 1, (void *)((u64)&newsk->sk_gso_max_segs) - 1);
protocol = *(u8 *)((u64)&newsk->sk_gso_max_segs - 1);
else
// pre-4.10 with big endian
bpf_probe_read(&protocol, 1, (void *)((u64)&newsk->sk_wmem_queued) - 1);
protocol = *(u8 *)((u64)&newsk->sk_wmem_queued - 1);
#else
# error "Fix your compiler's __BYTE_ORDER__?!"
#endif
Expand Down
22 changes: 7 additions & 15 deletions tools/tcptracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@
u16 sport = sockp->inet_sport;
u16 dport = skp->__sk_common.skc_dport;
#ifdef CONFIG_NET_NS
possible_net_t skc_net = skp->__sk_common.skc_net;
bpf_probe_read(&net_ns_inum, sizeof(net_ns_inum), &skc_net.net->ns.inum);
net_ns_inum = skp->__sk_common.skc_net.net->ns.inum;
#endif
##FILTER_NETNS##
Expand All @@ -144,8 +143,7 @@
u16 sport = sockp->inet_sport;
u16 dport = skp->__sk_common.skc_dport;
#ifdef CONFIG_NET_NS
possible_net_t skc_net = skp->__sk_common.skc_net;
bpf_probe_read(&net_ns_inum, sizeof(net_ns_inum), &skc_net.net->ns.inum);
net_ns_inum = skp->__sk_common.skc_net.net->ns.inum;
#endif
bpf_probe_read(&saddr, sizeof(saddr),
skp->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
Expand Down Expand Up @@ -430,16 +428,12 @@
u32 net_ns_inum = 0;
u8 ipver = 0;
bpf_probe_read(&dport, sizeof(dport), &newsk->__sk_common.skc_dport);
bpf_probe_read(&lport, sizeof(lport), &newsk->__sk_common.skc_num);
dport = newsk->__sk_common.skc_dport;
lport = newsk->__sk_common.skc_num;
// Get network namespace id, if kernel supports it
#ifdef CONFIG_NET_NS
possible_net_t skc_net = { };
bpf_probe_read(&skc_net, sizeof(skc_net), &newsk->__sk_common.skc_net);
bpf_probe_read(&net_ns_inum, sizeof(net_ns_inum), &skc_net.net->ns.inum);
#else
net_ns_inum = 0;
net_ns_inum = newsk->__sk_common.skc_net.net->ns.inum;
#endif
##FILTER_NETNS##
Expand All @@ -455,10 +449,8 @@
evt4.pid = pid >> 32;
evt4.ip = ipver;
bpf_probe_read(&evt4.saddr, sizeof(evt4.saddr),
&newsk->__sk_common.skc_rcv_saddr);
bpf_probe_read(&evt4.daddr, sizeof(evt4.daddr),
&newsk->__sk_common.skc_daddr);
evt4.saddr = newsk->__sk_common.skc_rcv_saddr;
evt4.daddr = newsk->__sk_common.skc_daddr;
evt4.sport = lport;
evt4.dport = ntohs(dport);
Expand Down

0 comments on commit 8d78edd

Please sign in to comment.