public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip] sched/swait: Annotate swait's special use
@ 2017-10-20 17:13 Davidlohr Bueso
  2017-10-20 20:25 ` Luis R. Rodriguez
  2017-10-23 12:45 ` [tip:sched/urgent] sched/swait: Document it clearly that the swait facilities are special and shouldn't be used tip-bot for Davidlohr Bueso
  0 siblings, 2 replies; 3+ messages in thread
From: Davidlohr Bueso @ 2017-10-20 17:13 UTC (permalink / raw)
  To: mingo, peterz; +Cc: torvalds, mcgrof, wagi, linux-kernel, dave, Davidlohr Bueso

We currently welcome using swait over wait whenever possible because
it is a slimmer data structure. However, Linus has made it very clear
that he does not want this used, unless under very specific rt scenarios
(such as current users).

Update the comments before kernel hipsters start thinking swait is the
cool thing to do.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 include/linux/swait.h | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/include/linux/swait.h b/include/linux/swait.h
index 73e97a08d3d0..cf30f5022472 100644
--- a/include/linux/swait.h
+++ b/include/linux/swait.h
@@ -9,13 +9,16 @@
 /*
  * Simple wait queues
  *
- * While these are very similar to the other/complex wait queues (wait.h) the
- * most important difference is that the simple waitqueue allows for
- * deterministic behaviour -- IOW it has strictly bounded IRQ and lock hold
- * times.
+ * While these are very similar to regular wait queues (wait.h) the most
+ * important difference is that the simple waitqueue allows for deterministic
+ * behaviour -- IOW it has strictly bounded IRQ and lock hold times.
  *
- * In order to make this so, we had to drop a fair number of features of the
- * other waitqueue code; notably:
+ * Mainly, this is accomplished by two things. Firstly not allowing swake_up_all
+ * from IRQ disabled, and dropping the lock upon every wakeup, giving a higher
+ * priority task a chance to run.
+ *
+ * Secondly, we had to drop a fair number of features of the other waitqueue
+ * code; notably:
  *
  *  - mixing INTERRUPTIBLE and UNINTERRUPTIBLE sleeps on the same waitqueue;
  *    all wakeups are TASK_NORMAL in order to avoid O(n) lookups for the right
@@ -24,12 +27,14 @@
  *  - the exclusive mode; because this requires preserving the list order
  *    and this is hard.
  *
- *  - custom wake functions; because you cannot give any guarantees about
- *    random code.
- *
- * As a side effect of this; the data structures are slimmer.
+ *  - custom wake callback functions; because you cannot give any guarantees
+ *    about random code. This also allows swait to be used in RT, such that
+ *    raw spinlock can be used for the swait queue head.
  *
- * One would recommend using this wait queue where possible.
+ * As a side effect of these; the data structures are slimmer albeit more ad-hoc.
+ * For all the above, note that simple wait queues should _only_ be used under
+ * very specific realtime constraints -- it is best to stick with the regular
+ * wait queues in most cases.
  */
 
 struct task_struct;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -tip] sched/swait: Annotate swait's special use
  2017-10-20 17:13 [PATCH -tip] sched/swait: Annotate swait's special use Davidlohr Bueso
@ 2017-10-20 20:25 ` Luis R. Rodriguez
  2017-10-23 12:45 ` [tip:sched/urgent] sched/swait: Document it clearly that the swait facilities are special and shouldn't be used tip-bot for Davidlohr Bueso
  1 sibling, 0 replies; 3+ messages in thread
From: Luis R. Rodriguez @ 2017-10-20 20:25 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: mingo, peterz, torvalds, mcgrof, wagi, linux-kernel,
	Davidlohr Bueso

On Fri, Oct 20, 2017 at 10:13:46AM -0700, Davidlohr Bueso wrote:
> We currently welcome using swait over wait whenever possible because
> it is a slimmer data structure. However, Linus has made it very clear
> that he does not want this used, unless under very specific rt scenarios
> (such as current users).
> 
> Update the comments before kernel hipsters start thinking swait is the
> cool thing to do.
> 
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>

