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

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