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

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