From: Thomas Gleixner <tglx@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [GIT pull] timer updates for 4.9
Date: Mon, 24 Oct 2016 16:51:35 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1610241638170.4983@nanos> (raw)
In-Reply-To: <alpine.DEB.2.20.1610240947160.4872@nanos>
On Mon, 24 Oct 2016, Thomas Gleixner wrote:
> On Sun, 23 Oct 2016, Linus Torvalds wrote:
> > So I found what looks like a bug in lock_timer_base() wrt migration.
> >
> > This code:
> >
> > for (;;) {
> > struct timer_base *base;
> > u32 tf = timer->flags;
> >
> > if (!(tf & TIMER_MIGRATING)) {
> > base = get_timer_base(tf);
> > spin_lock_irqsave(&base->lock, *flags);
> > if (timer->flags == tf)
> > return base;
> > spin_unlock_irqrestore(&base->lock, *flags);
> > }
> > cpu_relax();
> > }
> >
> > looks subtly buggy. I think that load of "tf" needs a READ_ONCE() to
> > make sure that gcc doesn't simply reload the valid of "timer->flags"
> > at random points.
>
> You are right, that needs a READ_ONCE(). Stupid me.
>
> > Yes, the spin_lock_irqsave() is a barrier, but that's the only one.
> > Afaik, gcc could decide that "I need to spill tf, so I'll just reload
> > it" after looking up get_timer_base().
> >
> > And no, I don't think this is the cause of my problem, but I suspect
> > that something _like_ fragility in lock_timer_base() could cause this.
>
> It might explain it, when this really ends up with the wrong base.
Can you please check in the disassembly whether gcc really reloads
timer->flags? Mine does not...
Another thing you might try is to enable debugobjects. As this happens only
at shutdown time the problem might be caused by something else which
wreckages timers in some subtle way.
Thanks,
tglx
next prev parent reply other threads:[~2016-10-24 14:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-22 12:02 Thomas Gleixner
2016-10-23 22:39 ` Linus Torvalds
2016-10-23 23:20 ` Linus Torvalds
2016-10-24 9:39 ` Thomas Gleixner
2016-10-24 14:51 ` Thomas Gleixner [this message]
2016-10-24 15:13 ` Thomas Gleixner
2016-10-25 14:57 ` [tip:timers/urgent] timers: Plug locking race vs. timer migration tip-bot for Thomas Gleixner
2016-10-25 14:58 ` [tip:timers/urgent] timers: Lock base for same bucket optimization tip-bot for Thomas Gleixner
2016-10-24 17:16 ` [GIT pull] timer updates for 4.9 Linus Torvalds
2016-10-24 19:09 ` Thomas Gleixner
2016-10-24 19:30 ` Linus Torvalds
2016-10-24 21:36 ` Thomas Gleixner
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=alpine.DEB.2.20.1610241638170.4983@nanos \
--to=tglx@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.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®