[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1258391726-30264-8-git-send-email-tj@kernel.org>
Date: Tue, 17 Nov 2009 02:15:12 +0900
From: Tejun Heo <tj@...nel.org>
To: linux-kernel@...r.kernel.org, jeff@...zik.org, mingo@...e.hu,
akpm@...ux-foundation.org, jens.axboe@...cle.com,
rusty@...tcorp.com.au, cl@...ux-foundation.org,
dhowells@...hat.com, arjan@...ux.intel.com,
torvalds@...ux-foundation.org, avi@...hat.com,
peterz@...radead.org, andi@...stfloor.org, fweisbec@...il.com
Cc: Tejun Heo <tj@...nel.org>
Subject: [PATCH 07/21] sched: implement sched_notifier_wake_up_process()
Implement sched_notifier_wake_up_process() which can be called from
activate, deactivate and in scheduler notifiers to wake up a task
which is bound to the same cpu. This will be used to implement
concurrency managed workqueue.
Signed-off-by: Tejun Heo <tj@...nel.org>
---
include/linux/sched.h | 1 +
kernel/sched.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 16dcd58..5d3a554 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1240,6 +1240,7 @@ struct sched_notifier {
void sched_notifier_register(enum sched_notifier_type type,
struct sched_notifier *notifier);
void sched_notifier_unregister(struct sched_notifier *notifier);
+bool sched_notifier_wake_up_process(struct task_struct *p);
struct rcu_node;
diff --git a/kernel/sched.c b/kernel/sched.c
index a25b993..c8868e2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7388,6 +7388,43 @@ void sched_notifier_unregister(struct sched_notifier *notifier)
}
EXPORT_SYMBOL_GPL(sched_notifier_unregister);
+/**
+ * sched_notifier_wake_up_process - wake up a process from sched notifier
+ * @p: task to wake up
+ *
+ * Wake up @p. This function can only be called from activate,
+ * deactivate and in scheduler notifiers and can only wake up tasks
+ * which are already bound to the cpu in question.
+ *
+ * CONTEXT:
+ * Scheduler notifiers.
+ *
+ * RETURNS:
+ * true if @p was waken up, false if @p was already awake.
+ */
+bool sched_notifier_wake_up_process(struct task_struct *p)
+{
+ struct rq *rq = task_rq(p);
+ bool success = false;
+
+ assert_spin_locked(&rq->lock);
+
+ if (!p->se.on_rq) {
+ schedstat_inc(p, se.nr_wakeups);
+ schedstat_inc(p, se.nr_wakeups_local);
+ activate_task(rq, p, 1);
+ success = true;
+ }
+
+ trace_sched_wakeup(rq, p, success);
+ p->state = TASK_RUNNING;
+#ifdef CONFIG_SMP
+ if (p->sched_class->task_wake_up)
+ p->sched_class->task_wake_up(rq, p);
+#endif
+ return success;
+}
+
#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
static struct ctl_table sd_ctl_dir[] = {
--
1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists