bcc/bcc-0.20.0-Update-cpudist.py.patch
Jerome Marchand 019ff871c7 Misc fixes (bz1992430)
- Sync with latest libbpf (fixes multiple BPF_F_BROADCAST breakages)
- Fix cpudist, mdflush, readahead, threadsnoop.
- Handle the renaming of task_struct_>state field on RHEL 9 (fixes
offcputime, offwaketime, runqlat and runqslower)
- Drop several tools that relies on features disabled on RHEL

Resolves: rhbz#1992430
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2021-10-15 10:57:36 +02:00

42 lines
1.2 KiB
Diff

From ad56e8a5a722df2ac2a5b3ea0822fd78f9a6fe51 Mon Sep 17 00:00:00 2001
From: Nick-nizhen <74173686+Nick-nizhen@users.noreply.github.com>
Date: Thu, 27 May 2021 13:21:59 +0800
Subject: [PATCH] Update cpudist.py
When calculating the ONCPU time, prev has left the CPU already. It is not necessary to judge whether the process state is TASK_RUNNING or not.
---
tools/cpudist.py | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/tools/cpudist.py b/tools/cpudist.py
index eb04f590..b5a6a978 100755
--- a/tools/cpudist.py
+++ b/tools/cpudist.py
@@ -100,19 +100,13 @@ int sched_switch(struct pt_regs *ctx, struct task_struct *prev)
u64 pid_tgid = bpf_get_current_pid_tgid();
u32 tgid = pid_tgid >> 32, pid = pid_tgid;
+ u32 prev_pid = prev->pid;
+ u32 prev_tgid = prev->tgid;
#ifdef ONCPU
- if (prev->state == TASK_RUNNING) {
+ update_hist(prev_tgid, prev_pid, ts);
#else
- if (1) {
+ store_start(prev_tgid, prev_pid, ts);
#endif
- u32 prev_pid = prev->pid;
- u32 prev_tgid = prev->tgid;
-#ifdef ONCPU
- update_hist(prev_tgid, prev_pid, ts);
-#else
- store_start(prev_tgid, prev_pid, ts);
-#endif
- }
BAIL:
#ifdef ONCPU
--
2.31.1