From a28ad059edf6f74acc124fde4b4934a2fc410a35 Mon Sep 17 00:00:00 2001 From: DavadDi Date: Mon, 17 Feb 2020 00:08:12 +0800 Subject: [PATCH] fix pid filter bug 1. Wirte a simple go, just print pid and get some website. func main() { pid := os.Getpid() fmt.Println(pid) response, err := http.Get("http://www.baidu.com") .... } ./main 3581 2. But when run `tcpconnlat`, we just go tid 3585, (not pid 3581) #./tcpconnlat PID COMM IP SADDR DADDR DPORT LAT(ms) 3585 main 4 10.0.2.15 180.101.49.11 80 60.68 3. So run `./tcpconnlat -p 3581` not work I have tested this situation under kernel 3.10 and 5.0.9. --- tools/tcpconnlat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tcpconnlat.py b/tools/tcpconnlat.py index 8f686211dcb0..be6bbbfa1782 100755 --- a/tools/tcpconnlat.py +++ b/tools/tcpconnlat.py @@ -105,7 +105,7 @@ def positive_float(val): int trace_connect(struct pt_regs *ctx, struct sock *sk) { - u32 pid = bpf_get_current_pid_tgid(); + u32 pid = bpf_get_current_pid_tgid() >> 32; FILTER struct info_t info = {.pid = pid}; info.ts = bpf_ktime_get_ns();