From patchwork Tue Jul 10 22:43:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john stultz X-Patchwork-Id: 9940 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 806BE23E57 for ; Tue, 10 Jul 2012 22:45:18 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3A5A4A1819A for ; Tue, 10 Jul 2012 22:45:18 +0000 (UTC) Received: by yenq6 with SMTP id q6so657079yen.11 for ; Tue, 10 Jul 2012 15:45:07 -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=TgBYwGnvPZaIrGSuZ6oNnzC2G/pXxs31GAzg9hivMMA=; b=XRwU7TGzGnYmdA9HKYmeigi7r6izVAvXqrdwAjT9+RPjAgkKTY+wNFEL4moKhPiuv7 NzKv65AgMdmyxma5q8GYymOixbSW37efFjFhVqxYI52ywtXhqv1L9h2Gv8ZIbWUiOXLj FGRRzw1/7H4W1jGJHa7Z6vDW+SThKYkXu7KAw32tb2Am9jWGSNe24n4q8kVOIbXW3WY/ nmGFTT8gImYZC7eFeaLZ+EIiQ26+gBgssrTz6v0CtaHVP+Cqb0zzJ1DkN4wUVmk/NID3 c4A6FkLNGNiRg1t9n9n9KCoZTABRUMWFdW47GJtTEsuEIocHT7YEfI+5tnXtRwr3JzE/ XWDA== Received: by 10.50.160.198 with SMTP id xm6mr13001554igb.0.1341960307322; Tue, 10 Jul 2012 15:45:07 -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 kh10csp1501ibb; Tue, 10 Jul 2012 15:45:07 -0700 (PDT) Received: by 10.50.42.130 with SMTP id o2mr12909894igl.37.1341960306876; Tue, 10 Jul 2012 15:45:06 -0700 (PDT) Received: from e37.co.us.ibm.com (e37.co.us.ibm.com. [32.97.110.158]) by mx.google.com with ESMTPS id l10si24696icz.31.2012.07.10.15.45.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 15:45:06 -0700 (PDT) Received-SPF: pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.158 as permitted sender) client-ip=32.97.110.158; Authentication-Results: mx.google.com; spf=pass (google.com: domain of johnstul@us.ibm.com designates 32.97.110.158 as permitted sender) smtp.mail=johnstul@us.ibm.com Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jul 2012 16:45:05 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Jul 2012 16:45:03 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 8294E1FF0051 for ; Tue, 10 Jul 2012 22:44:36 +0000 (WET) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6AMi19o017040 for ; Tue, 10 Jul 2012 16:44:21 -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 q6AMioKb013660 for ; Tue, 10 Jul 2012 16:44:51 -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 q6AMiji6013399; Tue, 10 Jul 2012 16:44:50 -0600 From: John Stultz To: Linux Kernel Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Prarit Bhargava , stable@vger.kernel.org, John Stultz Subject: [PATCH 4/6] hrtimers: Move lock held region in hrtimer_interrupt() Date: Tue, 10 Jul 2012 18:43:23 -0400 Message-Id: <1341960205-56738-6-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-7408-0000-0000-000006A79CF7 X-Gm-Message-State: ALoCoQkJQcRl6cJjkOHCIYoMD5c7xqFY0agR/kyNGYs6+CGZ2EXBRGaEXkON0vXZsl+m6ZQ/OcMT From: Thomas Gleixner We need to update the base offsets from this code and we need to do that under base->lock. Move the lock held region around the ktime_get() calls. The ktime_get() calls are going to be replaced with a function which gets the time and the offsets atomically. CC: Ingo Molnar CC: Peter Zijlstra CC: Prarit Bhargava CC: Thomas Gleixner CC: stable@vger.kernel.org Signed-off-by: Thomas Gleixner Signed-off-by: John Stultz --- kernel/hrtimer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 7c20cb8..14a260a 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -1263,11 +1263,10 @@ void hrtimer_interrupt(struct clock_event_device *dev) cpu_base->nr_events++; dev->next_event.tv64 = KTIME_MAX; + raw_spin_lock(&cpu_base->lock); entry_time = now = ktime_get(); retry: expires_next.tv64 = KTIME_MAX; - - raw_spin_lock(&cpu_base->lock); /* * We set expires_next to KTIME_MAX here with cpu_base->lock * held to prevent that a timer is enqueued in our queue via @@ -1344,6 +1343,7 @@ retry: * interrupt routine. We give it 3 attempts to avoid * overreacting on some spurious event. */ + raw_spin_lock(&cpu_base->lock); now = ktime_get(); cpu_base->nr_retries++; if (++retries < 3) @@ -1356,6 +1356,7 @@ retry: */ cpu_base->nr_hangs++; cpu_base->hang_detected = 1; + raw_spin_unlock(&cpu_base->lock); delta = ktime_sub(now, entry_time); if (delta.tv64 > cpu_base->max_hang_time.tv64) cpu_base->max_hang_time = delta;