From patchwork Wed Jul 9 06:55:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 33261 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D184E203F4 for ; Wed, 9 Jul 2014 06:56:20 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id hn18sf5141513igb.7 for ; Tue, 08 Jul 2014 23:56:20 -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=GUpoNYyqBJJMszg/P9PKokEtc7+F6WMLydQC8q3S0Fk=; b=Sl8omSAyN3vVQzV0nDVoH8cpOQzMoeYOObPmPMx2GlcG7xHxAZDZeH4pCmqRUFoASO haEttCZ+vM8al4O/RNSojGTS4nBYYxH4spp8ojAEiIWGNsPX6uHATcLr0yuAXWVN1MdD v0oqELmRe43RPmG+2u5VOcTXwnUWlF8nL77WAatgsbzt/ZYseTO30wMA4rUUvh6E+Dwn YRNXZvs8IyrHhOfbCqwVuadSlDuKsNveMZOtvj2RNXYofJkw75kpZ49xggHcEzEQyJ2G dji49ZXVpsx5EGkUIHqTMsdZVHb0e65N9f35noQ5JurkkwMDx/Spdjhdq1NgwF/D0pBQ oWQA== X-Gm-Message-State: ALoCoQnzR4UBzNO76UB55rLxyUlYd2dQREf//hUYEJncqVBI1w/vLr4ys2QAJeIZvanNQwmTSY7N X-Received: by 10.182.241.33 with SMTP id wf1mr18515715obc.37.1404888980109; Tue, 08 Jul 2014 23:56:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.228 with SMTP id j91ls2519014qgf.31.gmail; Tue, 08 Jul 2014 23:56:20 -0700 (PDT) X-Received: by 10.52.118.99 with SMTP id kl3mr31843818vdb.18.1404888980010; Tue, 08 Jul 2014 23:56:20 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id f15si11384048vdt.65.2014.07.08.23.56.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Jul 2014 23:56:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id ij19so6402956vcb.22 for ; Tue, 08 Jul 2014 23:56:19 -0700 (PDT) X-Received: by 10.58.152.234 with SMTP id vb10mr38062077veb.21.1404888979913; Tue, 08 Jul 2014 23:56:19 -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.37.5 with SMTP id tc5csp20643vcb; Tue, 8 Jul 2014 23:56:19 -0700 (PDT) X-Received: by 10.68.163.197 with SMTP id yk5mr39793000pbb.57.1404888979101; Tue, 08 Jul 2014 23:56:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb10si3405406pdb.422.2014.07.08.23.56.18; Tue, 08 Jul 2014 23:56:18 -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 S1754644AbaGIG4M (ORCPT + 28 others); Wed, 9 Jul 2014 02:56:12 -0400 Received: from mail-qa0-f51.google.com ([209.85.216.51]:57463 "EHLO mail-qa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbaGIG4J (ORCPT ); Wed, 9 Jul 2014 02:56:09 -0400 Received: by mail-qa0-f51.google.com with SMTP id j7so5606714qaq.38 for ; Tue, 08 Jul 2014 23:56:08 -0700 (PDT) X-Received: by 10.140.33.200 with SMTP id j66mr62668785qgj.81.1404888968890; Tue, 08 Jul 2014 23:56:08 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id g2sm84934910qaz.21.2014.07.08.23.56.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Jul 2014 23:56:08 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, fweisbec@gmail.com, arvind.chauhan@arm.com, preeti@linux.vnet.ibm.com, khilman@linaro.org, Viresh Kumar Subject: [RFC 3/7] tick: don't check for active hrtimer after adding it Date: Wed, 9 Jul 2014 12:25:35 +0530 Message-Id: X-Mailer: git-send-email 2.0.0.rc2 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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 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: , hrtimer_start*() family never fails to enqueue a hrtimer to a clock-base. The only special case is when the hrtimer was in past. If it is getting enqueued to local CPUs's clock-base, we raise a softirq and exit, else we handle that on next interrupt on remote CPU. At several places in the kernel, we try to make sure if hrtimer was added properly or not by calling hrtimer_active(), like: hrtimer_start(timer, expires, mode); if (hrtimer_active(timer)) { /* Added successfully */ } else { /* Was added in the past */ } As hrtimer_start*() never fails, hrtimer_active() is guaranteed to return '1'. So, there is no point calling hrtimer_active(). This is done in while loop at several places, which isn't required anymore. This patch updates tick core to get this fixed. This also removes the confusing comment present over usage of hrtimer_active(). - /* Check, if the timer was already in the past */ This comment says that hrtimer_active() would check if timer was already in the past, but hrtimer_active() can't check it. It just checks if timer is in INACTIVE state or not. Signed-off-by: Viresh Kumar --- kernel/time/tick-sched.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 6558b7a..66ca5ab 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -658,9 +658,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, if (ts->nohz_mode == NOHZ_MODE_HIGHRES) { hrtimer_start(&ts->sched_timer, expires, HRTIMER_MODE_ABS_PINNED); - /* Check, if the timer was already in the past */ - if (hrtimer_active(&ts->sched_timer)) - goto out; + goto out; } else if (!tick_program_event(expires, 0)) goto out; /* @@ -844,24 +842,25 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now) hrtimer_cancel(&ts->sched_timer); hrtimer_set_expires(&ts->sched_timer, ts->last_tick); - while (1) { - /* Forward the time to expire in the future */ - hrtimer_forward(&ts->sched_timer, now, tick_period); + /* Forward the time to expire in the future */ + hrtimer_forward(&ts->sched_timer, now, tick_period); - if (ts->nohz_mode == NOHZ_MODE_HIGHRES) { - hrtimer_start_expires(&ts->sched_timer, - HRTIMER_MODE_ABS_PINNED); - /* Check, if the timer was already in the past */ - if (hrtimer_active(&ts->sched_timer)) - break; - } else { - if (!tick_program_event( - hrtimer_get_expires(&ts->sched_timer), 0)) - break; - } + if (ts->nohz_mode == NOHZ_MODE_HIGHRES) { + hrtimer_start_expires(&ts->sched_timer, + HRTIMER_MODE_ABS_PINNED); + return; + } + + while (1) { + if (!tick_program_event(hrtimer_get_expires(&ts->sched_timer), + 0)) + break; /* Reread time and update jiffies */ now = ktime_get(); tick_do_update_jiffies64(now); + + /* Forward the time to expire in the future */ + hrtimer_forward(&ts->sched_timer, now, tick_period); } } @@ -1104,7 +1103,6 @@ early_param("skew_tick", skew_tick); void tick_setup_sched_timer(void) { struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched); - ktime_t now = ktime_get(); /* * Emulate tick processing via per-CPU hrtimers: @@ -1123,15 +1121,8 @@ void tick_setup_sched_timer(void) hrtimer_add_expires_ns(&ts->sched_timer, offset); } - for (;;) { - hrtimer_forward(&ts->sched_timer, now, tick_period); - hrtimer_start_expires(&ts->sched_timer, - HRTIMER_MODE_ABS_PINNED); - /* Check, if the timer was already in the past */ - if (hrtimer_active(&ts->sched_timer)) - break; - now = ktime_get(); - } + hrtimer_forward(&ts->sched_timer, ktime_get(), tick_period); + hrtimer_start_expires(&ts->sched_timer, HRTIMER_MODE_ABS_PINNED); #ifdef CONFIG_NO_HZ_COMMON if (tick_nohz_enabled) {