diff mbox

cpuidle: optimize using inline hint

Message ID 1391860974-1912-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat Feb. 8, 2014, 12:02 p.m. UTC
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---

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 mbox

Patch

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];