mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gaurav Jindal (Gaurav Jindal)" <Gaurav.Jindal@spreadtrum.com>
To: "mingo@redhat.com" <mingo@redhat.com>,
	"peterz@infradead.com" <peterz@infradead.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH]sched: cpuidle: Do not fetch current cpu in loop in idle thread
Date: Wed, 27 Apr 2016 09:54:41 +0000	[thread overview]
Message-ID: <20160427095434.GD877@gauravjindalubtnb.del.spreadtrum.com> (raw)

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 varaible while entering the idle
thread and use it in the loop. Since it is local variable, it will be
correct for each core. It will also save cycles consumed while fetching cpu
id using smp_proceesor_id() in loop.

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();
            rmb();

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

Regards
Gaurav Jindal
 

                 reply	other threads:[~2016-04-27  9:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160427095434.GD877@gauravjindalubtnb.del.spreadtrum.com \
    --to=gaurav.jindal@spreadtrum.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®