From patchwork Mon Jun 9 08:49:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 31537 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 572F520675 for ; Mon, 9 Jun 2014 09:15:31 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf34908773iec.4 for ; Mon, 09 Jun 2014 02:15:30 -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:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ktd9TgnJVeQJ+gjA86XdXFpCYMW4o4mBGFuymkj3Hds=; b=GLrMrW9NvOYhHFQbUw4Kh+ugytK6+mf66AzvI84qAI0oI1ftDwaz5KL6OwZqYsHjTm 7A1V6/lvb3+5ctV+TMfanigFkBG1tGRoreWOds3pZJ1X1Ubu75uF42SYy1Wg1Dc6f2dn QQUNn4IzIRj/4Ykajv5hCjuf9AonVAvbKsBGmVlUVi/vxd0edbGsD5xadm6ciuS1HUPt 6mbiT+EbLanVeurckGSKaHDsaw2sDJ2BQXOT4wOtb1VGS/HRgd3k/znt7sXs/sAdot53 /dpZWHVd1PJRgpD5W0Rn+a6JmwvkNuwFE/H/JF1Zs5ni8pkxY7bT7akSLqIVvS6Yzmw7 +ZTA== X-Gm-Message-State: ALoCoQm31lvDzHU+Fphkg+XAtCWp04f8KvKF1ybu6hpWuKfQ9gu3HR/S9lFztaIKou1Y30Xo/7p/ X-Received: by 10.50.6.45 with SMTP id x13mr1247276igx.4.1402305330638; Mon, 09 Jun 2014 02:15:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.240 with SMTP id j103ls1553515qgd.47.gmail; Mon, 09 Jun 2014 02:15:30 -0700 (PDT) X-Received: by 10.220.68.83 with SMTP id u19mr760723vci.52.1402305330515; Mon, 09 Jun 2014 02:15:30 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id qi12si11610118vdb.82.2014.06.09.02.15.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Jun 2014 02:15:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so2251005vcb.37 for ; Mon, 09 Jun 2014 02:15:30 -0700 (PDT) X-Received: by 10.52.14.130 with SMTP id p2mr21093368vdc.39.1402305330425; Mon, 09 Jun 2014 02:15:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp127478vcb; Mon, 9 Jun 2014 02:15:29 -0700 (PDT) X-Received: by 10.66.254.231 with SMTP id al7mr3250020pad.120.1402305329177; Mon, 09 Jun 2014 02:15:29 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sa9si1665520pac.31.2014.06.09.02.15.28; Mon, 09 Jun 2014 02:15:28 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933972AbaFIJPX (ORCPT + 27 others); Mon, 9 Jun 2014 05:15:23 -0400 Received: from ip4-83-240-18-248.cust.nbox.cz ([83.240.18.248]:58405 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754847AbaFIIvY (ORCPT ); Mon, 9 Jun 2014 04:51:24 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.80.1) (envelope-from ) id 1WtvIY-0007eK-8f; Mon, 09 Jun 2014 10:51:22 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Viresh Kumar , linaro-kernel@lists.linaro.org, linaro-networking@linaro.org, fweisbec@gmail.com, arvind.chauhan@arm.com, Thomas Gleixner , Jiri Slaby Subject: [PATCH 3.12 039/146] hrtimer: Set expiry time before switch_hrtimer_base() Date: Mon, 9 Jun 2014 10:49:34 +0200 Message-Id: <0bfa5653fccb44fa3edada4eca51d8aecbd3ecde.1402303820.git.jslaby@suse.cz> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.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.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Viresh Kumar 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit 84ea7fe37908254c3bd90910921f6e1045c1747a upstream. switch_hrtimer_base() calls hrtimer_check_target() which ensures that we do not migrate a timer to a remote cpu if the timer expires before the current programmed expiry time on that remote cpu. But __hrtimer_start_range_ns() calls switch_hrtimer_base() before the new expiry time is set. So the sanity check in hrtimer_check_target() is operating on stale or even uninitialized data. Update expiry time before calling switch_hrtimer_base(). [ tglx: Rewrote changelog once again ] Signed-off-by: Viresh Kumar Cc: linaro-kernel@lists.linaro.org Cc: linaro-networking@linaro.org Cc: fweisbec@gmail.com Cc: arvind.chauhan@arm.com Link: http://lkml.kernel.org/r/81999e148745fc51bbcd0615823fbab9b2e87e23.1399882253.git.viresh.kumar@linaro.org Signed-off-by: Thomas Gleixner Signed-off-by: Jiri Slaby --- kernel/hrtimer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 6de65d8a70e2..aa149222cd8e 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -1002,11 +1002,8 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, /* Remove an active timer from the queue: */ ret = remove_hrtimer(timer, base); - /* Switch the timer base, if necessary: */ - new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); - if (mode & HRTIMER_MODE_REL) { - tim = ktime_add_safe(tim, new_base->get_time()); + tim = ktime_add_safe(tim, base->get_time()); /* * CONFIG_TIME_LOW_RES is a temporary way for architectures * to signal that they simply return xtime in @@ -1021,6 +1018,9 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, hrtimer_set_expires_range_ns(timer, tim, delta_ns); + /* Switch the timer base, if necessary: */ + new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); + timer_stats_hrtimer_set_start_info(timer); leftmost = enqueue_hrtimer(timer, new_base);