From patchwork Thu Mar 27 05:54:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 27176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2AD9E20062 for ; Thu, 27 Mar 2014 05:55:07 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf11369354oag.4 for ; Wed, 26 Mar 2014 22:55:06 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Ue/Qp+DpxHE0FJM4gkGJ/9w9PLLCSzuPTrkTU31gEO8=; b=UflU3ms3amLj69Qh4S9OaPdNZwiWKFg2C7QCV7McPufr5ewrvu4YCoz6gUoCGccDyI VzMRmsT05dAzujx1Mu0y4WjBiAwy1G0zfVNQx69pFkSK1H7mOsvcshKAYgBg7xPSIRWH B3ZExRPte1VMeR3EAg0RoEzyGpyPw7XqvuhBVXvZY0f15c4LRYT0bXQ3OIz9B8Q109NJ IMK3VFyHThAKx0U8pTKJPTn0xoCU22XtFMiC75xwf+orVJqholDEZpz8eABkJ28KhiFG V+ZdOGyI0s+l1lfmN+68QFa94vTpWrj5+oKk72InwN0fgp3ESAytUxvxwXyYnMOehVCi 0rgQ== X-Gm-Message-State: ALoCoQmhT2Rh5PwBTdU0lC5g0pNHBH37ESuGh+W6/to6RU7pvnI1bTMukEG3Nd7W8cNK13e3XTZR X-Received: by 10.43.163.199 with SMTP id mp7mr28490477icc.6.1395899706708; Wed, 26 Mar 2014 22:55:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.100.137 with SMTP id s9ls1060679qge.57.gmail; Wed, 26 Mar 2014 22:55:06 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr4959502vcx.7.1395899706613; Wed, 26 Mar 2014 22:55:06 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id uq15si272674veb.194.2014.03.26.22.55.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 22:55:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.170 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.170; Received: by mail-ve0-f170.google.com with SMTP id pa12so3623424veb.1 for ; Wed, 26 Mar 2014 22:55:06 -0700 (PDT) X-Received: by 10.52.175.166 with SMTP id cb6mr53407916vdc.1.1395899706513; Wed, 26 Mar 2014 22:55:06 -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.78.9 with SMTP id i9csp101955vck; Wed, 26 Mar 2014 22:55:06 -0700 (PDT) X-Received: by 10.66.141.197 with SMTP id rq5mr9321581pab.64.1395899705709; Wed, 26 Mar 2014 22:55:05 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vu10si672998pbc.138.2014.03.26.22.55.05; Wed, 26 Mar 2014 22:55:05 -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 S1752087AbaC0Fy4 (ORCPT + 26 others); Thu, 27 Mar 2014 01:54:56 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:35614 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777AbaC0Fyz (ORCPT ); Thu, 27 Mar 2014 01:54:55 -0400 Received: by mail-wi0-f171.google.com with SMTP id hr14so4109683wib.4 for ; Wed, 26 Mar 2014 22:54:54 -0700 (PDT) X-Received: by 10.180.184.167 with SMTP id ev7mr10491362wic.55.1395899694168; Wed, 26 Mar 2014 22:54:54 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id qg3sm9052162wic.10.2014.03.26.22.54.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 26 Mar 2014 22:54:53 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, fweisbec@gmail.com, linaro-networking@linaro.org, Viresh Kumar Subject: [PATCH V3 Resend] hrtimer: use ffs() to iterate over valid bits from active_bases Date: Thu, 27 Mar 2014 11:24:47 +0530 Message-Id: <16126ce574322be7733522e6aacab0f45ebd9db5.1395899588.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: <8aa380361c07844f7b274e472f542ae2171bb39a.1395899293.git.viresh.kumar@linaro.org> References: <8aa380361c07844f7b274e472f542ae2171bb39a.1395899293.git.viresh.kumar@linaro.org> 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.170 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: , Currently we are iterating over all possible (currently four) bits of active_bases to see if corresponding clock bases are active. This is good enough for cases where 3 or 4 bases are used but if only 1 or 2 are used then it makes more sense to use ffs() to find the right bit directly. Suggested-by: Thomas Gleixner Signed-off-by: Viresh Kumar --- V3->Resend: s/__ffs/ffs in commit log :( V2->V3: Use ffs() instead of __ffs() and decrement 'i' later. V1->V2: Instead of removing active_bases use __ffs() on it to make loop more efficient. kernel/hrtimer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index acfef5f..2aad8a7 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -1265,6 +1265,7 @@ void hrtimer_interrupt(struct clock_event_device *dev) { struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); ktime_t expires_next, now, entry_time, delta; + unsigned long active_bases = cpu_base->active_bases; int i, retries = 0; BUG_ON(!cpu_base->hres_active); @@ -1284,15 +1285,11 @@ retry: */ cpu_base->expires_next.tv64 = KTIME_MAX; - for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { - struct hrtimer_clock_base *base; + while ((i = ffs(active_bases))) { + struct hrtimer_clock_base *base = cpu_base->clock_base + --i; 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))) { @@ -1327,6 +1324,8 @@ retry: __run_hrtimer(timer, &basenow); } + + active_bases &= ~(1 << i); } /*