lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190814104131.20190-2-mark.rutland@arm.com>
Date:   Wed, 14 Aug 2019 11:41:23 +0100
From:   Mark Rutland <mark.rutland@....com>
To:     linux-kernel@...r.kernel.org
Cc:     ak@...ux.intel.com, akpm@...ux-foundation.org,
        bigeasy@...utronix.de, bp@...e.de, catalin.marinas@....com,
        davem@...emloft.net, hch@....de, kan.liang@...el.com,
        mark.rutland@....com, mingo@...nel.org, peterz@...radead.org,
        riel@...riel.com, will@...nel.org
Subject: [PATCH 1/9] sched/core: add is_kthread() helper

Code checking whether a task is a kthread isn't very consistent. Some
code correctly tests task->flags & PF_THREAD, while other code checks
task->mm (which can be true for a kthread which calls use_mm()).

So that we can clean this up and keep the code easy to follow, let's add
an obvious helper function to test whether a task is a kthread.
Subsequent patches will use this as part of cleaning up and correcting
open-coded tests.

At the same time, let's fix up the kerneldoc for is_idle_task() for
consistency with the new helper, using true/false rather than 0/1, given
the functions return bool.

Signed-off-by: Mark Rutland <mark.rutland@....com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
---
 include/linux/sched.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 9f51932bd543..b7e96409d75f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1621,13 +1621,24 @@ extern struct task_struct *idle_task(int cpu);
  * is_idle_task - is the specified task an idle task?
  * @p: the task in question.
  *
- * Return: 1 if @p is an idle task. 0 otherwise.
+ * Return: true if @p is an idle task, false otherwise.
  */
 static inline bool is_idle_task(const struct task_struct *p)
 {
 	return !!(p->flags & PF_IDLE);
 }
 
+/**
+ * is_kthread - is the specified task a kthread
+ * @p: the task in question.
+ *
+ * Return: true if @p is a kthread, false otherwise.
+ */
+static inline bool is_kthread(const struct task_struct *p)
+{
+	return !!(p->flags & PF_KTHREAD);
+}
+
 extern struct task_struct *curr_task(int cpu);
 extern void ia64_set_curr_task(int cpu, struct task_struct *p);
 
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