From patchwork Fri Apr 4 06:36:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 27751 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4EA242036E for ; Fri, 4 Apr 2014 06:42:42 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf9776573oac.3 for ; Thu, 03 Apr 2014 23:42:41 -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=AmWuhNNxUYFNm83CyKAhClf54cKXutCnTHI5RpXb1No=; b=ZmQTZMTuUOZUaQq89w5cZ2UabIuRWYnCRmG7BMy0SSIk7ULJKp6kb/iCh2xEe+Qhho oX9VVyCrh9V5GzSYSQdOA7hwNBBbFuiihkZ3m+yCPe4CRiBQuMcxEVTdI7g13P2YtgN+ WwB79vA9QVsP3SNcfYXo5tVIo8y1s3KZ6mUpvnnDc/kKDSfbIGxshex5mz5GyES1TfNn RGBmEQGpA3MJ7wcCayOjtW3aTmTbEtBseromvzygsGefFLfWignC4S8DCmh73M5oQq2y ypTpDaPQqUq6sJfCAN+Eq7tqOvxyZew6j+I7OPfTjV/RS1WqLCek41AWG2uXpOtHyUTz PLCQ== X-Gm-Message-State: ALoCoQlNorysLoxE7/V5a26txCPhNykIoPOoq5MHUMFjsYO0HzmJUYdfIz1Ump6VoscRYT8oDRxi X-Received: by 10.43.79.196 with SMTP id zr4mr6501364icb.3.1396593761873; Thu, 03 Apr 2014 23:42:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.112 with SMTP id p103ls922706qga.41.gmail; Thu, 03 Apr 2014 23:42:41 -0700 (PDT) X-Received: by 10.52.142.10 with SMTP id rs10mr9749662vdb.3.1396593761791; Thu, 03 Apr 2014 23:42:41 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id nc1si626434vec.132.2014.04.03.23.42.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 23:42:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.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.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so1098082veb.23 for ; Thu, 03 Apr 2014 23:42:41 -0700 (PDT) X-Received: by 10.58.107.65 with SMTP id ha1mr3645713veb.1.1396593761717; Thu, 03 Apr 2014 23:42:41 -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 v8csp89295vcv; Thu, 3 Apr 2014 23:42:41 -0700 (PDT) X-Received: by 10.69.31.43 with SMTP id kj11mr12595819pbd.67.1396593757177; Thu, 03 Apr 2014 23:42:37 -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.36; Thu, 03 Apr 2014 23:42:36 -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 S1752805AbaDDGmS (ORCPT + 27 others); Fri, 4 Apr 2014 02:42:18 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:64806 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752663AbaDDGmJ (ORCPT ); Fri, 4 Apr 2014 02:42:09 -0400 Received: by mail-we0-f173.google.com with SMTP id w61so2879726wes.4 for ; Thu, 03 Apr 2014 23:42:08 -0700 (PDT) X-Received: by 10.180.8.170 with SMTP id s10mr1706941wia.35.1396593728404; Thu, 03 Apr 2014 23:42:08 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id di9sm2723598wid.6.2014.04.03.23.42.05 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Apr 2014 23:42:07 -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 24/36] hrtimer: Use for_each_active_base() to iterate over active clock bases Date: Fri, 4 Apr 2014 12:06:07 +0530 Message-Id: <12b00acd325068b14ef079a6740dca9eb1ce3734.1396592516.git.viresh.kumar@linaro.org> 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.128.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: , There are various places where we are currently running a loop of HRTIMER_MAX_CLOCK_BASES iterations. We just run 'continue;' if there are no timers added to a clock base. Instead we can use the new for_each_active_base() routine to iterate over only the bases which are currently active. Signed-off-by: Viresh Kumar --- kernel/hrtimer.c | 58 ++++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index ceadfa5..b3ab19a 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -557,21 +557,17 @@ static inline int hrtimer_hres_active(void) static void hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal) { - int i; - struct hrtimer_clock_base *base = cpu_base->clock_base; + struct hrtimer_clock_base *base; + struct hrtimer *timer; ktime_t expires, expires_next; + unsigned int active_bases; + int i; expires_next.tv64 = KTIME_MAX; - for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) { - struct hrtimer *timer; - struct timerqueue_node *next; - - next = timerqueue_getnext(&base->active); - if (!next) - continue; - timer = container_of(next, struct hrtimer, node); - + for_each_active_base(i, base, cpu_base, active_bases) { + timer = container_of(timerqueue_getnext(&base->active), + struct hrtimer, node); expires = hrtimer_get_monoexpires(timer, base); /* * clock_was_set() has changed base->offset so the @@ -1131,23 +1127,19 @@ EXPORT_SYMBOL_GPL(hrtimer_get_remaining); ktime_t hrtimer_get_next_event(void) { struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); - struct hrtimer_clock_base *base = cpu_base->clock_base; + struct hrtimer_clock_base *base; ktime_t delta, mindelta = { .tv64 = KTIME_MAX }; + struct hrtimer *timer; + unsigned int active_bases; unsigned long flags; int i; raw_spin_lock_irqsave(&cpu_base->lock, flags); if (!hrtimer_hres_active()) { - for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) { - struct hrtimer *timer; - struct timerqueue_node *next; - - next = timerqueue_getnext(&base->active); - if (!next) - continue; - - timer = container_of(next, struct hrtimer, node); + for_each_active_base(i, base, cpu_base, active_bases) { + timer = container_of(timerqueue_getnext(&base->active), + struct hrtimer, node); delta.tv64 = hrtimer_get_expires_tv64(timer); delta = ktime_sub(delta, base->get_time()); if (delta.tv64 < mindelta.tv64) @@ -1270,7 +1262,9 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now) void hrtimer_interrupt(struct clock_event_device *dev) { struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); + struct hrtimer_clock_base *base; ktime_t expires_next, now, entry_time, delta; + unsigned int active_bases; int i, retries = 0; BUG_ON(!cpu_base->hres_active); @@ -1290,15 +1284,10 @@ retry: */ cpu_base->expires_next.tv64 = KTIME_MAX; - for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { - struct hrtimer_clock_base *base; + for_each_active_base(i, base, cpu_base, active_bases) { struct timerqueue_node *node; ktime_t basenow; - if (!(cpu_base->active_bases & (1 << i))) - continue; - - base = cpu_base->clock_base + i; basenow = ktime_add(now, base->offset); while ((node = timerqueue_getnext(&base->active))) { @@ -1468,16 +1457,13 @@ void hrtimer_run_queues(void) struct timerqueue_node *node; struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); struct hrtimer_clock_base *base; + unsigned int active_bases; int index, gettime = 1; if (hrtimer_hres_active()) return; - for (index = 0; index < HRTIMER_MAX_CLOCK_BASES; index++) { - base = &cpu_base->clock_base[index]; - if (!timerqueue_getnext(&base->active)) - continue; - + for_each_active_base(index, base, cpu_base, active_bases) { if (gettime) { hrtimer_get_softirq_time(cpu_base); gettime = 0; @@ -1697,6 +1683,8 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base, static void migrate_hrtimers(int scpu) { struct hrtimer_cpu_base *old_base, *new_base; + struct hrtimer_clock_base *clock_base; + unsigned int active_bases; int i; BUG_ON(cpu_online(scpu)); @@ -1712,9 +1700,9 @@ static void migrate_hrtimers(int scpu) raw_spin_lock(&new_base->lock); raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); - for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) - migrate_hrtimer_list(&old_base->clock_base[i], - &new_base->clock_base[i]); + for_each_active_base(i, clock_base, old_base, active_bases) + migrate_hrtimer_list(clock_base, + &new_base->clock_base[clock_base->index]); raw_spin_unlock(&old_base->lock); raw_spin_unlock(&new_base->lock);