Blame SOURCES/bcc-0.19.0-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch

fd9488
From c610314e8f8265317bf54ef518df48809834feba Mon Sep 17 00:00:00 2001
fd9488
From: Jerome Marchand <jmarchan@redhat.com>
fd9488
Date: Thu, 14 Oct 2021 12:01:01 +0200
fd9488
Subject: [PATCH] Handle renaming of task_struct_>state field on RHEL 9
fd9488
fd9488
There has been some cleanup of task_struct's state field and to catch
fd9488
any place that has been missed in the conversion, it has been renamed
fd9488
__state.
fd9488
---
fd9488
 tools/cpudist.py     | 2 +-
fd9488
 tools/offcputime.py  | 4 ++--
fd9488
 tools/offwaketime.py | 4 ++--
fd9488
 tools/runqlat.py     | 4 ++--
fd9488
 tools/runqslower.py  | 4 ++--
fd9488
 5 files changed, 9 insertions(+), 9 deletions(-)
fd9488
fd9488
diff --git a/tools/cpudist.py b/tools/cpudist.py
fd9488
index eb04f590..ba36ba76 100755
fd9488
--- a/tools/cpudist.py
fd9488
+++ b/tools/cpudist.py
fd9488
@@ -101,7 +101,7 @@ int sched_switch(struct pt_regs *ctx, struct task_struct *prev)
fd9488
     u32 tgid = pid_tgid >> 32, pid = pid_tgid;
fd9488
 
fd9488
 #ifdef ONCPU
fd9488
-    if (prev->state == TASK_RUNNING) {
fd9488
+    if (prev->__state == TASK_RUNNING) {
fd9488
 #else
fd9488
     if (1) {
fd9488
 #endif
fd9488
diff --git a/tools/offcputime.py b/tools/offcputime.py
fd9488
index 128c6496..b93e78d2 100755
fd9488
--- a/tools/offcputime.py
fd9488
+++ b/tools/offcputime.py
fd9488
@@ -205,10 +205,10 @@ thread_context = ""
fd9488
     thread_context = "all threads"
fd9488
     thread_filter = '1'
fd9488
 if args.state == 0:
fd9488
-    state_filter = 'prev->state == 0'
fd9488
+    state_filter = 'prev->__state == 0'
fd9488
 elif args.state:
fd9488
     # these states are sometimes bitmask checked
fd9488
-    state_filter = 'prev->state & %d' % args.state
fd9488
+    state_filter = 'prev->__state & %d' % args.state
fd9488
 else:
fd9488
     state_filter = '1'
fd9488
 bpf_text = bpf_text.replace('THREAD_FILTER', thread_filter)
fd9488
diff --git a/tools/offwaketime.py b/tools/offwaketime.py
fd9488
index 753eee97..722c0381 100755
fd9488
--- a/tools/offwaketime.py
fd9488
+++ b/tools/offwaketime.py
fd9488
@@ -254,10 +254,10 @@ int oncpu(struct pt_regs *ctx, struct task_struct *p) {
fd9488
 else:
fd9488
     thread_filter = '1'
fd9488
 if args.state == 0:
fd9488
-    state_filter = 'p->state == 0'
fd9488
+    state_filter = 'p->__state == 0'
fd9488
 elif args.state:
fd9488
     # these states are sometimes bitmask checked
fd9488
-    state_filter = 'p->state & %d' % args.state
fd9488
+    state_filter = 'p->__state & %d' % args.state
fd9488
 else:
fd9488
     state_filter = '1'
fd9488
 bpf_text = bpf_text.replace('THREAD_FILTER', thread_filter)
fd9488
diff --git a/tools/runqlat.py b/tools/runqlat.py
fd9488
index b13ff2d1..8e443c3c 100755
fd9488
--- a/tools/runqlat.py
fd9488
+++ b/tools/runqlat.py
fd9488
@@ -116,7 +116,7 @@ int trace_run(struct pt_regs *ctx, struct task_struct *prev)
fd9488
     u32 pid, tgid;
fd9488
 
fd9488
     // ivcsw: treat like an enqueue event and store timestamp
fd9488
-    if (prev->state == TASK_RUNNING) {
fd9488
+    if (prev->__state == TASK_RUNNING) {
fd9488
         tgid = prev->tgid;
fd9488
         pid = prev->pid;
fd9488
         if (!(FILTER || pid == 0)) {
fd9488
@@ -170,7 +170,7 @@ RAW_TRACEPOINT_PROBE(sched_switch)
fd9488
     u32 pid, tgid;
fd9488
 
fd9488
     // ivcsw: treat like an enqueue event and store timestamp
fd9488
-    if (prev->state == TASK_RUNNING) {
fd9488
+    if (prev->__state == TASK_RUNNING) {
fd9488
         tgid = prev->tgid;
fd9488
         pid = prev->pid;
fd9488
         if (!(FILTER || pid == 0)) {
fd9488
diff --git a/tools/runqslower.py b/tools/runqslower.py
fd9488
index 6df98d9f..ba71e5d3 100755
fd9488
--- a/tools/runqslower.py
fd9488
+++ b/tools/runqslower.py
fd9488
@@ -112,7 +112,7 @@ int trace_run(struct pt_regs *ctx, struct task_struct *prev)
fd9488
     u32 pid, tgid;
fd9488
 
fd9488
     // ivcsw: treat like an enqueue event and store timestamp
fd9488
-    if (prev->state == TASK_RUNNING) {
fd9488
+    if (prev->__state == TASK_RUNNING) {
fd9488
         tgid = prev->tgid;
fd9488
         pid = prev->pid;
fd9488
         u64 ts = bpf_ktime_get_ns();
fd9488
@@ -178,7 +178,7 @@ RAW_TRACEPOINT_PROBE(sched_switch)
fd9488
     long state;
fd9488
 
fd9488
     // ivcsw: treat like an enqueue event and store timestamp
fd9488
-    bpf_probe_read_kernel(&state, sizeof(long), (const void *)&prev->state);
fd9488
+    bpf_probe_read_kernel(&state, sizeof(long), (const void *)&prev->__state);
fd9488
     if (state == TASK_RUNNING) {
fd9488
         bpf_probe_read_kernel(&tgid, sizeof(prev->tgid), &prev->tgid);
fd9488
         bpf_probe_read_kernel(&pid, sizeof(prev->pid), &prev->pid);
fd9488
-- 
fd9488
2.31.1
fd9488