Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1649258

[patch V3 30/32] sched: Provide is_percpu_thread() helper

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject [patch V3 30/32] sched: Provide is_percpu_thread() helper
Date 2017-05-24 10:30 +0200
Message-ID <tKzQ9-8hN-75@gated-at.bofh.it> (permalink)
References <tKzQ6-8hN-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Provide a helper function for checking whether current task is a per cpu
thread.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1265,6 +1265,16 @@ extern struct pid *cad_pid;
 #define tsk_used_math(p)			((p)->flags & PF_USED_MATH)
 #define used_math()				tsk_used_math(current)
 
+static inline bool is_percpu_thread(void)
+{
+#ifdef CONFIG_SMP
+	return (current->flags & PF_NO_SETAFFINITY) &&
+		(current->nr_cpus_allowed  == 1);
+#else
+	return true;
+#endif
+}
+
 /* Per-process atomic flags. */
 #define PFA_NO_NEW_PRIVS		0	/* May not gain new privileges. */
 #define PFA_SPREAD_PAGE			1	/* Spread page cache over cpuset */

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[patch V3 30/32] sched: Provide is_percpu_thread() helper Thomas Gleixner <tglx@linutronix.de> - 2017-05-24 10:30 +0200

csiph-web