From patchwork Wed Apr 16 08:31:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 28452 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CFEEE2036A for ; Wed, 16 Apr 2014 08:31:48 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id jt11sf39877798pbb.11 for ; Wed, 16 Apr 2014 01:31:48 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=0ljG97ZGUjQgiZIqYNKL8GGjlz6ku/zRjBcMrhhmKzQ=; b=jP/Oc2rUkrAcpdWhQ2fAUZVnT2ma3AaREePTcQ1u6ighvfW5uu95AxpuzeUggpaEQ5 Az3rHTeewxlN4IJanSjBac31em+9SjpAOu/TapE8f6qTXBTTCfd97mU2gXFNzFRDA667 FyvyWGs9S51t2XxBU5Lwsw3z89Z4sa8cEXIAYSKAKKKqSngE7iYGQ2CL6qPzR8HiBUpW vs3mdkhne0XtRIsXLZ7mf3eqU9vQeol7kInK1hFHe55xlV254pdOdhnq4ZYF82KUn0FW Vid81UVg0mJWCMe76KE+NERONWvs/L4gEoLYb6jxxjDGRXo1DSaVGstZN11jaBdeMPRt h4LQ== X-Gm-Message-State: ALoCoQl4bTPZm87MVCowswh64u9v8HzfUd71h5C41OvgfHsygFuEd5uhSzhBd3zEPFt96lccDSPX X-Received: by 10.66.121.195 with SMTP id lm3mr1071337pab.24.1397637108018; Wed, 16 Apr 2014 01:31:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.208 with SMTP id 74ls164269qgn.18.gmail; Wed, 16 Apr 2014 01:31:47 -0700 (PDT) X-Received: by 10.220.69.72 with SMTP id y8mr955918vci.21.1397637107905; Wed, 16 Apr 2014 01:31:47 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id at8si3772374vec.199.2014.04.16.01.31.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 01:31:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so10171410veb.26 for ; Wed, 16 Apr 2014 01:31:47 -0700 (PDT) X-Received: by 10.58.207.74 with SMTP id lu10mr4932285vec.15.1397637107821; Wed, 16 Apr 2014 01:31:47 -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.220.221.72 with SMTP id ib8csp294632vcb; Wed, 16 Apr 2014 01:31:47 -0700 (PDT) X-Received: by 10.66.163.164 with SMTP id yj4mr7084370pab.91.1397637106954; Wed, 16 Apr 2014 01:31:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qf4si12286329pbb.309.2014.04.16.01.31.46; Wed, 16 Apr 2014 01:31:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751852AbaDPIbg (ORCPT + 26 others); Wed, 16 Apr 2014 04:31:36 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:41933 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751006AbaDPIbd (ORCPT ); Wed, 16 Apr 2014 04:31:33 -0400 Received: by mail-wi0-f172.google.com with SMTP id hi2so976136wib.17 for ; Wed, 16 Apr 2014 01:31:32 -0700 (PDT) X-Received: by 10.180.188.130 with SMTP id ga2mr18295848wic.18.1397637092159; Wed, 16 Apr 2014 01:31:32 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id fx6sm8339336wib.4.2014.04.16.01.31.28 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 16 Apr 2014 01:31:31 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de Cc: linaro-kernel@lists.linaro.org, linaro-networking@linaro.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V1 Resend] hrtimer: call switch_hrtimer_base() after setting new expiry time Date: Wed, 16 Apr 2014 14:01:19 +0530 Message-Id: <8ed33f7e6e58b1a51fa156cf69831a177d724456.1397636308.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e 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: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , In switch_hrtimer_base() we are calling hrtimer_check_target() which guarantees this: /* * With HIGHRES=y we do not migrate the timer when it is expiring * before the next event on the target cpu because we cannot reprogram * the target cpu hardware and we would cause it to fire late. * * Called with cpu_base->lock of target cpu held. */ But switch_hrtimer_base() is only called from one place, i.e. __hrtimer_start_range_ns() and at that point (where we call switch_hrtimer_base()) expiration time is not yet known as we call this routine later: hrtimer_set_expires_range_ns(). To fix this, we need to find the updated expiry time before calling switch_hrtimer_base(). Signed-off-by: Viresh Kumar --- Hi Thomas, I have sent this previously as part of: https://lkml.org/lkml/2014/4/4/23 But as you asked to send bugfixes without any dependencies for ticks patches, I thought of sending bugfixes separately for timers too. This was the only bugfix from that series and other patches don't conflict with it, so I am not resending other patches from above series again. Not adding any stable tags as this is broken from a long long time and don't know if you want to fix it for those kernels. kernel/hrtimer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index d55092c..c86b95a 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -968,11 +968,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 @@ -987,6 +984,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);