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

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