From: sonic zhang <sonic.adi@gmail.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
john stultz <johnstul@us.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] Timekeeping: Fix dead lock in update_wall_time by correct shift convertion.
Date: Tue, 16 Mar 2010 18:43:45 +0800 [thread overview]
Message-ID: <1268736225.5075.10.camel@eight.analog.com> (raw)
update_wall_time() runs into dead lock after kernel traps into kgdb and exits
per user's request some seconds layer. This is root caused to be wrong
calculation of maxshift in update_wall_time().
The shift in update_wall_time() and logarithmic_accumulation() is
clock shift. In order to generate ntp_error and maxshift correctly,
shift convertion between clock and ntp should be done properly.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
kernel/time/timekeeping.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 1673637..5b47c9e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -770,10 +770,14 @@ static cycle_t logarithmic_accumulation(cycle_t
offset, int shift)
raw_time.tv_sec++;
}
- /* Accumulate error between NTP and clock interval */
- timekeeper.ntp_error += tick_length << shift;
- timekeeper.ntp_error -= timekeeper.xtime_interval <<
- (timekeeper.ntp_error_shift + shift);
+ /*
+ * Accumulate error between NTP and clock interval.
+ * Paramter shift is clock shift. It should minus shift
+ * conversion between clock and ntp to generate ntp shift.
+ */
+ timekeeper.ntp_error += tick_length <<
+ (shift - timekeeper.ntp_error_shift);
+ timekeeper.ntp_error -= timekeeper.xtime_interval << shift;
return offset;
}
@@ -813,8 +817,12 @@ void update_wall_time(void)
*/
shift = ilog2(offset) - ilog2(timekeeper.cycle_interval);
shift = max(0, shift);
- /* Bound shift to one less then what overflows tick_length */
- maxshift = (8*sizeof(tick_length) - (ilog2(tick_length)+1)) - 1;
+ /*
+ * Bound shift to one less then what overflows tick_length.
+ * Should plus shift conversion between clock and ntp.
+ */
+ maxshift = (8*sizeof(tick_length) - (ilog2(tick_length)+1)) - 1
+ + timekeeper.ntp_error_shift;
shift = min(shift, maxshift);
while (offset >= timekeeper.cycle_interval) {
offset = logarithmic_accumulation(offset, shift);
--
1.6.0
next reply other threads:[~2010-03-16 10:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 10:43 sonic zhang [this message]
[not found] <1268735629.5075.8.camel@eight.analog.com>
[not found] ` <1268763512.1676.7.camel@work-vm>
2010-03-17 2:58 ` Sonic Zhang
2010-03-17 3:41 ` john stultz
2010-03-17 5:14 ` Sonic Zhang
2010-03-17 15:59 ` 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=1268736225.5075.10.camel@eight.analog.com \
--to=sonic.adi@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--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
Powered by JetHome