Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1391987 > unrolled thread

[PATCH]sched:idle: do not fetch current cpu id in loop

Started by"Gaurav Jindal (Gaurav Jindal)" <Gaurav.Jindal@spreadtrum.com>
First post2016-05-02 07:40 +0200
Last post2016-05-02 07:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH]sched:idle: do not fetch current cpu id in loop "Gaurav Jindal (Gaurav Jindal)" <Gaurav.Jindal@spreadtrum.com> - 2016-05-02 07:40 +0200

#1391987 — [PATCH]sched:idle: do not fetch current cpu id in loop

From"Gaurav Jindal (Gaurav Jindal)" <Gaurav.Jindal@spreadtrum.com>
Date2016-05-02 07:40 +0200
Subject[PATCH]sched:idle: do not fetch current cpu id in loop
Message-ID<rueKl-69n-1@gated-at.bofh.it>
Hi

Currently, in idle thread loop, smp_processor_id() fetches the cpu id
every time it runs thus taking more cpu cycles.

Instead, save the cpu id as local variable while entering the idle
thread and use it further. Since it is local varibale, it will be
gurranteed to be correct for each core. It will help to save cycles
consumed in fetching the cpu is using the smp_processor_id().

Patch:

-------------------------------------------------------------------
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 1214f0a..9696f9e 100644
--- a/kernel/sched/idle.c
--- b/kernel/sched/idle.c
@@ -185,6 +185,9 @@ exit_idle:
*/
static void cpu_idle_loop(void)
{
+ int cpu_id;
+
+ cpu_id = smp_processor_id();
while(1)
/*
*If the arch has a polling bit, we maintain an invariant:
@@ -202,7 +205,7 @@ static void cpu_idle_loop(void)
check_pgt_cache();
rmp();

- if (cpu_is_offline(smp_processor_id()))
+ if (cpu_is_offline(cpu_id))
arch_cpu_idle_dead();

local_irq_disable();
------------------------------------------------------------------

Signed-off-by: Gaurav Jindal<gaurav.jindal@spreadtrum.com>
Reviewed-by: Sanjeev Yadav<Sanjeev.Yadav@spreadtrum.com>



Regards
Gaurav Jindal

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web