From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
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.mckenney@linaro.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
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 [thread overview]
Message-ID: <1321388885-11211-4-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111115202736.GA11030@linux.vnet.ibm.com>
From: Paul E. McKenney <paul.mckenney@linaro.org>
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 <josh@joshtriplett.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
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.
*/
--
1.7.3.2
next prev parent reply other threads:[~2011-11-15 20:28 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 20:27 [PATCH tip/core/rcu 0/9] Preview of additional RCU changes for 3.3 Paul E. McKenney
2011-11-15 20:27 ` [PATCH tip/core/rcu 1/9] rcu: Permit RCU_FAST_NO_HZ to be used by TREE_PREEMPT_RCU Paul E. McKenney
2011-11-15 20:27 ` [PATCH tip/core/rcu 2/9] rcu: Add rcutorture system-shutdown capability Paul E. McKenney
2011-11-15 21:46 ` Josh Triplett
2011-11-16 20:32 ` Paul E. McKenney
2011-11-16 22:15 ` Josh Triplett
2011-11-16 22:44 ` Paul E. McKenney
2011-11-16 22:58 ` Josh Triplett
2011-11-16 23:43 ` Paul E. McKenney
2011-11-17 0:48 ` Josh Triplett
2011-11-17 0:49 ` Josh Triplett
2011-11-17 1:40 ` Paul E. McKenney
2011-11-17 23:57 ` Josh Triplett
2011-11-18 0:27 ` Paul E. McKenney
2011-11-15 20:27 ` [PATCH tip/core/rcu 3/9] rcu: Control rcutorture startup from kernel boot parameters Paul E. McKenney
2011-11-15 21:49 ` Josh Triplett
2011-11-16 20:38 ` Paul E. McKenney
2011-11-16 22:17 ` Josh Triplett
2011-11-15 20:28 ` Paul E. McKenney [this message]
2011-11-15 21:13 ` [PATCH tip/core/rcu 4/9] sched: add is_idle_task() to handle invalidated uses of idle_cpu() Josh Triplett
2011-11-16 19:54 ` Paul E. McKenney
2011-11-15 20:28 ` [PATCH tip/core/rcu 5/9] rcu: Make RCU use the new is_idle_task() API Paul E. McKenney
2011-11-15 21:35 ` Josh Triplett
2011-11-15 20:28 ` [PATCH tip/core/rcu 6/9] sparc: Make SPARC " Paul E. McKenney
2011-11-15 21:15 ` David Miller
2011-11-15 20:28 ` [PATCH tip/core/rcu 7/9] kdb: Make KDB " Paul E. McKenney
2011-11-15 20:28 ` [PATCH tip/core/rcu 8/9] events: Make events " Paul E. McKenney
2011-11-15 20:28 ` [PATCH tip/core/rcu 9/9] tile: Make tile " Paul E. McKenney
2011-11-23 17:03 ` Chris Metcalf
2011-11-28 23:02 ` Paul E. McKenney
2011-11-15 21:50 ` [PATCH tip/core/rcu 0/9] Preview of additional RCU changes for 3.3 Josh Triplett
2011-11-16 20:39 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321388885-11211-4-git-send-email-paulmck@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=darren@dvhart.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=niv@us.ibm.com \
--cc=patches@linaro.org \
--cc=paul.mckenney@linaro.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).