Blame SOURCES/bcc-0.20.0-Update-cpudist.py.patch

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