fix: sched: Change task_struct::state (v5.14)
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 12 Jul 2021 18:51:20 +0000 (14:51 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Jul 2021 19:32:04 +0000 (15:32 -0400)
See upstream commit:

  commit 2f064a59a11ff9bc22e52e9678bc601404c7cb34
  Author: Peter Zijlstra <peterz@infradead.org>
  Date:   Fri Jun 11 10:28:17 2021 +0200

    sched: Change task_struct::state

    Change the type and name of task_struct::state. Drop the volatile and
    shrink it to an 'unsigned int'. Rename it in order to find all uses
    such that we can use READ_ONCE/WRITE_ONCE as appropriate.

Change-Id: I3a379192d6b977753fe58d4f67833a78dd7a0a47
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/wrapper/sched.h [new file with mode: 0644]
src/lttng-statedump-impl.c

diff --git a/include/wrapper/sched.h b/include/wrapper/sched.h
new file mode 100644 (file)
index 0000000..54e29f7
--- /dev/null
@@ -0,0 +1,26 @@
+/* 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 */
index 164345ca463865a6e4332d15aa91fe25c03f9f43..4dfbca0b29dcc8b11b81099cd43f2ab97376c573 100644 (file)
@@ -26,7 +26,6 @@
 #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>
@@ -43,6 +42,7 @@
 #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>
@@ -661,7 +661,7 @@ int lttng_enumerate_process_states(struct lttng_kernel_session *session)
                                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;
@@ -672,7 +672,7 @@ int lttng_enumerate_process_states(struct lttng_kernel_session *session)
                                         * 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;
This page took 0.028069 seconds and 4 git commands to generate.