From patchwork Thu Jul 5 19:12:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 9866 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 66DBB23E4F for ; Thu, 5 Jul 2012 19:14:37 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1A47BA1838C for ; Thu, 5 Jul 2012 19:14:37 +0000 (UTC) Received: by ghbz12 with SMTP id z12so8440044ghb.11 for ; Thu, 05 Jul 2012 12:14:36 -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=1aLJ+YFkB4Y6RsqEBv3RwoqUqiLL2/Bt+QV5Qv+zb28=; b=hHhrOsLZZ2Ab5SgDED2kZ22FU23V+V5+GPT5zB7fRjYxkAk+r+Nm5JZRBjdpTo4U6R dikEAFH0knzM53xCDK3dlIKPUhnABctaMOF/bwwTRbJ435vWdvYQHM6QcIUTzhq2scn3 zquQ9OEm9Qe2bClCzN8EX8q61afsFgG6j2pQXMh2SuDYMECVgyQx3xRNdC8I3AgHLbwA LYF4r1CrHBvfW5ekKvgI95p5WEByuQaeBmpUYPOnC/tG0D66OQ0Iy7nYWb/J2VV+GIit 1dOum/Frm/4DVAbKBf38JDV/4ehPzm8opH+Ip+BBSZ+qOyIq85urIfCWdA+bFQJmnRRh z6VA== Received: by 10.50.195.234 with SMTP id ih10mr758206igc.0.1341515676275; Thu, 05 Jul 2012 12:14:36 -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.24.148 with SMTP id v20csp217ibb; Thu, 5 Jul 2012 12:14:35 -0700 (PDT) Received: by 10.66.73.69 with SMTP id j5mr32707528pav.8.1341515675613; Thu, 05 Jul 2012 12:14:35 -0700 (PDT) Received: from e36.co.us.ibm.com (e36.co.us.ibm.com. [32.97.110.154]) by mx.google.com with ESMTPS id sp1si39355726pbc.230.2012.07.05.12.14.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 12:14:35 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.154 as permitted sender) client-ip=32.97.110.154; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.154 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jul 2012 13:14:32 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Jul 2012 13:13:37 -0600 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 4C8963E40059 for ; Thu, 5 Jul 2012 19:13:36 +0000 (WET) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q65JDGDS276252 for ; Thu, 5 Jul 2012 13:13:19 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q65JDDOY007190 for ; Thu, 5 Jul 2012 13:13:14 -0600 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q65JD4xN006244; Thu, 5 Jul 2012 13:13:08 -0600 From: John Stultz To: Linux Kernel Cc: John Stultz , Prarit Bhargava , stable@vger.kernel.org, Thomas Gleixner Subject: [PATCH 1/3] hrtimer: Fix clock_was_set so it is safe to call from irq context Date: Thu, 5 Jul 2012 15:12:16 -0400 Message-Id: <1341515538-5100-2-git-send-email-johnstul@us.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341515538-5100-1-git-send-email-johnstul@us.ibm.com> References: <1341515538-5100-1-git-send-email-johnstul@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12070519-7606-0000-0000-000001C43FCF X-Gm-Message-State: ALoCoQlkHt4IdRghW/u7UWz33BkBFakXQ3QiGScDE8veXBjRjrcNQXKB5bO9Lw93pBLN1hWvsCVF NOTE:This is a prerequisite patch that's required to address the widely observed leap-second related futex/hrtimer issues. Currently clock_was_set() is unsafe to be called from irq context, as it calls on_each_cpu(). This causes problems when we need to adjust the time from update_wall_time(). To fix this, if clock_was_set is called when irqs are disabled, we schedule a timer to fire for immedately after we're out of interrupt context to then notify the hrtimer subsystem. CC: Prarit Bhargava CC: stable@vger.kernel.org CC: Thomas Gleixner Acked-by: Prarit Bhargava Reported-by: Jan Engelhardt Signed-off-by: John Stultz --- kernel/hrtimer.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index ae34bf5..d730678 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -746,7 +746,7 @@ static inline void retrigger_next_event(void *arg) { } * resolution timer interrupts. On UP we just disable interrupts and * call the high resolution interrupt code. */ -void clock_was_set(void) +static void do_clock_was_set(unsigned long data) { #ifdef CONFIG_HIGH_RES_TIMERS /* Retrigger the CPU local events everywhere */ @@ -755,6 +755,21 @@ void clock_was_set(void) timerfd_clock_was_set(); } +static DEFINE_TIMER(clock_was_set_timer, do_clock_was_set , 0, 0); + +void clock_was_set(void) +{ + /* + * We can't call on_each_cpu() from irq context, + * so if irqs are disabled , schedule the clock_was_set + * via a timer_list timer for right after. + */ + if (irqs_disabled()) + mod_timer(&clock_was_set_timer, jiffies); + else + do_clock_was_set(0); +} + /* * During resume we might have to reprogram the high resolution timer * interrupt (on the local CPU):