From patchwork Sun Jul 1 18:30:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 9721 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 266ED23E23 for ; Sun, 1 Jul 2012 18:31:25 +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 E997AA1843E for ; Sun, 1 Jul 2012 18:31:24 +0000 (UTC) Received: by ghbz12 with SMTP id z12so4036703ghb.11 for ; Sun, 01 Jul 2012 11:31:24 -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-cbid :x-ibm-iss-spamdetectors:x-ibm-iss-detailinfo:x-gm-message-state; bh=A2oA+4rTfuNJoXRxeCpZe2wMcx553xdnQR57FR8F6TU=; b=aKjqEDD0qE4s1btStMEUzDYexVcQMtbtXzrsA3Prd9VLur0AIkz1LaN5V3z5viSVs+ ZXeP/4RwlW1D94TTz/IMaQrNlhnFKvX/iF/vIuqPmyvDXBUQIHPf2Y65Z+yCugUnm6tz H2Zkr+Qop1S5AXJQgdi1AGu4lh5tVPy+fKqpxHzsZxK6HmZv7xf0Fxpe9alUp5I3Asw2 uo2XgSRBRcMTcPCmHV+JKn8H1lBCchms4FlVd3sTbTEFhjCETdjQqkA8GSOQaeuK5Mf9 uZZ1f2Xt0Os/XhzriqeZ7EhYBp1tBB6sl5uSqfyylNSw+OYKGPy6NwKMp5pDc6OR1rcj E4Kw== Received: by 10.42.89.72 with SMTP id f8mr4747531icm.33.1341167484269; Sun, 01 Jul 2012 11:31:24 -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 v20csp13473ibb; Sun, 1 Jul 2012 11:31:23 -0700 (PDT) Received: by 10.68.231.229 with SMTP id tj5mr24155013pbc.39.1341167483479; Sun, 01 Jul 2012 11:31:23 -0700 (PDT) Received: from e34.co.us.ibm.com (e34.co.us.ibm.com. [32.97.110.152]) by mx.google.com with ESMTPS id tm4si18070249pbc.302.2012.07.01.11.31.23 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jul 2012 11:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.152 as permitted sender) client-ip=32.97.110.152; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.152 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 1 Jul 2012 12:31:22 -0600 Received: from d03relay02.boulder.ibm.com (9.17.195.227) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 1 Jul 2012 12:31:05 -0600 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q61IUSZe124508 for ; Sun, 1 Jul 2012 12:30:48 -0600 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q61IUDul023942 for ; Sun, 1 Jul 2012 12:30:13 -0600 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q61IUBgt023866; Sun, 1 Jul 2012 12:30:12 -0600 From: John Stultz To: Linux Kernel Cc: John Stultz , Prarit Bhargava , stable@vger.kernel.org, Thomas Gleixner Subject: [PATCH 1/2] [RFC] Fix clock_was_set so it is safe to call from atomic Date: Sun, 1 Jul 2012 14:30:00 -0400 Message-Id: <1341167401-31342-2-git-send-email-johnstul@us.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341167401-31342-1-git-send-email-johnstul@us.ibm.com> References: <1341167401-31342-1-git-send-email-johnstul@us.ibm.com> x-cbid: 12070118-1780-0000-0000-000007001CF6 X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000284; HX=3.00000191; KW=3.00000007; PH=3.00000001; SC=3.00000004; SDB=6.00152897; UDB=6.00034576; UTC=2012-07-01 18:31:21 X-Gm-Message-State: ALoCoQnQcWRyDxpp+GVhiD3MegfzfNZwUzM+jVOkjcaP9m5DCAQhBpcVz5dio5BAPpzOsqZR9wtM 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 atomic context, as it calls on_each_cpu(). This causes problems when we need to adjust the time from update_wall_time(). To fix this, introduce a work_struct so if we're in_atomic, we can schedule work to do the necessary update after we're out of the atomic section. CC: Prarit Bhargava CC: stable@vger.kernel.org CC: Thomas Gleixner Reported-by: Jan Engelhardt Signed-off-by: John Stultz --- kernel/hrtimer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index ae34bf5..ee7a98d 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(struct work_struct *work) { #ifdef CONFIG_HIGH_RES_TIMERS /* Retrigger the CPU local events everywhere */ @@ -754,6 +754,20 @@ void clock_was_set(void) #endif timerfd_clock_was_set(); } +static DECLARE_WORK(clock_was_set_work, do_clock_was_set); + +void clock_was_set(void) +{ + /* + * We can't call on_each_cpu() from atomic context, + * so if we're in_atomic, schedule the clock_was_set + * for later. + */ + if (in_atomic()) + schedule_work(&clock_was_set_work); + else + do_clock_was_set(NULL); +} /* * During resume we might have to reprogram the high resolution timer