From patchwork Tue Jul 10 22:43:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 9938 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 166DE23E57 for ; Tue, 10 Jul 2012 22:44:22 +0000 (UTC) Received: from mail-yw0-f51.google.com (mail-yw0-f51.google.com [209.85.213.51]) by fiordland.canonical.com (Postfix) with ESMTP id D9B2FA185E0 for ; Tue, 10 Jul 2012 22:44:21 +0000 (UTC) Received: by mail-yw0-f51.google.com with SMTP id n12so581706yhn.38 for ; Tue, 10 Jul 2012 15:44:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-gm-message-state; bh=+vq+OKqqAxsLRFqejoXhEHVldUBGhxAh+h5fXZtlYCo=; b=Lghc90Gipkx36Zacxq/DKVqVukhCnZbhReHvMgiOHGlG9/0rb5yhnVQRoGqMIW0miB 5Zx/0J7ugZquVuhMv6N1brT0sL8blICxlw0AvExsgmet16AzVR1i7GHv56jrSquNMIjl yUYvM7RAQ/BrGjmfArbr83PjMXTiOPvO9+8yOgEE4EMQISgIB8OfDuakQk5jngp1kQ1I DWl/c6o6ijN50l5I75LDP48CoTkVmVHhnsLUdUAUEFeRqwcgDxhMny11I3ZjEblrIdKI WpAp9cM0UbzWf4YuP3iX/4yu9pM0cn40E9ksCvAtcW2p0VCd5X7FFlX/vIS4FHcfnTWJ jywg== Received: by 10.50.57.167 with SMTP id j7mr12566554igq.53.1341960261374; Tue, 10 Jul 2012 15:44:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.235.202 with SMTP id kh10csp1493ibb; Tue, 10 Jul 2012 15:44:20 -0700 (PDT) Received: by 10.68.194.4 with SMTP id hs4mr72422480pbc.128.1341960260727; Tue, 10 Jul 2012 15:44:20 -0700 (PDT) Received: from e35.co.us.ibm.com (e35.co.us.ibm.com. [32.97.110.153]) by mx.google.com with ESMTPS id pu9si935028pbc.148.2012.07.10.15.44.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 15:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.153 as permitted sender) client-ip=32.97.110.153; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.153 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jul 2012 16:44:19 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Jul 2012 16:43:45 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id E2B661FF004B for ; Tue, 10 Jul 2012 22:43:43 +0000 (WET) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6AMhihL291904 for ; Tue, 10 Jul 2012 16:43:44 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6AMimOQ013560 for ; Tue, 10 Jul 2012 16:44:48 -0600 Received: from kernel.stglabs.ibm.com ([9.114.214.19]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6AMiji3013399; Tue, 10 Jul 2012 16:44:47 -0600 From: John Stultz To: Linux Kernel Cc: John Stultz , Ingo Molnar , Peter Zijlstra , Prarit Bhargava , Thomas Gleixner , stable@vger.kernel.org Subject: [PATCH 2/6] timekeeping: Fix leapsecond triggered load spike issue Date: Tue, 10 Jul 2012 18:43:20 -0400 Message-Id: <1341960205-56738-3-git-send-email-johnstul@us.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341960205-56738-1-git-send-email-johnstul@us.ibm.com> References: <1341960205-56738-1-git-send-email-johnstul@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12071022-6148-0000-0000-0000078A3ADF X-Gm-Message-State: ALoCoQk84K0psxc+aaiIcdpJORIIvJCo2TRdMOZ80Fp18wXoWrJlrwhaQCDKAACPfywDQ7ZcpQj8 The timekeeping code misses an update of the hrtimer subsystem after a leap second happened. Due to that timers based on CLOCK_REALTIME are either expiring a second early or late depending on whether a leap second has been inserted or deleted until an operation is initiated which causes that update. Unless the update happens by some other means this discrepancy between the timekeeping and the hrtimer data stays forever and timers are expired either early or late. The reported immediate workaround - $ data -s "`date`" - is causing a call to clock_was_set() which updates the hrtimer data structures. See: http://www.sheeri.com/content/mysql-and-leap-second-high-cpu-and-fix Add the missing clock_was_set() call to update_wall_time() in case of a leap second event. The actual update is deferred to softirq context as the necessary smp function call cannot be invoked from hard interrupt context. CC: Ingo Molnar CC: Peter Zijlstra CC: Prarit Bhargava CC: Thomas Gleixner CC: stable@vger.kernel.org Reported-by: Jan Engelhardt Signed-off-by: John Stultz Signed-off-by: Thomas Gleixner Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6f46a00..a413e59 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -963,6 +963,8 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift) leap = second_overflow(timekeeper.xtime.tv_sec); timekeeper.xtime.tv_sec += leap; timekeeper.wall_to_monotonic.tv_sec -= leap; + if (leap) + clock_was_set_delayed(); } /* Accumulate raw time */ @@ -1079,6 +1081,8 @@ static void update_wall_time(void) leap = second_overflow(timekeeper.xtime.tv_sec); timekeeper.xtime.tv_sec += leap; timekeeper.wall_to_monotonic.tv_sec -= leap; + if (leap) + clock_was_set_delayed(); } timekeeping_update(false);