From patchwork Fri Apr 4 06:36:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 27753 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 476052036E for ; Fri, 4 Apr 2014 06:42:44 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf7769532vcb.2 for ; Thu, 03 Apr 2014 23:42:43 -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=LkirXqOMHIeVL/1U+R3wSQN/4oNFulMkZISZiEi+4QA=; b=Bixn0WH6VL4eKFwGePtrVsR92Rydz1T0QwVRb5U14M9A9m48hP9EybZEjYaPAKqo4J Z7cM358UrI8R96YOB1ydWTCxRDBfDzgBMDRYWtbQklKN08fKIxphADl0lTfl3Tw9Y6Sh DHP0cM1Ie2y0Y+M2+MaVgRvX0yC85cjtLRcPEtKLnBE+nBdxGI0LsBs2BGH40Pk8BnYj hKqXBW9Jj7D/rpHno/i6ZmerrklkwiAvT370/5rgbb7XGft6bgGL4u3+bQd06v81czHg MCi45htjFls+Q8ai4upg5mfMgoqskxIDyFs/E+99SJ0VMKFcuXLmU5MTEYNgKLOD953x +9bg== X-Gm-Message-State: ALoCoQmPrm/Di9ZiHUODeMnj0OCUQr8k85ohiuoFq6kr/CneWIZywfXENuoZ7D38A0mCwndxAuBH X-Received: by 10.236.121.4 with SMTP id q4mr6168224yhh.34.1396593763943; Thu, 03 Apr 2014 23:42:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.85 with SMTP id a79ls905339qge.72.gmail; Thu, 03 Apr 2014 23:42:43 -0700 (PDT) X-Received: by 10.221.55.133 with SMTP id vy5mr6856528vcb.17.1396593763854; Thu, 03 Apr 2014 23:42:43 -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 tv3si1644198vdc.54.2014.04.03.23.42.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 23:42:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id im17so2750269vcb.23 for ; Thu, 03 Apr 2014 23:42:43 -0700 (PDT) X-Received: by 10.58.202.133 with SMTP id ki5mr3499688vec.19.1396593763758; Thu, 03 Apr 2014 23:42:43 -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.12.8 with SMTP id v8csp89298vcv; Thu, 3 Apr 2014 23:42:43 -0700 (PDT) X-Received: by 10.68.237.133 with SMTP id vc5mr12977452pbc.92.1396593759725; Thu, 03 Apr 2014 23:42:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xt7si4198997pab.20.2014.04.03.23.42.38; Thu, 03 Apr 2014 23:42:38 -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 S1752859AbaDDGmd (ORCPT + 27 others); Fri, 4 Apr 2014 02:42:33 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:36993 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752732AbaDDGm0 (ORCPT ); Fri, 4 Apr 2014 02:42:26 -0400 Received: by mail-we0-f174.google.com with SMTP id t60so2959732wes.33 for ; Thu, 03 Apr 2014 23:42:25 -0700 (PDT) X-Received: by 10.180.7.133 with SMTP id j5mr1676189wia.55.1396593745695; Thu, 03 Apr 2014 23:42:25 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id ph8sm11011920wjb.32.2014.04.03.23.42.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Apr 2014 23:42:24 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de Cc: linaro-kernel@lists.linaro.org, fweisbec@gmail.com, linaro-networking@linaro.org, Arvind.Chauhan@arm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V2 27/36] hrtimer: call switch_hrtimer_base() after setting new expiry time Date: Fri, 4 Apr 2014 12:06:10 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e 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: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 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 the 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() from hrtimer_set_expires_range_ns(). Signed-off-by: Viresh Kumar --- kernel/hrtimer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index c712960..81e0251 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -964,11 +964,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 @@ -977,12 +974,15 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, * timeouts. This will go away with the GTOD framework. */ #ifdef CONFIG_TIME_LOW_RES - tim = ktime_add_safe(tim, new_base->resolution); + tim = ktime_add_safe(tim, base->resolution); #endif } 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); @@ -1000,7 +1000,7 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, * We need to drop cpu_base->lock to avoid a * lock ordering issue vs. rq->lock. */ - raw_spin_unlock(&new_base->cpu_base->lock); + raw_spin_unlock(&timer->base->cpu_base->lock); raise_softirq_irqoff(HRTIMER_SOFTIRQ); local_irq_restore(flags); return ret;