Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] timers: Clarify usleep_range() function comment

76 views
Skip to first unread message

Bjorn Helgaas

unread,
May 31, 2016, 5:23:16 PM5/31/16
to Thomas Gleixner, John Stultz, linux-...@vger.kernel.org
Update the usleep_range() function comment to make it clear that it can
only be used in non-atomic context.

Previously we claimed usleep_range() was a drop-in replacement for udelay()
where wakeup is flexible. But that's only true in non-atomic contexts,
where it's possible to sleep instead of delay.

Signed-off-by: Bjorn Helgaas <bhel...@google.com>
---
kernel/time/timer.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 3a95f97..c024c9f 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1702,9 +1702,15 @@ static void __sched do_usleep_range(unsigned long min, unsigned long max)
}

/**
- * usleep_range - Drop in replacement for udelay where wakeup is flexible
+ * usleep_range - sleep for an approximate time
* @min: Minimum time in usecs to sleep
* @max: Maximum time in usecs to sleep
+ *
+ * In non-atomic context where the exact wakeup time is flexible, use
+ * usleep_range() instead of udelay(). The sleep improves responsiveness
+ * by avoiding the CPU-hogging busy-wait of udelay(), and the range reduces
+ * power usage by allowing hrtimers to take advantage of an already-
+ * scheduled interrupt instead of scheduling a new one just for this sleep.
*/
void __sched usleep_range(unsigned long min, unsigned long max)
{

tip-bot for Bjorn Helgaas

unread,
Jun 9, 2016, 7:04:02 PM6/9/16
to linux-ti...@vger.kernel.org, mi...@kernel.org, john....@linaro.org, h...@zytor.com, bhel...@google.com, linux-...@vger.kernel.org, tg...@linutronix.de
Commit-ID: b5227d03b7191a9a44bf75a4c228a6a9ddbe781b
Gitweb: http://git.kernel.org/tip/b5227d03b7191a9a44bf75a4c228a6a9ddbe781b
Author: Bjorn Helgaas <bhel...@google.com>
AuthorDate: Tue, 31 May 2016 16:23:02 -0500
Committer: Thomas Gleixner <tg...@linutronix.de>
CommitDate: Fri, 10 Jun 2016 00:59:14 +0200

timers: Clarify usleep_range() function comment

Update the usleep_range() function comment to make it clear that it can
only be used in non-atomic context.

Previously we claimed usleep_range() was a drop-in replacement for udelay()
where wakeup is flexible. But that's only true in non-atomic contexts,
where it's possible to sleep instead of delay.

Signed-off-by: Bjorn Helgaas <bhel...@google.com>
Cc: John Stultz <john....@linaro.org>
Link: http://lkml.kernel.org/r/20160531212302.2...@bhelgaas-glaptop2.roam.corp.google.com
Signed-off-by: Thomas Gleixner <tg...@linutronix.de>

---
kernel/time/timer.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 3a95f97..67dd610 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1702,9 +1702,15 @@ static void __sched do_usleep_range(unsigned long min, unsigned long max)
}

/**
- * usleep_range - Drop in replacement for udelay where wakeup is flexible
+ * usleep_range - Sleep for an approximate time
0 new messages