From patchwork Sat Feb 8 12:02:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 24340 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 86B2420143 for ; Sat, 8 Feb 2014 12:03:17 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id x10sf8083866pdj.8 for ; Sat, 08 Feb 2014 04:03:15 -0800 (PST) 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=wGbYNxy8pkslsaajEOUUuSYq3hMMGXo+iWneLs6SKeg=; b=TsxSTnK8qqyZx0HVtPLF3DmzO88Bu8Mw7K/m9nPtON04r8H37811w9lyLc96GEw8nO oGoll43t9EH9OBYCtwUrU0waw+lWaQ1y516Zlin5XU6D5E2fzWwXbS2DnfgjebGYtzhD fzRpVyXZ7Qr/AdaYHlwbYTjyWswFi6x8xHh+pHTk1CDQfJkEkaxWQyRdFDuyv54wTJhl EAafcwyzgCSzhdHhQ1b4vBCSgdH5JNPU9ERno9DTb/yMWvKAJ1K1wXo4q//YQb9u6p0H gbTeAutpkVDOMqc/C1l2hCnHCCWXFq+EtCY57pwJDvw9QgxM7PYQtwRqNALmKwVqvdzG GEXg== X-Gm-Message-State: ALoCoQnADuv8t57vcgu4JZXcBNMBMF2Cz6zbZo9hXkfVPPkJJQivcC47Bi+LZzsIUGWEc22rWMbG X-Received: by 10.68.197.73 with SMTP id is9mr8046024pbc.0.1391860995880; Sat, 08 Feb 2014 04:03:15 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.35.208 with SMTP id n74ls1353337qgn.65.gmail; Sat, 08 Feb 2014 04:03:15 -0800 (PST) X-Received: by 10.52.23.68 with SMTP id k4mr12346505vdf.24.1391860995784; Sat, 08 Feb 2014 04:03:15 -0800 (PST) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id cl8si2432928vcb.76.2014.02.08.04.03.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Feb 2014 04:03:15 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.51 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.51; Received: by mail-vb0-f51.google.com with SMTP id 11so3512050vbe.10 for ; Sat, 08 Feb 2014 04:03:15 -0800 (PST) X-Received: by 10.52.30.230 with SMTP id v6mr12357307vdh.6.1391860995701; Sat, 08 Feb 2014 04:03:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp29210vcz; Sat, 8 Feb 2014 04:03:15 -0800 (PST) X-Received: by 10.68.7.66 with SMTP id h2mr25452953pba.91.1391860994679; Sat, 08 Feb 2014 04:03:14 -0800 (PST) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx.google.com with ESMTPS id qt8si5594563pbb.191.2014.02.08.04.03.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Feb 2014 04:03:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.44 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.220.44; Received: by mail-pa0-f44.google.com with SMTP id kq14so4279753pab.31 for ; Sat, 08 Feb 2014 04:03:14 -0800 (PST) X-Received: by 10.68.125.164 with SMTP id mr4mr25542597pbb.27.1391860993954; Sat, 08 Feb 2014 04:03:13 -0800 (PST) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id nv7sm22970477pbc.31.2014.02.08.04.03.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Feb 2014 04:03:12 -0800 (PST) From: Sanjay Singh Rawat To: private-pmwg@linaro.org Cc: Sanjay Singh Rawat Subject: [PATCH] cpuidle: optimize using inline hint Date: Sat, 8 Feb 2014 17:32:54 +0530 Message-Id: <1391860974-1912-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sanjay.rawat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.51 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Signed-off-by: Sanjay Singh Rawat --- This patch is intended to add some inline optimization for few functions in cpuidle code, which will save some function call work and negligible increase in the size of the code. using inline hint for functions - with minimal definition and are suitable for inlining - which are called frequently checked on panda 3.14.rc1, using menu governor. How to check for ladder? regards, sanjay --- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/driver.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 7 +++---- kernel/sched/proc.c | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index a55e68f..33fbba7 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -33,7 +33,7 @@ static int enabled_devices; static int off __read_mostly; static int initialized __read_mostly; -int cpuidle_disabled(void) +inline int cpuidle_disabled(void) { return off; } diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 06dbe7c..d5b5294 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -30,7 +30,7 @@ static DEFINE_PER_CPU(struct cpuidle_driver *, cpuidle_drivers); * Returns a pointer to struct cpuidle_driver or NULL if no driver has been * registered for @cpu. */ -static struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) +static inline struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) { return per_cpu(cpuidle_drivers, cpu); } diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index 9f08e8c..28d39e7 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c @@ -168,7 +168,7 @@ static int ladder_enable_device(struct cpuidle_driver *drv, * @dev: the CPU * @index: the index of actual state entered */ -static void ladder_reflect(struct cpuidle_device *dev, int index) +static inline void ladder_reflect(struct cpuidle_device *dev, int index) { struct ladder_device *ldev = &__get_cpu_var(ladder_devices); if (index > 0) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index cf7f2f0..6ed1d78 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -135,11 +135,10 @@ struct menu_device { #define LOAD_INT(x) ((x) >> FSHIFT) #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) -static int get_loadavg(void) +static inline int get_loadavg(void) { unsigned long this = this_cpu_load(); - return LOAD_INT(this) * 10 + LOAD_FRAC(this) / 10; } @@ -195,7 +194,7 @@ static DEFINE_PER_CPU(struct menu_device, menu_devices); static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev); /* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */ -static u64 div_round64(u64 dividend, u32 divisor) +static inline u64 div_round64(u64 dividend, u32 divisor) { return div_u64(dividend + (divisor / 2), divisor); } @@ -373,7 +372,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) * NOTE: it's important to be fast here because this operation will add to * the overall exit latency. */ -static void menu_reflect(struct cpuidle_device *dev, int index) +static inline void menu_reflect(struct cpuidle_device *dev, int index) { struct menu_device *data = &__get_cpu_var(menu_devices); data->last_state_idx = index; diff --git a/kernel/sched/proc.c b/kernel/sched/proc.c index 16f5a30..abca704 100644 --- a/kernel/sched/proc.c +++ b/kernel/sched/proc.c @@ -8,7 +8,7 @@ #include "sched.h" -unsigned long this_cpu_load(void) +inline unsigned long this_cpu_load(void) { struct rq *this = this_rq(); return this->cpu_load[0];