From patchwork Fri Sep 12 21:22:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 37368 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EBBA020C7F for ; Fri, 12 Sep 2014 21:22:45 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e53sf883158eek.6 for ; Fri, 12 Sep 2014 14:22:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=7E4qP/1eYPwevfufN0gewzxBFtwtqkx5HQQQ/2dvrko=; b=IwuL1hkML5Etub49OpUIctppnITed2USelqFSEhOipAoWY2jRhm6lDAElpdl8vGW7V SSC5+WTBIe962Rcg7CKxqVqbCs3A+uYH2IZkEtQgQphYXpkGWLKh3jUiTOY1LoBPjgJT H4Q2BnSkgiJbCdeWOr+1ZYDEtiMECeqH+e9bI05z8CoNg98C7Ww29jgBozpGmBWxX11f eI0dbxk800yN4mHS8FCKk4BeHs8YhAgY3N5OHfYj8aMfrLVUIs8DrVWL4MDt+ngnofbw e7qdAGaoLbWn3nst6XK/LMGO9W6uv5HIot3pV6IvhYt4RbLvljNKvnMuaiRam94iBLzj /TYw== X-Gm-Message-State: ALoCoQl34pXgf0XXoBZb5nJUD/CCOtP0gmnYYbQi2AWwgGpSj3xayrr92cAcXGHdb0QagBET9and X-Received: by 10.112.149.67 with SMTP id ty3mr3063031lbb.1.1410556965063; Fri, 12 Sep 2014 14:22:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.107 with SMTP id ud11ls192791lac.38.gmail; Fri, 12 Sep 2014 14:22:45 -0700 (PDT) X-Received: by 10.152.21.6 with SMTP id r6mr11888866lae.6.1410556964996; Fri, 12 Sep 2014 14:22:44 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id gi2si8422921lbc.52.2014.09.12.14.22.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 14:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id b8so1698096lan.39 for ; Fri, 12 Sep 2014 14:22:44 -0700 (PDT) X-Received: by 10.112.76.6 with SMTP id g6mr11249732lbw.22.1410556964924; Fri, 12 Sep 2014 14:22:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.141.42 with SMTP id rl10csp809203lbb; Fri, 12 Sep 2014 14:22:44 -0700 (PDT) X-Received: by 10.70.38.239 with SMTP id j15mr17485428pdk.109.1410556962542; Fri, 12 Sep 2014 14:22:42 -0700 (PDT) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by mx.google.com with ESMTPS id yg2si10295359pab.48.2014.09.12.14.22.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 14:22:42 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.53 as permitted sender) client-ip=209.85.220.53; Received: by mail-pa0-f53.google.com with SMTP id rd3so2071915pab.26 for ; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) X-Received: by 10.66.139.232 with SMTP id rb8mr15876561pab.130.1410556961872; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id p6sm4225878pds.13.2014.09.12.14.22.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Sep 2014 14:22:40 -0700 (PDT) From: John Stultz To: lkml Cc: Richard Larocque , stable@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Richard Cochran , Prarit Bhargava , Sharvil Nanavati , John Stultz Subject: [PATCH 4/4] alarmtimer: Lock k_itimer during timer callback Date: Fri, 12 Sep 2014 14:22:24 -0700 Message-Id: <1410556944-14944-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410556944-14944-1-git-send-email-john.stultz@linaro.org> References: <1410556944-14944-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Richard Larocque Locks the k_itimer's it_lock member when handling the alarm timer's expiry callback. The regular posix timers defined in posix-timers.c have this lock held during timout processing because their callbacks are routed through posix_timer_fn(). The alarm timers follow a different path, so they ought to grab the lock somewhere else. Cc: stable@vger.kernel.org Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Sharvil Nanavati Signed-off-by: Richard Larocque Signed-off-by: John Stultz --- kernel/time/alarmtimer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 41a9253..a7077d3 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -464,8 +464,12 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid) static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, ktime_t now) { + unsigned long flags; struct k_itimer *ptr = container_of(alarm, struct k_itimer, it.alarm.alarmtimer); + enum alarmtimer_restart result = ALARMTIMER_NORESTART; + + spin_lock_irqsave(&ptr->it_lock, flags); if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) { if (posix_timer_event(ptr, 0) != 0) ptr->it_overrun++; @@ -475,9 +479,11 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, if (ptr->it.alarm.interval.tv64) { ptr->it_overrun += alarm_forward(alarm, now, ptr->it.alarm.interval); - return ALARMTIMER_RESTART; + result = ALARMTIMER_RESTART; } - return ALARMTIMER_NORESTART; + spin_unlock_irqrestore(&ptr->it_lock, flags); + + return result; } /**