aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-04-28 10:01:38 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-29 08:15:55 -0400
commit50fa610a3b6ba7cf91d7a92229177dfaff2b81a1 (patch)
tree0369fc3269a18f8d2ffcedaebe4ac875bbe9870c /kernel/sched.c
parent56a50adda49b2020156616c4eb15353e0f9ad7de (diff)
sched: Document memory barriers implied by sleep/wake-up primitives
Add a section to the memory barriers document to note the implied memory barriers of sleep primitives (set_current_state() and wrappers) and wake-up primitives (wake_up() and co.). Also extend the in-code comments on the wake_up() functions to note these implied barriers. [ Impact: add documentation ] Signed-off-by: David Howells <dhowells@redhat.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> LKML-Reference: <20090428140138.1192.94723.stgit@warthog.procyon.org.uk> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index b902e587a3a0..fd0c2cee3f35 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2458,6 +2458,17 @@ out:
2458 return success; 2458 return success;
2459} 2459}
2460 2460
2461/**
2462 * wake_up_process - Wake up a specific process
2463 * @p: The process to be woken up.
2464 *
2465 * Attempt to wake up the nominated process and move it to the set of runnable
2466 * processes. Returns 1 if the process was woken up, 0 if it was already
2467 * running.
2468 *
2469 * It may be assumed that this function implies a write memory barrier before
2470 * changing the task state if and only if any tasks are woken up.
2471 */
2461int wake_up_process(struct task_struct *p) 2472int wake_up_process(struct task_struct *p)
2462{ 2473{
2463 return try_to_wake_up(p, TASK_ALL, 0); 2474 return try_to_wake_up(p, TASK_ALL, 0);
@@ -5241,6 +5252,9 @@ void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
5241 * @mode: which threads 5252 * @mode: which threads
5242 * @nr_exclusive: how many wake-one or wake-many threads to wake up 5253 * @nr_exclusive: how many wake-one or wake-many threads to wake up
5243 * @key: is directly passed to the wakeup function 5254 * @key: is directly passed to the wakeup function
5255 *
5256 * It may be assumed that this function implies a write memory barrier before
5257 * changing the task state if and only if any tasks are woken up.
5244 */ 5258 */
5245void __wake_up(wait_queue_head_t *q, unsigned int mode, 5259void __wake_up(wait_queue_head_t *q, unsigned int mode,
5246 int nr_exclusive, void *key) 5260 int nr_exclusive, void *key)
@@ -5279,6 +5293,9 @@ void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key)
5279 * with each other. This can prevent needless bouncing between CPUs. 5293 * with each other. This can prevent needless bouncing between CPUs.
5280 * 5294 *
5281 * On UP it can prevent extra preemption. 5295 * On UP it can prevent extra preemption.
5296 *
5297 * It may be assumed that this function implies a write memory barrier before
5298 * changing the task state if and only if any tasks are woken up.
5282 */ 5299 */
5283void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, 5300void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode,
5284 int nr_exclusive, void *key) 5301 int nr_exclusive, void *key)
@@ -5315,6 +5332,9 @@ EXPORT_SYMBOL_GPL(__wake_up_sync); /* For internal use only */
5315 * awakened in the same order in which they were queued. 5332 * awakened in the same order in which they were queued.
5316 * 5333 *
5317 * See also complete_all(), wait_for_completion() and related routines. 5334 * See also complete_all(), wait_for_completion() and related routines.
5335 *
5336 * It may be assumed that this function implies a write memory barrier before
5337 * changing the task state if and only if any tasks are woken up.
5318 */ 5338 */
5319void complete(struct completion *x) 5339void complete(struct completion *x)
5320{ 5340{
@@ -5332,6 +5352,9 @@ EXPORT_SYMBOL(complete);
5332 * @x: holds the state of this particular completion 5352 * @x: holds the state of this particular completion
5333 * 5353 *
5334 * This will wake up all threads waiting on this particular completion event. 5354 * This will wake up all threads waiting on this particular completion event.
5355 *
5356 * It may be assumed that this function implies a write memory barrier before
5357 * changing the task state if and only if any tasks are woken up.
5335 */ 5358 */
5336void complete_all(struct completion *x) 5359void complete_all(struct completion *x)
5337{ 5360{