From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938775AbdEXI3C (ORCPT ); Wed, 24 May 2017 04:29:02 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:58070 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1765681AbdEXI0a (ORCPT ); Wed, 24 May 2017 04:26:30 -0400 Message-Id: <20170524081549.541649540@linutronix.de> User-Agent: quilt/0.63-1 Date: Wed, 24 May 2017 10:15:41 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Sebastian Siewior , Paul McKenney Subject: [patch V3 30/32] sched: Provide is_percpu_thread() helper References: <20170524081511.203800767@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=sched--Provide-is_percpu_thread()-helper.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a helper function for checking whether current task is a per cpu thread. Signed-off-by: Thomas Gleixner --- 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 */