From: tip-bot for Eric Dumazet <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux@eikelenboom.it, davem@davemloft.net, hpa@zytor.com,
tglx@linutronix.de, edumazet@google.com,
linux-kernel@vger.kernel.org, mingo@kernel.org, jon@jons.org
Subject: [tip:timers/urgent] timer: Write timer->flags atomically
Date: Tue, 18 Aug 2015 06:36:42 -0700 [thread overview]
Message-ID: <tip-d0023a1448abdcc892b8bca631e74bb1888efd02@git.kernel.org> (raw)
In-Reply-To: <1439831928.32680.11.camel@edumazet-glaptop2.roam.corp.google.com>
Commit-ID: d0023a1448abdcc892b8bca631e74bb1888efd02
Gitweb: http://git.kernel.org/tip/d0023a1448abdcc892b8bca631e74bb1888efd02
Author: Eric Dumazet <edumazet@google.com>
AuthorDate: Mon, 17 Aug 2015 10:18:48 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 18 Aug 2015 15:31:16 +0200
timer: Write timer->flags atomically
lock_timer_base() cannot prevent the following :
CPU1 ( in __mod_timer()
timer->flags |= TIMER_MIGRATING;
spin_unlock(&base->lock);
base = new_base;
spin_lock(&base->lock);
// The next line clears TIMER_MIGRATING
timer->flags &= ~TIMER_BASEMASK;
CPU2 (in lock_timer_base())
see timer base is cpu0 base
spin_lock_irqsave(&base->lock, *flags);
if (timer->flags == tf)
return base; // oops, wrong base
timer->flags |= base->cpu // too late
We must write timer->flags in one go, otherwise we can fool other cpus.
Fixes: bc7a34b8b9eb ("timer: Reduce timer migration overhead if disabled")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jon Christopherson <jon@jons.org>
Cc: David Miller <davem@davemloft.net>
Cc: xen-devel@lists.xen.org
Cc: david.vrabel@citrix.com
Cc: Sander Eikelenboom <linux@eikelenboom.it>
Link: http://lkml.kernel.org/r/1439831928.32680.11.camel@edumazet-glaptop2.roam.corp.google.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 5e097fa..84190f0 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -807,8 +807,8 @@ __mod_timer(struct timer_list *timer, unsigned long expires,
spin_unlock(&base->lock);
base = new_base;
spin_lock(&base->lock);
- timer->flags &= ~TIMER_BASEMASK;
- timer->flags |= base->cpu;
+ WRITE_ONCE(timer->flags,
+ (timer->flags & ~TIMER_BASEMASK) | base->cpu);
}
}
prev parent reply other threads:[~2015-08-18 13:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-12 19:19 Linux 4.2-rc6 regression: RIP: e030:[<ffffffff8110fb18>] [<ffffffff8110fb18>] detach_if_pending+0x18/0x80 linux
2015-08-12 20:41 ` Eric Dumazet
2015-08-12 20:50 ` linux
2015-08-12 21:40 ` David Miller
2015-08-12 21:46 ` Sander Eikelenboom
2015-08-12 22:41 ` Eric Dumazet
2015-08-14 22:09 ` Sander Eikelenboom
2015-08-14 22:16 ` Sander Eikelenboom
2015-08-14 22:39 ` Eric Dumazet
2015-08-17 9:09 ` Sander Eikelenboom
2015-08-17 13:37 ` Eric Dumazet
2015-08-17 13:48 ` Sander Eikelenboom
2015-08-17 14:02 ` Jon Christopherson
2015-08-17 14:21 ` Eric Dumazet
2015-08-17 14:25 ` Sander Eikelenboom
2015-08-17 15:16 ` Jon Christopherson
2015-08-17 17:18 ` Eric Dumazet
2015-08-17 18:27 ` Sander Eikelenboom
2015-08-17 19:13 ` Thomas Gleixner
2015-08-18 0:05 ` Jon Christopherson
2015-08-18 13:36 ` tip-bot for Eric Dumazet [this message]
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=tip-d0023a1448abdcc892b8bca631e74bb1888efd02@git.kernel.org \
--to=tipbot@zytor.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hpa@zytor.com \
--cc=jon@jons.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=linux@eikelenboom.it \
--cc=mingo@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