From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Russell King <rmk+kernel@armlinux.org.uk>,
David Riley <davidriley@chromium.org>,
Thomas Gleixner <tglx@linutronix.de>,
Richard Cochran <richardcochran@gmail.com>,
Prarit Bhargava <prarit@redhat.com>,
Ingo Molnar <mingo@kernel.org>,
John Stultz <john.stultz@linaro.org>
Subject: [PATCH 2/3] delay: Add explanation of udelay() inaccuracy
Date: Fri, 27 Jan 2017 16:59:30 -0800 [thread overview]
Message-ID: <1485565171-21223-3-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1485565171-21223-1-git-send-email-john.stultz@linaro.org>
From: Russell King <rmk+kernel@armlinux.org.uk>
There seems to be some misunderstanding that udelay() and friends will
always guarantee the specified delay. This is a false understanding.
When udelay() is based on CPU cycles, it can return early for many
reasons which are detailed by Linus' reply to me in a thread in 2011:
http://lists.openwall.net/linux-kernel/2011/01/12/372
However, a udelay test module was created in 2014 which allows udelay()
to only be 0.5% fast, which is outside of the CPU-cycles udelay()
results I measured back in 2011, which were deemed to be in the "we
don't care" region.
test_udelay() should be fixed to reflect the real allowable tolerance
on udelay(), rather than 0.5%.
Cc: David Riley <davidriley@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
include/linux/delay.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/delay.h b/include/linux/delay.h
index a6ecb34..2ecb3c4 100644
--- a/include/linux/delay.h
+++ b/include/linux/delay.h
@@ -5,6 +5,17 @@
* Copyright (C) 1993 Linus Torvalds
*
* Delay routines, using a pre-computed "loops_per_jiffy" value.
+ *
+ * Please note that ndelay(), udelay() and mdelay() may return early for
+ * several reasons:
+ * 1. computed loops_per_jiffy too low (due to the time taken to
+ * execute the timer interrupt.)
+ * 2. cache behaviour affecting the time it takes to execute the
+ * loop function.
+ * 3. CPU clock rate changes.
+ *
+ * Please see this thread:
+ * http://lists.openwall.net/linux-kernel/2011/01/09/56
*/
#include <linux/kernel.h>
--
2.7.4
next prev parent reply other threads:[~2017-01-28 1:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-28 0:59 [GIT PULL][PATCH 0/3] Timekeeping items for 4.11 John Stultz
2017-01-28 0:59 ` [PATCH 1/3] timekeeping: Remove unused timekeeping_{get,set}_tai_offset() John Stultz
2017-01-28 0:59 ` John Stultz [this message]
2017-01-28 0:59 ` [PATCH 3/3] timers: Omit POSIX timer stuff from task_struct when disabled John Stultz
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=1485565171-21223-3-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=davidriley@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=prarit@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
--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
all inboxes | Powered by JetHome®