Thanks, I was busy.

Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>

  Luis

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:sched/urgent] sched/swait: Document it clearly that the swait facilities are special and shouldn't be used
  2017-10-20 17:13 [PATCH -tip] sched/swait: Annotate swait's special use Davidlohr Bueso
  2017-10-20 20:25 ` Luis R. Rodriguez
@ 2017-10-23 12:45 ` tip-bot for Davidlohr Bueso
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Davidlohr Bueso @ 2017-10-23 12:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, paulmck, tglx, torvalds, hpa, mcgrof, linux-kernel, akpm,
	mingo, dave, dbueso

Commit-ID:  88796e7e5c457cae72833196cb98e6895dd107e2
Gitweb:     https://git.kernel.org/tip/88796e7e5c457cae72833196cb98e6895dd107e2
Author:     Davidlohr Bueso <dave@stgolabs.net>
AuthorDate: Fri, 20 Oct 2017 10:13:46 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 23 Oct 2017 13:59:21 +0200

sched/swait: Document it clearly that the swait facilities are special and shouldn't be used

We currently welcome using swait over wait whenever possible because
it is a slimmer data structure. However, Linus has made it very clear
that he does not want this used, unless under very specific RT scenarios
(such as current users).

Update the comments before kernel hipsters start thinking swait is the
cool thing to do.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dave@stgolabs.net
Cc: wagi@monom.org
Link: http://lkml.kernel.org/r/20171020171346.24445-1-dave@stgolabs.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/swait.h | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/include/linux/swait.h b/include/linux/swait.h
index 73e97a0..cf30f502 100644
--- a/include/linux/swait.h
+++ b/include/linux/swait.h
@@ -9,13 +9,16 @@
 /*
  * Simple wait queues
  *
- * While these are very similar to the other/complex wait queues (wait.h) the
- * most important difference is that the simple waitqueue allows for
- * deterministic behaviour -- IOW it has strictly bounded IRQ and lock hold
- * times.
+ * While these are very similar to regular wait queues (wait.h) the most
+ * important difference is that the simple waitqueue allows for deterministic
+ * behaviour -- IOW it has strictly bounded IRQ and lock hold times.
  *
- * In order to make this so, we had to drop a fair number of features of the
- * other waitqueue code; notably:
+ * Mainly, this is accomplished by two things. Firstly not allowing swake_up_all
+ * from IRQ disabled, and dropping the lock upon every wakeup, giving a higher
+ * priority task a chance to run.
+ *
+ * Secondly, we had to drop a fair number of features of the other waitqueue
+ * code; notably:
  *
  *  - mixing INTERRUPTIBLE and UNINTERRUPTIBLE sleeps on the same waitqueue;
  *    all wakeups are TASK_NORMAL in order to avoid O(n) lookups for the right
@@ -24,12 +27,14 @@
  *  - the exclusive mode; because this requires preserving the list order
  *    and this is hard.
  *
- *  - custom wake functions; because you cannot give any guarantees about
- *    random code.
- *
- * As a side effect of this; the data structures are slimmer.
+ *  - custom wake callback functions; because you cannot give any guarantees
+ *    about random code. This also allows swait to be used in RT, such that
+ *    raw spinlock can be used for the swait queue head.
  *
- * One would recommend using this wait queue where possible.
+ * As a side effect of these; the data structures are slimmer albeit more ad-hoc.
+ * For all the above, note that simple wait queues should _only_ be used under
+ * very specific realtime constraints -- it is best to stick with the regular
+ * wait queues in most cases.
  */
 
 struct task_struct;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-23 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-20 17:13 [PATCH -tip] sched/swait: Annotate swait's special use Davidlohr Bueso
2017-10-20 20:25 ` Luis R. Rodriguez
2017-10-23 12:45 ` [tip:sched/urgent] sched/swait: Document it clearly that the swait facilities are special and shouldn't be used tip-bot for Davidlohr Bueso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox