]> sourceware.org Git - systemtap.git/commitdiff
Use task_state tapset function to avoid task_struct changes
authorWilliam Cohen <wcohen@redhat.com>
Tue, 14 Sep 2021 01:32:38 +0000 (21:32 -0400)
committerWilliam Cohen <wcohen@redhat.com>
Tue, 14 Sep 2021 01:32:38 +0000 (21:32 -0400)
The Linux 5.14 kernel's task_struct changed the state field to
__state.  The task_state tapset function selects the appropriate
version.  Make the scheduler.stp tapset and schedtimes.stp example use
the task_state function rather than directly trying to access the
task_struct state field (and get it wrong for newer kernels).

tapset/linux/scheduler.stp
testsuite/systemtap.examples/process/schedtimes.stp

index 7338e90088651a3f4457aeb567659cbdfcbc18df..4667ab53ab0d43976fa39d7e8d49331df577dc13 100644 (file)
@@ -138,7 +138,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
                prev_tid = $prev_p->pid
                prev_task = $prev_p
                prev_task_name = task_execname($prev_p)
-               prevtsk_state = $prev_p->state
+               prevtsk_state = task_state($prev_p)
        }
        else {
                prev_priority = $prev->prio
@@ -146,7 +146,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
                prev_tid = $prev->pid
                prev_task = $prev
                prev_task_name = task_execname($prev)
-               prevtsk_state = $prev->state
+               prevtsk_state = task_state($prev)
        }
 
        if (@defined($next)) {
@@ -155,7 +155,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
                next_tid = $next->pid
                next_task = $next
                next_task_name = task_execname($next)
-               nexttsk_state = $next->state
+               nexttsk_state = task_state($next)
        }
        else if (@defined($next_p)) {
                next_priority = $next_p->prio
@@ -163,7 +163,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
                next_tid = $next_p->pid
                next_task = $next_p
                next_task_name = task_execname($next_p)
-               nexttsk_state = $next_p->state
+               nexttsk_state = task_state($next_p)
        }
        else {
                next_priority = $new->prio
@@ -171,7 +171,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
                next_tid = $new->pid
                next_task = $new
                next_task_name = task_execname($new)
-               nexttsk_state = $new->state
+               nexttsk_state = task_state($new)
        }
 }
 
index 4e422c893eb87e3fff4a771974fdac0eb3ab75cd..ee105304525fe3013d73f5c5b34862ef4fb02ecd 100755 (executable)
@@ -99,7 +99,7 @@ probe kernel.trace("sched_switch")
   // Task $prev is scheduled off this cpu
   if (task_targeted($prev)) {
     pid = $prev->pid
-    state = $prev->state
+    state = task_state($prev)
     update_times(pid, timestamp())
 
     if (state > 0) {
This page took 0.030938 seconds and 5 git commands to generate.