Commit 9858ca5e authored by Evgeny Vereshchagin's avatar Evgeny Vereshchagin

Fix tools[/old]/offcputime -p PID

We should extract pid before THREAD_FILTER
parent c419edf4
...@@ -96,12 +96,11 @@ BPF_HASH(start, u32); ...@@ -96,12 +96,11 @@ BPF_HASH(start, u32);
BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE) BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE)
int oncpu(struct pt_regs *ctx, struct task_struct *prev) { int oncpu(struct pt_regs *ctx, struct task_struct *prev) {
u32 pid; u32 pid = prev->pid;
u64 ts, *tsp; u64 ts, *tsp;
// record previous thread sleep time // record previous thread sleep time
if (THREAD_FILTER) { if (THREAD_FILTER) {
pid = prev->pid;
ts = bpf_ktime_get_ns(); ts = bpf_ktime_get_ns();
start.update(&pid, &ts); start.update(&pid, &ts);
} }
......
...@@ -89,12 +89,11 @@ static u64 get_frame(u64 *bp) { ...@@ -89,12 +89,11 @@ static u64 get_frame(u64 *bp) {
} }
int oncpu(struct pt_regs *ctx, struct task_struct *prev) { int oncpu(struct pt_regs *ctx, struct task_struct *prev) {
u32 pid; u32 pid = prev->pid;
u64 ts, *tsp; u64 ts, *tsp;
// record previous thread sleep time // record previous thread sleep time
if (FILTER) { if (FILTER) {
pid = prev->pid;
ts = bpf_ktime_get_ns(); ts = bpf_ktime_get_ns();
start.update(&pid, &ts); start.update(&pid, &ts);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment