From patchwork Tue Nov 15 20:28:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5151 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 23CEA23E0F for ; Tue, 15 Nov 2011 20:28:27 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 17D20A18249 for ; Tue, 15 Nov 2011 20:28:27 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id a26so1226734faa.11 for ; Tue, 15 Nov 2011 12:28:27 -0800 (PST) Received: by 10.152.104.1 with SMTP id ga1mr18051509lab.40.1321388906930; Tue, 15 Nov 2011 12:28:26 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs55688lal; Tue, 15 Nov 2011 12:28:26 -0800 (PST) Received: by 10.52.22.226 with SMTP id h2mr45470636vdf.46.1321388904906; Tue, 15 Nov 2011 12:28:24 -0800 (PST) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com. [32.97.182.139]) by mx.google.com with ESMTPS id c39si8806470anp.82.2011.11.15.12.28.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Nov 2011 12:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.139 as permitted sender) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.139 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Nov 2011 15:28:24 -0500 Received: from d01relay03.pok.ibm.com ([9.56.227.235]) by e9.ny.us.ibm.com ([192.168.1.109]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 15 Nov 2011 15:28:20 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pAFKSJA0284400; Tue, 15 Nov 2011 15:28:19 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pAFKS7Nx008069; Tue, 15 Nov 2011 15:28:08 -0500 Received: from paulmck-ThinkPad-W500 ([9.47.24.246]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pAFKS7dF008043; Tue, 15 Nov 2011 15:28:07 -0500 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id CEF94EAA0E; Tue, 15 Nov 2011 12:28:06 -0800 (PST) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, patches@linaro.org, "Paul E. McKenney" , "Paul E. McKenney" Subject: [PATCH tip/core/rcu 4/9] sched: add is_idle_task() to handle invalidated uses of idle_cpu() Date: Tue, 15 Nov 2011 12:28:00 -0800 Message-Id: <1321388885-11211-4-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <20111115202736.GA11030@linux.vnet.ibm.com> References: <20111115202736.GA11030@linux.vnet.ibm.com> x-cbid: 11111520-7182-0000-0000-000000321DE7 From: Paul E. McKenney Commit 908a3283 (Fix idle_cpu()) invalidated some uses of idle_cpu(), which used to say whether or not the CPU was running the idle task, but now instead says whether or not the CPU is running the idle task in the absence of pending wakeups. Although this new implementation gives a better answer to the question "is this CPU idle?", it also invalidates other uses that were made of idle_cpu(). This commit therefore introduces a new is_idle_task() API member that determines whether or not the specified task is one of the idle tasks, allowing open-coded "->pid == 0" sequences to be replaced by something more meaningful. Suggested-by: Josh Triplett Suggested-by: Peter Zijlstra Signed-off-by: Paul E. McKenney Signed-off-by: Paul E. McKenney --- include/linux/sched.h | 1 + kernel/sched.c | 9 +++++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 68daf4f..4b1077b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2071,6 +2071,7 @@ extern int sched_setscheduler(struct task_struct *, int, extern int sched_setscheduler_nocheck(struct task_struct *, int, const struct sched_param *); extern struct task_struct *idle_task(int cpu); +extern int is_idle_task(struct task_struct *p); extern struct task_struct *curr_task(int cpu); extern void set_curr_task(int cpu, struct task_struct *p); diff --git a/kernel/sched.c b/kernel/sched.c index 0e9344a..c9c1bb3 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -5185,6 +5185,15 @@ struct task_struct *idle_task(int cpu) } /** + * is_idle_task - is the specified task an idle task? + * @tsk: the task in question. + */ +int is_idle_task(struct task_struct *p) +{ + return p->pid == 0; +} + +/** * find_process_by_pid - find a process with a matching PID value. * @pid: the pid in question. */