From: "Duane Griffin" <duaneg@dghda.com>
To: Chris Adams <cmadams@hiwaay.net>
Cc: Duane Griffin <duaneg@dghda.com>,
Linas Vepstas <linasvepstas@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Re: Bug: Status/Summary of slashdot leap-second crash on new years 2008-2009
Date: Sat, 3 Jan 2009 04:52:28 +0000 [thread overview]
Message-ID: <20090103045227.GA5994@dastardly.home.dghda.com> (raw)
In-Reply-To: <20090103044143.GB1538533@hiwaay.net>
On Fri, Jan 02, 2009 at 10:41:43PM -0600, Chris Adams wrote:
> Once upon a time, Duane Griffin <duaneg@dghda.com> said:
> > On Fri, Jan 02, 2009 at 06:21:14PM -0600, Chris Adams wrote:
> > > In any case, the quick-n-dirty fix would be to not try to printk while
> > > holding xtime_lock (I think the NTP code is the only thing that does).
> > > However, it would be nice to still get the leap second notification, so
> > > some other fix would be better I guess.
> >
> > How about just moving the printk out of the lock? I.e. something like
> > this:
>
> Well, you've only fixed the inserting a leap second case, not the
> removing a leap second case. AFAIK we've never actually had a leap
> second removed, but it could happen (and the code is already there), so
> it should be fixed as well.
Quite right...
> Also, I didn't notice the locking was right there in the ntp_leap_second
> function in the 2.6.26.6 kernel I was looking at, because I've also been
> looking at the 2.6.9-based RHEL 4 kernel (which is a good bit different;
> the lock is held outside the function, so it wouldn't be easy to drop it
> for the printk). I guess that's Red Hat's (and other long-term support
> vendors') problem. The simplest thing for them is still probably to
> just remove the printks.
>
> Here's a patch that moves both prinkts outside the lock. I am unable to
> make a kernel with this patch crash on a leap second insertion or
> deletion.
> --
> Chris Adams <cmadams@hiwaay.net>
> Systems and Network Administrator - HiWAAY Internet Services
> I don't speak for anybody but myself - that's enough trouble.
>
>
> From: Chris Adams <cmadams@hiwaay.net>
>
> The code to handle leap seconds printks an information message when the
> second is inserted or deleted. It does this while holding xtime_lock.
> However, printk wakes up klogd, and in some cases, the scheduler tries
> to get the current kernel time, trying to get xtime_lock (which results
> in a deadlock). This moved the printks outside of the lock.
>
> Signed-off-by: Chris Adams <cmadams@hiwaay.net>
> ---
> diff -urpN linux-2.6.28-git5-vanilla/kernel/time/ntp.c linux-2.6.28-git5/kernel/time/ntp.c
> --- linux-2.6.28-git5-vanilla/kernel/time/ntp.c 2009-01-02 22:09:34.000000000 -0600
> +++ linux-2.6.28-git5/kernel/time/ntp.c 2009-01-02 22:11:23.000000000 -0600
> @@ -130,6 +130,7 @@ void ntp_clear(void)
> static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
> {
> enum hrtimer_restart res = HRTIMER_NORESTART;
> + int msg = 0;
>
> write_seqlock(&xtime_lock);
>
> @@ -140,8 +141,7 @@ static enum hrtimer_restart ntp_leap_sec
> xtime.tv_sec--;
> wall_to_monotonic.tv_sec++;
> time_state = TIME_OOP;
> - printk(KERN_NOTICE "Clock: "
> - "inserting leap second 23:59:60 UTC\n");
> + msg = 1;
> hrtimer_add_expires_ns(&leap_timer, NSEC_PER_SEC);
> res = HRTIMER_RESTART;
> break;
> @@ -150,8 +150,7 @@ static enum hrtimer_restart ntp_leap_sec
> time_tai--;
> wall_to_monotonic.tv_sec--;
> time_state = TIME_WAIT;
> - printk(KERN_NOTICE "Clock: "
> - "deleting leap second 23:59:59 UTC\n");
> + msg = 2;
> break;
> case TIME_OOP:
> time_tai++;
> @@ -166,6 +165,17 @@ static enum hrtimer_restart ntp_leap_sec
>
> write_sequnlock(&xtime_lock);
>
> + switch (msg) {
> + case 1:
> + printk(KERN_NOTICE "Clock: "
> + "inserting leap second 23:59:60 UTC\n");
> + break;
> + case 2:
> + printk(KERN_NOTICE "Clock: "
> + "deleting leap second 23:59:59 UTC\n");
> + break;
> + }
> +
> return res;
> }
>
How about instead of a switch statement, assigning the message to a
variable and printing that. I.e. something like:
static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
{
enum hrtimer_restart res = HRTIMER_NORESTART;
const char *msg = NULL;
...
msg = "Clock: inserting leap second 23:59:60 UTC";
...
msg = "Clock: deleting leap second 23:59:59 UTC";
...
if (msg)
printk(KERN_NOTICE "%s\n", msg);
Cheers,
Duane.
--
"I never could learn to drink that blood and call it wine" - Bob Dylan
next prev parent reply other threads:[~2009-01-03 4:52 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-02 19:25 Linas Vepstas
2009-01-02 20:04 ` Diego Calleja
2009-01-02 20:25 ` Robert Hancock
2009-01-03 6:32 ` David Newall
2009-01-03 6:37 ` Ben Goodger
2009-01-04 8:43 ` David Newall
2009-01-04 9:00 ` Kyle Moffett
2009-01-04 10:03 ` David Newall
2009-01-04 11:13 ` david
2009-01-04 23:15 ` David Newall
2009-01-04 23:25 ` Chris Adams
2009-01-05 0:01 ` David Newall
2009-01-05 0:41 ` Alan Cox
2009-01-05 8:43 ` David Newall
2009-01-05 19:47 ` Alan Cox
2009-01-05 0:29 ` david
2009-01-04 23:37 ` David Newall
2009-01-05 1:05 ` david
2009-01-05 0:14 ` David Newall
2009-01-05 0:21 ` Ben Goodger
2009-01-05 6:34 ` David Newall
2009-01-05 23:03 ` Linas Vepstas
2009-01-05 0:44 ` Alan Cox
2009-01-05 5:48 ` Linas Vepstas
2009-01-05 14:33 ` Nick Andrew
2009-01-05 16:08 ` Linas Vepstas
2009-01-05 17:51 ` david
2009-01-05 17:42 ` Linas Vepstas
2009-01-06 2:27 ` john stultz-lkml
2009-01-06 4:53 ` Linas Vepstas
2009-01-06 5:00 ` Linas Vepstas
2009-01-06 19:40 ` [ntpwg] " M. Warner Losh
2009-01-06 19:50 ` M. Warner Losh
2009-01-07 3:50 ` Danny Mayer
2009-01-07 4:52 ` Linas Vepstas
2009-01-07 10:03 ` David Newall
2009-01-07 17:24 ` M. Warner Losh
2009-01-08 16:51 ` Magnus Danielson
2009-01-07 14:34 ` Danny Mayer
2009-01-07 15:42 ` Linas Vepstas
2009-01-07 19:23 ` Danny Mayer
2009-01-07 16:04 ` john stultz
2009-01-07 17:36 ` M. Warner Losh
2009-01-07 17:39 ` M. Warner Losh
2009-01-07 19:31 ` Alan Cox
2009-01-07 19:42 ` M. Warner Losh
2009-01-08 3:57 ` Danny Mayer
2009-01-08 4:42 ` M. Warner Losh
2009-01-08 10:48 ` Alan Cox
2009-01-08 10:56 ` Alan Cox
2009-01-08 22:22 ` David Mills
2009-01-08 15:02 ` M. Warner Losh
2009-01-08 18:57 ` Marshall Eubanks
2009-01-08 20:09 ` Steve Allen
2009-01-12 16:11 ` Pavel Machek
2009-01-12 17:07 ` [ntpwg] " M. Warner Losh
2009-01-12 21:45 ` Valdis.Kletnieks
2009-01-06 2:31 ` Nick Andrew
2009-01-06 1:59 ` David Newall
2009-01-06 2:18 ` Chris Adams
2009-01-06 2:51 ` Nick Andrew
2009-01-06 9:40 ` Alan Cox
2009-01-07 1:17 ` Nick Andrew
2009-01-07 9:37 ` Alan Cox
2009-01-07 9:46 ` David Newall
2009-01-07 9:54 ` Alan Cox
2009-01-07 10:18 ` David Newall
2009-01-07 10:52 ` Alan Cox
2009-01-07 13:45 ` David Newall
2009-01-07 14:10 ` Alan Cox
2009-01-07 14:36 ` David Newall
2009-01-07 15:40 ` Alan Cox
2009-01-10 9:46 ` David Newall
2009-01-07 22:13 ` Chris Adams
2009-01-07 13:33 ` Chris Adams
2009-01-07 13:37 ` Alan Cox
2009-01-07 14:12 ` David Newall
2009-01-07 14:09 ` David Newall
2009-01-07 21:42 ` Chris Adams
2009-01-04 11:35 ` Valdis.Kletnieks
2009-01-05 0:08 ` David Newall
2009-01-06 3:53 ` Valdis.Kletnieks
2009-01-04 17:20 ` Kyle Moffett
2009-01-03 7:00 ` Chris Adams
2009-01-04 8:41 ` David Newall
2009-01-02 20:29 ` Linas Vepstas
[not found] ` <8752a8760901021328t545a0327v58faebe1e921680a@mail.gmail.com>
2009-01-02 21:29 ` Ben Goodger
2009-01-03 0:21 ` Chris Adams
2009-01-03 2:23 ` Duane Griffin
2009-01-03 3:45 ` Linas Vepstas
2009-01-03 4:41 ` [PATCH] " Chris Adams
2009-01-03 4:52 ` Duane Griffin [this message]
2009-01-03 18:01 ` [PATCH] v2 " Chris Adams
2009-01-03 19:04 ` Duane Griffin
2009-01-03 20:01 ` Linas Vepstas
2009-06-08 2:18 ` Ben Hutchings
2009-06-18 22:34 ` Chris Friesen
2009-06-18 22:58 ` Ben Hutchings
2009-06-18 23:48 ` Chris Friesen
2009-01-06 2:21 ` john stultz-lkml
2009-01-06 2:25 ` Chris Adams
2009-01-06 4:35 ` Linas Vepstas
2009-01-03 3:49 ` Linas Vepstas
2009-01-03 4:02 ` Ben Goodger
2009-01-03 4:46 ` Duane Griffin
2009-01-03 4:50 ` Ben Goodger
2009-01-03 22:58 ` Jeffrey J. Kosowsky
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=20090103045227.GA5994@dastardly.home.dghda.com \
--to=duaneg@dghda.com \
--cc=cmadams@hiwaay.net \
--cc=linasvepstas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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®