From patchwork Wed Aug 14 10:41:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 171257 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp645412ily; Wed, 14 Aug 2019 03:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOyyuXyDQpGCX9xT4uYZT05tNOohpvLcJmEGrAifT+x0HNoiyz8AGbqhXbFeuUpMYrpfnW X-Received: by 2002:a17:90a:a404:: with SMTP id y4mr6771002pjp.58.1565779305480; Wed, 14 Aug 2019 03:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565779305; cv=none; d=google.com; s=arc-20160816; b=0A6uF5p/yYsdZqZ8L6MWvQIH4v65crtIzu7wke1ZW4sJuXdgQFUfdc2HtqkTBfF9or qpDUcBVXXrtElRIRdUKegK5F5SJDgO74qBlJmV/xodn6v/67T5MJdP/Wn1U9cdR8zBtJ G7IW/F2r6e+0LXuxyFqv/ydk9Be49MptkE4yvmetLsYASYmnPLDlJKkC4XOdKcb0D2jK JDmcuUaHhFrjeNUxqf8rljCbN2SOueT4UWNy4+4D86Q01XAuNjs63GPtu6jN1JbqgqyF ItazHAhaZYPrE8r96mrkroUc4F5GXmmAvb/ZX7pRV+L69raepy/CUMaTJiBwuHuZRlco ey/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=HdY5W0mGwDCOdDZLMtw3do16jjfhpkXUOCe2yQ2GUDY=; b=L9ve2wMKB735m9qGome/mkd+Z5A55F/jwm5Xnv+BNvgARkJVMkrXJwmUQcf7o6jf4w lSJOWDMgzsJotH5kx2Z3p9SNw5DtmuiLc15rBsi5A/7I+TJI5xFZoHnSCXKpJIzjppWO QaXD8trJoktZg/0SB1+0tzaHQ3+rJkOSk6a+Xn7NUtidhxhUg+7vBKVEerCi2JarV7N4 nszw+8acd3n37dF6dcya6DK4EH2p8J5JcHk5x+lUuTZPaIWcHprB9Ax9d0H3k2XAv16w 3z3ED/HKE1y0VbIyGgo49FKwTFJxurc9oMPe4njzz0Dkd0JgIWa8kyfG8+elJ5FX/jEj mWwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k133si63889896pgc.425.2019.08.14.03.41.45; Wed, 14 Aug 2019 03:41:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727081AbfHNKln (ORCPT + 28 others); Wed, 14 Aug 2019 06:41:43 -0400 Received: from foss.arm.com ([217.140.110.172]:51832 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfHNKll (ORCPT ); Wed, 14 Aug 2019 06:41:41 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4671B360; Wed, 14 Aug 2019 03:41:41 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7ABDE3F706; Wed, 14 Aug 2019 03:41:39 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, akpm@linux-foundation.org, bigeasy@linutronix.de, bp@suse.de, catalin.marinas@arm.com, davem@davemloft.net, hch@lst.de, kan.liang@intel.com, mark.rutland@arm.com, mingo@kernel.org, peterz@infradead.org, riel@surriel.com, will@kernel.org Subject: [PATCH 1/9] sched/core: add is_kthread() helper Date: Wed, 14 Aug 2019 11:41:23 +0100 Message-Id: <20190814104131.20190-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190814104131.20190-1-mark.rutland@arm.com> References: <20190814104131.20190-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Ingo Molnar Cc: Peter Zijlstra --- include/linux/sched.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.11.0 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);