From patchwork Wed Jul 4 06:21:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 9813 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 35F3723E23 for ; Wed, 4 Jul 2012 06:22:51 +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 E0589A187ED for ; Wed, 4 Jul 2012 06:22:50 +0000 (UTC) Received: by ghbz12 with SMTP id z12so6658032ghb.11 for ; Tue, 03 Jul 2012 23:22:50 -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=nFhcoVHMIH+upKIMsqA8bgoo1DVdXT2Bgpyvc6tG+EI=; b=fIOWBZku580ckunz7qYfnIXQan3lAXcsjSUdhSt6r17Sey1dMA1NXkZEk53Z+A95pe 3XVVYqM8lmK+OuLdVnlYBiMZ81spSEezXmCFsflYIrVqiSbyB8qxMEd7d/nvH1XIwGRI B9Keigxwl50pXgd879kuZb1JtOqyZHzgj7HnBVpHCd+KG3xQ7xZ7pdfzqjt1dBImkIWM r3W4bC8IAsJ+kkNIJSYhSqXdZmKFYpsvOaVbSZJ/mhdBxVm/n6BtldKbDkba/xfZSEYO 4OutYoGxhCp5iSDSvZVJfoziGqRfJVslawVMaCucj+dbpMikcQKo6qQwoBfn6sugv4mA QEjA== Received: by 10.50.203.39 with SMTP id kn7mr12327782igc.53.1341382970255; Tue, 03 Jul 2012 23:22:50 -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 v20csp49796ibb; Tue, 3 Jul 2012 23:22:49 -0700 (PDT) Received: by 10.50.203.39 with SMTP id kn7mr12327770igc.53.1341382969861; Tue, 03 Jul 2012 23:22:49 -0700 (PDT) Received: from e4.ny.us.ibm.com (e4.ny.us.ibm.com. [32.97.182.144]) by mx.google.com with ESMTPS id gf6si6648622igb.23.2012.07.03.23.22.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 23:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.144 as permitted sender) client-ip=32.97.182.144; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.182.144 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e4.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Jul 2012 02:22:47 -0400 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e4.ny.us.ibm.com (192.168.1.104) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Jul 2012 02:21:56 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id B0F196E8054 for ; Wed, 4 Jul 2012 02:21:55 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q646LtGp265228 for ; Wed, 4 Jul 2012 02:21:55 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q64BqmGq019357 for ; Wed, 4 Jul 2012 07:52:48 -0400 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q64BqmM3019347; Wed, 4 Jul 2012 07:52:48 -0400 From: John Stultz To: Linux Kernel Cc: John Stultz , Prarit Bhargava , stable@vger.kernel.org, Thomas Gleixner , linux@openhuawei.org Subject: [PATCH 1/3] [RFC] hrtimer: Fix clock_was_set so it is safe to call from irq context Date: Wed, 4 Jul 2012 02:21:28 -0400 Message-Id: <1341382890-42324-2-git-send-email-johnstul@us.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341382890-42324-1-git-send-email-johnstul@us.ibm.com> References: <1341382890-42324-1-git-send-email-johnstul@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12070406-3534-0000-0000-00000A1C05A9 X-Gm-Message-State: ALoCoQkLSRqzqG0qBqQ2Mt6QfCZx/KKlmlmaADVgEYDY+fJAL6gvSG9tQCr5c8PtHOY8AHMP/24x 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 CC: linux@openhuawei.org 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):