Drop 'wrapper/namespace.h' wrapper
[lttng-modules.git] / include / instrumentation / events / sched.h
index 29bce6729b9e5af33a5b7e8eeaaa7f36cf54eee2..f10f94d4d8bfacf61b10f455f7f863e80a541e51 100644 (file)
 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,9,0))
 #include <linux/sched/rt.h>
 #endif
-#include <wrapper/namespace.h>
 
 #define LTTNG_MAX_PID_NS_LEVEL 32
 
 #ifndef _TRACE_SCHED_DEF_
 #define _TRACE_SCHED_DEF_
 
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
+
+static inline long __trace_sched_switch_state(bool preempt,
+               unsigned int prev_state,
+               struct task_struct *p)
+{
+        unsigned int state;
+
+#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).
+         */
+        if (preempt)
+                return TASK_REPORT_MAX;
+
+        /*
+         * task_state_index() uses fls() and returns a value from 0-8 range.
+         * Decrement it by 1 (except TASK_RUNNING state i.e 0) before using
+         * it for left shift operation to get the correct task->state
+         * mapping.
+         */
+       state = __task_state_index(prev_state, p->exit_state);
+
+        return state ? (1 << (state - 1)) : state;
+}
+
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
 
 static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
 {
@@ -165,6 +194,7 @@ static inline long __trace_sched_switch_state(struct task_struct *p)
 
 #endif /* _TRACE_SCHED_DEF_ */
 
+#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
 /*
  * Enumeration of the task state bitmask.
  * Only bit flags are enumerated here, not composition of states.
@@ -198,6 +228,7 @@ LTTNG_TRACEPOINT_ENUM(task_state,
                ctf_enum_value("TASK_STATE_MAX", TASK_STATE_MAX)
        )
 )
+#endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */
 
 /*
  * Tracepoint for calling kthread_stop, performed to end a kthread:
@@ -319,35 +350,81 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new,
 /*
  * Tracepoint for task switches, performed by the scheduler:
  */
+
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
+LTTNG_TRACEPOINT_EVENT(sched_switch,
+
+       TP_PROTO(bool preempt,
+               struct task_struct *prev,
+               struct task_struct *next,
+               unsigned int prev_state),
+
+       TP_ARGS(preempt, prev, next, prev_state),
+
+       TP_FIELDS(
+               ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
+               ctf_integer(pid_t, prev_tid, prev->pid)
+               ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO)
+#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
+               ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(preempt, prev_state, prev))
+#else
+               ctf_integer(long, prev_state, __trace_sched_switch_state(preempt, prev_state, prev))
+#endif
+               ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN)
+               ctf_integer(pid_t, next_tid, next->pid)
+               ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO)
+       )
+)
+
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0))
+
 LTTNG_TRACEPOINT_EVENT(sched_switch,
 
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0))
        TP_PROTO(bool preempt,
                 struct task_struct *prev,
                 struct task_struct *next),
 
        TP_ARGS(preempt, prev, next),
+
+       TP_FIELDS(
+               ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
+               ctf_integer(pid_t, prev_tid, prev->pid)
+               ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO)
+#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
+               ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(preempt, prev))
+#else
+               ctf_integer(long, prev_state, __trace_sched_switch_state(preempt, prev))
+#endif
+               ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN)
+               ctf_integer(pid_t, next_tid, next->pid)
+               ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO)
+       )
+)
+
 #else
+
+LTTNG_TRACEPOINT_EVENT(sched_switch,
+
        TP_PROTO(struct task_struct *prev,
                 struct task_struct *next),
 
        TP_ARGS(prev, next),
-#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0)) */
 
        TP_FIELDS(
                ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
                ctf_integer(pid_t, prev_tid, prev->pid)
                ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO)
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0))
-               ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(preempt, prev))
-#else
+#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
                ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(prev))
+#else
+               ctf_integer(long, prev_state, __trace_sched_switch_state(prev))
 #endif
                ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN)
                ctf_integer(pid_t, next_tid, next->pid)
                ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO)
        )
 )
+#endif
 
 /*
  * Tracepoint for a task being migrated:
@@ -466,7 +543,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
                                        pid_ns = task_active_pid_ns(parent);
                                        if (pid_ns)
                                                parent_ns_inum =
-                                                       pid_ns->lttng_ns_inum;
+                                                       pid_ns->ns.inum;
                                }
                                parent_ns_inum;
                        }))
@@ -486,7 +563,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
                                        pid_ns = task_active_pid_ns(child);
                                        if (pid_ns)
                                                child_ns_inum =
-                                                       pid_ns->lttng_ns_inum;
+                                                       pid_ns->ns.inum;
                                }
                                child_ns_inum;
                        }))
This page took 0.026154 seconds and 4 git commands to generate.