From 7259e6a5dfc2a27cd7e8171d9b337610bbf44984 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 12 Jul 2021 14:51:20 -0400 Subject: [PATCH] fix: sched: Change task_struct::state (v5.14) See upstream commit: commit 2f064a59a11ff9bc22e52e9678bc601404c7cb34 Author: Peter Zijlstra 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 Signed-off-by: Mathieu Desnoyers --- include/wrapper/sched.h | 26 ++++++++++++++++++++++++++ src/lttng-statedump-impl.c | 6 +++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 include/wrapper/sched.h diff --git a/include/wrapper/sched.h b/include/wrapper/sched.h new file mode 100644 index 00000000..54e29f7d --- /dev/null +++ b/include/wrapper/sched.h @@ -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 + */ + +#ifndef _LTTNG_WRAPPER_SCHED_H +#define _LTTNG_WRAPPER_SCHED_H + +#include +#include + +#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 */ diff --git a/src/lttng-statedump-impl.c b/src/lttng-statedump-impl.c index 164345ca..4dfbca0b 100644 --- a/src/lttng-statedump-impl.c +++ b/src/lttng-statedump-impl.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #ifdef CONFIG_LTTNG_HAS_LIST_IRQ #include @@ -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; -- 2.34.1