Fix: update sched instrumentation for kernel 4.4.0
[lttng-modules.git] / instrumentation / events / lttng-module / sched.h
index f6b65ae2e98ad36651588accabe3504b1c8241af..347edb75e309bb01544d19b7455a4bb2b562f03f 100644 (file)
 #ifndef _TRACE_SCHED_DEF_
 #define _TRACE_SCHED_DEF_
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0))
+
+static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
+{
+#ifdef CONFIG_SCHED_DEBUG
+       BUG_ON(p != current);
+#endif /* CONFIG_SCHED_DEBUG */
+       /*
+        * Preemption ignores task state, therefore preempted tasks are always RUNNING
+        * (we will not have dequeued if state != RUNNING).
+        */
+       return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state;
+}
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
 
 static inline long __trace_sched_switch_state(struct task_struct *p)
 {
@@ -142,12 +156,26 @@ LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template,
 
        TP_ARGS(p),
 
-       TP_FIELDS(
-               ctf_array_text(char, comm, p->comm, TASK_COMM_LEN)
-               ctf_integer(pid_t, tid, p->pid)
-               ctf_integer(int, prio, p->prio)
-               ctf_integer(int, target_cpu, task_cpu(p))
+       TP_STRUCT__entry(
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  tid                     )
+               __field(        int,    prio                    )
+               __field(        int,    target_cpu              )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, p->comm, TASK_COMM_LEN)
+               tp_assign(tid, p->pid)
+               tp_assign(prio, p->prio)
+               tp_assign(target_cpu, task_cpu(p))
        )
+       TP_perf_assign(
+               __perf_task(p)
+       ),
+
+       TP_printk("comm=%s tid=%d prio=%d target_cpu=%03d",
+                 __entry->comm, __entry->tid, __entry->prio,
+                 __entry->target_cpu)
 )
 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */
 LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template,
@@ -257,7 +285,13 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new,
  */
 LTTNG_TRACEPOINT_EVENT(sched_switch,
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0))
+       TP_PROTO(bool preempt,
+                struct task_struct *prev,
+                struct task_struct *next),
+
+       TP_ARGS(preempt, prev, next),
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
        TP_PROTO(struct task_struct *prev,
                 struct task_struct *next),
 
@@ -283,7 +317,9 @@ LTTNG_TRACEPOINT_EVENT(sched_switch,
                tp_memcpy(next_comm, next->comm, TASK_COMM_LEN)
                tp_assign(prev_tid, prev->pid)
                tp_assign(prev_prio, prev->prio - MAX_RT_PRIO)
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0))
+               tp_assign(prev_state, __trace_sched_switch_state(preempt, prev))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
                tp_assign(prev_state, __trace_sched_switch_state(prev))
 #else
                tp_assign(prev_state, prev->state)
This page took 0.024296 seconds and 4 git commands to generate.