#include <linux/cpu.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
-#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/wait.h>
#include <wrapper/genhd.h>
#include <wrapper/file.h>
#include <wrapper/fdtable.h>
+#include <wrapper/sched.h>
#ifdef CONFIG_LTTNG_HAS_LIST_IRQ
#include <linux/irq.h>
status = LTTNG_ZOMBIE;
else if (p->exit_state == EXIT_DEAD)
status = LTTNG_DEAD;
- else if (p->state == TASK_RUNNING) {
+ else if (lttng_task_is_running(p)) {
/* Is this a forked child that has not run yet? */
if (list_empty(&p->rt.run_list))
status = LTTNG_WAIT_FORK;
* was really running at this time.
*/
status = LTTNG_WAIT_CPU;
- } else if (p->state &
+ } else if (lttng_get_task_state(p) &
(TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)) {
/* Task is waiting for something to complete */
status = LTTNG_WAIT;
--- /dev/null
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * src/wrapper/kprobes.h
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#ifndef _LTTNG_WRAPPER_SCHED_H
+#define _LTTNG_WRAPPER_SCHED_H
+
+#include <linux/sched.h>
+#include <lttng-kernel-version.h>
+
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,14,0))
+
+#define lttng_get_task_state(task) READ_ONCE((task)->__state)
+#define lttng_task_is_running(task) task_is_running(task)
+
+#else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,14,0) */
+
+#define lttng_get_task_state(task) ((task)->state)
+#define lttng_task_is_running(task) (lttng_get_task_state(task) == TASK_RUNNING)
+
+#endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,14,0) */
+
+#endif /* _LTTNG_WRAPPER_SCHED_H */