From patchwork Tue Jul 10 22:43:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 9935 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 471AD23E57 for ; Tue, 10 Jul 2012 22:43:58 +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 E87E2A188CC for ; Tue, 10 Jul 2012 22:43:57 +0000 (UTC) Received: by yhnn12 with SMTP id n12so581706yhn.38 for ; Tue, 10 Jul 2012 15:43:47 -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=LJ0P10mDJJWiBVgD4nZfGzG+Zd8Y/+wnsIOFtDRGq8o=; b=nIrsN/Kzf14N+aG3OHPRRFWG7nug5qr4z+Pdtgs9/FDBHS0IM2BOAoN9aGwk0eL300 VhlTFG1hlSWeePl9xCQQYB22hehSu+0CpbvLE8ffCg+PjDPbJPIivpqSPy9iad09lDoa cwCZCb+eeBtuegLH35SwSmTU7iHnCv+yAZhQogzbW5X+zHrzDjD65di0tJhU5aoegGet W47feowWnuaJ5paVXkJKPSaOkVZSXhjpvs3sCm3ngdPSfx1AluZ/VNRm2WJq3Fk2JWU5 q0sx8jxpnswMs3wwy1b+9VSkl02XnU3CfL4snNEvJ63urHalVu2FafwzXwzUkynu0p8G yt8A== Received: by 10.50.160.198 with SMTP id xm6mr12999527igb.0.1341960227073; Tue, 10 Jul 2012 15:43:47 -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 kh10csp1481ibb; Tue, 10 Jul 2012 15:43:46 -0700 (PDT) Received: by 10.50.46.230 with SMTP id y6mr12699049igm.20.1341960226659; Tue, 10 Jul 2012 15:43:46 -0700 (PDT) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com. [32.97.182.146]) by mx.google.com with ESMTPS id vy9si38071igb.0.2012.07.10.15.43.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 15:43:46 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.146 as permitted sender) client-ip=32.97.182.146; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.146 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jul 2012 18:43:46 -0400 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e6.ny.us.ibm.com (192.168.1.106) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Jul 2012 18:43:44 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 8108D6E804C for ; Tue, 10 Jul 2012 18:43:43 -0400 (EDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6AMhgKT439410 for ; Tue, 10 Jul 2012 18:43:43 -0400 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 q6AMil3Q013537 for ; Tue, 10 Jul 2012 16:44:47 -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 q6AMiji2013399; Tue, 10 Jul 2012 16:44:46 -0600 From: John Stultz To: Linux Kernel Cc: John Stultz , Ingo Molnar , Peter Zijlstra , Prarit Bhargava , Thomas Gleixner , stable@vger.kernel.org Subject: [PATCH 1/6] hrtimer: Provide clock_was_set_delayed() Date: Tue, 10 Jul 2012 18:43:19 -0400 Message-Id: <1341960205-56738-2-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-1976-0000-0000-00000F108DD6 X-Gm-Message-State: ALoCoQmJxELsAd7rPj9DlzkrjPEUoVo037LddD+wmqXzIdT99Vy87ta+3739zg9NLwcWG/7AarIO clock_was_set() cannot be called from hard interrupt context because it calls on_each_cpu(). For fixing the widely reported leap seconds issue it's necessary to call it from the timer interrupt context. Provide a new function which denotes it in the hrtimer cpu base structure of the cpu on which it is called and raising the timer softirq. We then execute the clock_was_set() notificiation in the timer softirq context in hrtimer_run_pending(). 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 --- include/linux/hrtimer.h | 5 ++++- kernel/hrtimer.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index fd0dc30..4c3dac8 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -165,6 +165,7 @@ enum hrtimer_base_type { * @lock: lock protecting the base and associated clock bases * and timers * @active_bases: Bitfield to mark bases with active timers + * @clock_was_set: Indicates that clock was set from irq context. * @expires_next: absolute time of the next event which was scheduled * via clock_set_next_event() * @hres_active: State of high resolution mode @@ -177,7 +178,8 @@ enum hrtimer_base_type { */ struct hrtimer_cpu_base { raw_spinlock_t lock; - unsigned long active_bases; + unsigned int active_bases; + unsigned int clock_was_set; #ifdef CONFIG_HIGH_RES_TIMERS ktime_t expires_next; int hres_active; @@ -309,6 +311,7 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) #endif extern void clock_was_set(void); +extern void clock_was_set_delayed(void); #ifdef CONFIG_TIMERFD extern void timerfd_clock_was_set(void); #else diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index ae34bf5..7c20cb8 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -756,6 +756,19 @@ void clock_was_set(void) } /* + * Called from timekeeping code to reprogramm the hrtimer interrupt + * device. If called from the timer interrupt context we defer it to + * softirq context. + */ +void clock_was_set_delayed(void) +{ + struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); + + cpu_base->clock_was_set = 1; + __raise_softirq_irqoff(TIMER_SOFTIRQ); +} + +/* * During resume we might have to reprogram the high resolution timer * interrupt (on the local CPU): */ @@ -1413,6 +1426,13 @@ static inline void __hrtimer_peek_ahead_timers(void) { } */ void hrtimer_run_pending(void) { + struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); + + if (cpu_base->clock_was_set) { + cpu_base->clock_was_set = 0; + clock_was_set(); + } + if (hrtimer_hres_active()) return;