|
|
6236aa |
commit 0bd97a8061c2ebbe792da8b662c5d19b2f1af02c
|
|
|
6236aa |
Author: William Cohen <wcohen@redhat.com>
|
|
|
6236aa |
Date: Mon Sep 13 21:32:38 2021 -0400
|
|
|
6236aa |
|
|
|
6236aa |
Use task_state tapset function to avoid task_struct changes
|
|
|
6236aa |
|
|
|
6236aa |
The Linux 5.14 kernel's task_struct changed the state field to
|
|
|
6236aa |
__state. The task_state tapset function selects the appropriate
|
|
|
6236aa |
version. Make the scheduler.stp tapset and schedtimes.stp example use
|
|
|
6236aa |
the task_state function rather than directly trying to access the
|
|
|
6236aa |
task_struct state field (and get it wrong for newer kernels).
|
|
|
6236aa |
|
|
|
6236aa |
diff --git a/tapset/linux/scheduler.stp b/tapset/linux/scheduler.stp
|
|
|
6236aa |
index 7338e9008..4667ab53a 100644
|
|
|
6236aa |
--- a/tapset/linux/scheduler.stp
|
|
|
6236aa |
+++ b/tapset/linux/scheduler.stp
|
|
|
6236aa |
@@ -138,7 +138,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
|
|
|
6236aa |
prev_tid = $prev_p->pid
|
|
|
6236aa |
prev_task = $prev_p
|
|
|
6236aa |
prev_task_name = task_execname($prev_p)
|
|
|
6236aa |
- prevtsk_state = $prev_p->state
|
|
|
6236aa |
+ prevtsk_state = task_state($prev_p)
|
|
|
6236aa |
}
|
|
|
6236aa |
else {
|
|
|
6236aa |
prev_priority = $prev->prio
|
|
|
6236aa |
@@ -146,7 +146,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
|
|
|
6236aa |
prev_tid = $prev->pid
|
|
|
6236aa |
prev_task = $prev
|
|
|
6236aa |
prev_task_name = task_execname($prev)
|
|
|
6236aa |
- prevtsk_state = $prev->state
|
|
|
6236aa |
+ prevtsk_state = task_state($prev)
|
|
|
6236aa |
}
|
|
|
6236aa |
|
|
|
6236aa |
if (@defined($next)) {
|
|
|
6236aa |
@@ -155,7 +155,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
|
|
|
6236aa |
next_tid = $next->pid
|
|
|
6236aa |
next_task = $next
|
|
|
6236aa |
next_task_name = task_execname($next)
|
|
|
6236aa |
- nexttsk_state = $next->state
|
|
|
6236aa |
+ nexttsk_state = task_state($next)
|
|
|
6236aa |
}
|
|
|
6236aa |
else if (@defined($next_p)) {
|
|
|
6236aa |
next_priority = $next_p->prio
|
|
|
6236aa |
@@ -163,7 +163,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
|
|
|
6236aa |
next_tid = $next_p->pid
|
|
|
6236aa |
next_task = $next_p
|
|
|
6236aa |
next_task_name = task_execname($next_p)
|
|
|
6236aa |
- nexttsk_state = $next_p->state
|
|
|
6236aa |
+ nexttsk_state = task_state($next_p)
|
|
|
6236aa |
}
|
|
|
6236aa |
else {
|
|
|
6236aa |
next_priority = $new->prio
|
|
|
6236aa |
@@ -171,7 +171,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
|
|
|
6236aa |
next_tid = $new->pid
|
|
|
6236aa |
next_task = $new
|
|
|
6236aa |
next_task_name = task_execname($new)
|
|
|
6236aa |
- nexttsk_state = $new->state
|
|
|
6236aa |
+ nexttsk_state = task_state($new)
|
|
|
6236aa |
}
|
|
|
6236aa |
}
|
|
|
6236aa |
|
|
|
6236aa |
diff --git a/testsuite/systemtap.examples/process/schedtimes.stp b/testsuite/systemtap.examples/process/schedtimes.stp
|
|
|
6236aa |
index 4e422c893..ee1053045 100755
|
|
|
6236aa |
--- a/testsuite/systemtap.examples/process/schedtimes.stp
|
|
|
6236aa |
+++ b/testsuite/systemtap.examples/process/schedtimes.stp
|
|
|
6236aa |
@@ -99,7 +99,7 @@ probe kernel.trace("sched_switch")
|
|
|
6236aa |
// Task $prev is scheduled off this cpu
|
|
|
6236aa |
if (task_targeted($prev)) {
|
|
|
6236aa |
pid = $prev->pid
|
|
|
6236aa |
- state = $prev->state
|
|
|
6236aa |
+ state = task_state($prev)
|
|
|
6236aa |
update_times(pid, timestamp())
|
|
|
6236aa |
|
|
|
6236aa |
if (state > 0) {
|
|
|
6236aa |
|
|
|
6236aa |
commit a29f65d5750f6379afeca99c5d641598ff638517
|
|
|
6236aa |
Author: Stan Cox <scox@redhat.com>
|
|
|
6236aa |
Date: Sun Jul 18 21:32:51 2021 -0400
|
|
|
6236aa |
|
|
|
6236aa |
PR28079: Adapt to kernel 5.14 task_struct.__state change
|
|
|
6236aa |
|
|
|
6236aa |
Use signal_wake_up_state for the 5.14 kernel which changed volatile long state to unsigned int __state.
|
|
|
6236aa |
|
|
|
6236aa |
diff --git a/buildrun.cxx b/buildrun.cxx
|
|
|
6236aa |
index a1332a687..ae27ddea4 100644
|
|
|
6236aa |
--- a/buildrun.cxx
|
|
|
6236aa |
+++ b/buildrun.cxx
|
|
|
6236aa |
@@ -523,3 +523,4 @@ compile_pass (systemtap_session& s)
|
|
|
6236aa |
output_autoconf(s, o, cs, "autoconf-lockdown-kernel.c", "STAPCONF_LOCKDOWN_KERNEL", NULL);
|
|
|
6236aa |
+ output_autoconf(s, o, cs, "autoconf-task-state.c", "STAPCONF_TASK_STATE", NULL);
|
|
|
6236aa |
|
|
|
6236aa |
// used by runtime/linux/netfilter.c
|
|
|
6236aa |
output_exportconf(s, o2, "nf_register_hook", "STAPCONF_NF_REGISTER_HOOK");
|
|
|
6236aa |
diff --git a/runtime/linux/autoconf-task-state.c b/runtime/linux/autoconf-task-state.c
|
|
|
6236aa |
new file mode 100644
|
|
|
6236aa |
index 000000000..27a1d7c13
|
|
|
6236aa |
--- /dev/null
|
|
|
6236aa |
+++ b/runtime/linux/autoconf-task-state.c
|
|
|
6236aa |
@@ -0,0 +1,18 @@
|
|
|
6236aa |
+/*
|
|
|
6236aa |
+ * Is this a kernel prior to the following kernel commit:
|
|
|
6236aa |
+ *
|
|
|
6236aa |
+ * commit 2f064a59a11ff9bc22e52e9678bc601404c7cb34
|
|
|
6236aa |
+ * Author: Peter Zijlstra <peterz@infradead.org>
|
|
|
6236aa |
+ * Date: 2021-06-11 10:28:17 +0200
|
|
|
6236aa |
+ *
|
|
|
6236aa |
+ * sched: Change task_struct::state
|
|
|
6236aa |
+ * Change the type and name of task_struct::state. Drop the volatile and
|
|
|
6236aa |
+ * shrink it to an 'unsigned int'. Rename it in order to find all uses
|
|
|
6236aa |
+ * such that we can use READ_ONCE/WRITE_ONCE as appropriate.
|
|
|
6236aa |
+ */
|
|
|
6236aa |
+
|
|
|
6236aa |
+#include <linux/sched.h>
|
|
|
6236aa |
+
|
|
|
6236aa |
+unsigned int bar (struct task_struct *foo) {
|
|
|
6236aa |
+ return (foo->state = 0);
|
|
|
6236aa |
+}
|
|
|
6236aa |
diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
|
|
|
6236aa |
index ff8c5549d..d63e6366c 100644
|
|
|
6236aa |
--- a/runtime/stp_utrace.c
|
|
|
6236aa |
+++ b/runtime/stp_utrace.c
|
|
|
6236aa |
@@ -33,9 +33,12 @@
|
|
|
6236aa |
#if defined(__set_task_state)
|
|
|
6236aa |
#define __stp_set_task_state(tsk, state_value) \
|
|
|
6236aa |
__set_task_state((tsk), (state_value))
|
|
|
6236aa |
-#else
|
|
|
6236aa |
+#elif defined(STAPCONF_TASK_STATE)
|
|
|
6236aa |
#define __stp_set_task_state(tsk, state_value) \
|
|
|
6236aa |
do { (tsk)->state = (state_value); } while (0)
|
|
|
6236aa |
+#else
|
|
|
6236aa |
+#define __stp_set_task_state(tsk, state_value) \
|
|
|
6236aa |
+ signal_wake_up_state((tsk), (state_value))
|
|
|
6236aa |
#endif
|
|
|
6236aa |
|
|
|
6236aa |
// For now, disable the task_work_queue on non-RT kernels.
|
|
|
6236aa |
@@ -1263,7 +1266,7 @@ static void utrace_wakeup(struct task_struct *target, struct utrace *utrace)
|
|
|
6236aa |
spin_lock_irq(&target->sighand->siglock);
|
|
|
6236aa |
if (target->signal->flags & SIGNAL_STOP_STOPPED ||
|
|
|
6236aa |
target->signal->group_stop_count)
|
|
|
6236aa |
- target->state = TASK_STOPPED;
|
|
|
6236aa |
+ __stp_set_task_state(target, TASK_STOPPED);
|
|
|
6236aa |
else
|
|
|
6236aa |
stp_wake_up_state(target, __TASK_TRACED);
|
|
|
6236aa |
spin_unlock_irq(&target->sighand->siglock);
|