From: tip-bot for Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
joe@perches.com, a.p.zijlstra@chello.nl, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:sched/core] sched: Update yield() docs
Date: Mon, 12 Mar 2012 21:47:29 -0700 [thread overview]
Message-ID: <tip-8e3fabfde445a872c8aec2296846badf24d7c8b4@git.kernel.org> (raw)
In-Reply-To: <1331056466.11248.327.camel@twins>
Commit-ID: 8e3fabfde445a872c8aec2296846badf24d7c8b4
Gitweb: http://git.kernel.org/tip/8e3fabfde445a872c8aec2296846badf24d7c8b4
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Tue, 6 Mar 2012 18:54:26 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 12 Mar 2012 20:43:17 +0100
sched: Update yield() docs
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1331056466.11248.327.camel@twins
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched/core.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8781cec..47614a5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4577,8 +4577,24 @@ EXPORT_SYMBOL(__cond_resched_softirq);
/**
* yield - yield the current processor to other threads.
*
- * This is a shortcut for kernel-space yielding - it marks the
- * thread runnable and calls sys_sched_yield().
+ * Do not ever use this function, there's a 99% chance you're doing it wrong.
+ *
+ * The scheduler is at all times free to pick the calling task as the most
+ * eligible task to run, if removing the yield() call from your code breaks
+ * it, its already broken.
+ *
+ * Typical broken usage is:
+ *
+ * while (!event)
+ * yield();
+ *
+ * where one assumes that yield() will let 'the other' process run that will
+ * make event true. If the current task is a SCHED_FIFO task that will never
+ * happen. Never use yield() as a progress guarantee!!
+ *
+ * If you want to use yield() to wait for something, use wait_event().
+ * If you want to use yield() to be 'nice' for others, use cond_resched().
+ * If you still want to use yield(), do not!
*/
void __sched yield(void)
{
prev parent reply other threads:[~2012-03-13 4:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 11:23 [PATCH] cpuset: mm: Remove memory barrier damage from the page allocator Mel Gorman
2012-03-02 16:19 ` Christoph Lameter
2012-03-02 17:43 ` Mel Gorman
2012-03-02 19:53 ` Christoph Lameter
2012-03-02 21:25 ` Peter Zijlstra
2012-03-02 23:47 ` David Rientjes
2012-03-05 9:44 ` Mel Gorman
2012-03-06 23:31 ` David Rientjes
2012-03-05 9:35 ` Mel Gorman
2012-03-02 21:21 ` Peter Zijlstra
2012-03-05 20:18 ` Andrew Morton
2012-03-06 2:01 ` [RFC PATCH] checkpatch: Warn on use of yield() Joe Perches
2012-03-06 12:45 ` Peter Zijlstra
2012-03-06 13:14 ` Glauber Costa
2012-03-06 13:25 ` Peter Zijlstra
2012-03-06 13:27 ` Glauber Costa
2012-03-06 17:41 ` Joe Perches
2012-03-06 17:54 ` Peter Zijlstra
2012-03-06 18:00 ` Joe Perches
2012-03-06 18:17 ` Joe Perches
2012-03-06 19:31 ` [PATCH 1/2] " Joe Perches
2012-03-06 19:31 ` [PATCH 2/2] checkpatch: whitespace - add/remove blank lines Joe Perches
2012-03-08 15:56 ` [PATCH 1/2 V2] checkpatch: Warn on use of yield() Joe Perches
2012-03-13 4:47 ` tip-bot for Peter Zijlstra [this message]
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=tip-8e3fabfde445a872c8aec2296846badf24d7c8b4@git.kernel.org \
--to=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--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