From: Venkatesh Pallipadi <venki@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>,
Aaron Durbin <adurbin@google.com>, Paul Turner <pjt@google.com>,
Yong Zhang <yong.zhang0@gmail.com>,
Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org,
Venkatesh Pallipadi <venki@google.com>
Subject: [PATCH 4/4] x86: Optimize try_ipiless_wakeup avoid idle task lookup
Date: Fri, 24 Feb 2012 14:33:20 -0800 [thread overview]
Message-ID: <1330122800-834-5-git-send-email-venki@google.com> (raw)
In-Reply-To: <1330122800-834-1-git-send-email-venki@google.com>
Optimize try_ipiless_wakeup with caching of idletask's ti_flags pointer
in a percpu area. Shows a measurable difference in cost of async
smp_call_function_single() to a target CPU that is mwait-idle.
This shows ~50-100 cycles (of total 1200(local) or 1900(remote)) savings on
the IPI send side (as measured with async smp_call_function_single).
Signed-off-by: Venkatesh Pallipadi <venki@google.com>
---
arch/x86/include/asm/ipiless_wake.h | 7 ++++---
arch/x86/kernel/smpboot.c | 4 ++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/ipiless_wake.h b/arch/x86/include/asm/ipiless_wake.h
index a490dd3..232ce36 100644
--- a/arch/x86/include/asm/ipiless_wake.h
+++ b/arch/x86/include/asm/ipiless_wake.h
@@ -7,6 +7,7 @@
#ifdef CONFIG_SMP
+DECLARE_PER_CPU(__u32 *, idletask_ti_flags);
/*
* TIF_IN_IPILESS_IDLE CPU being in a idle state with ipiless wakeup
* capability, without any pending IPIs.
@@ -61,13 +62,13 @@ static inline void do_ipiless_pending_work(void)
static inline int try_ipiless_wakeup(int cpu)
{
- struct thread_info *idle_ti = task_thread_info(idle_task(cpu));
+ __u32 *ti_flags = per_cpu(idletask_ti_flags, cpu);
- if (!(idle_ti->flags & _TIF_IN_IPILESS_IDLE))
+ if (!(*ti_flags & _TIF_IN_IPILESS_IDLE))
return 0;
return test_and_clear_bit(TIF_IN_IPILESS_IDLE,
- (unsigned long *)&idle_ti->flags);
+ (unsigned long *)ti_flags);
}
#else
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 66d250c..33339e2 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -133,6 +133,8 @@ DEFINE_PER_CPU(cpumask_var_t, cpu_llc_shared_map);
DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
EXPORT_PER_CPU_SYMBOL(cpu_info);
+DEFINE_PER_CPU(__u32 *, idletask_ti_flags);
+
atomic_t init_deasserted;
/*
@@ -715,6 +717,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
set_idle_for_cpu(cpu, c_idle.idle);
do_rest:
per_cpu(current_task, cpu) = c_idle.idle;
+ per_cpu(idletask_ti_flags, cpu) = &task_thread_info(c_idle.idle)->flags;
#ifdef CONFIG_X86_32
/* Stack for startup_32 can be just as for start_secondary onwards */
irq_ctx_init(cpu);
@@ -1143,6 +1146,7 @@ void __init native_smp_prepare_boot_cpu(void)
/* already set me in cpu_online_mask in boot_cpu_init() */
cpumask_set_cpu(me, cpu_callout_mask);
per_cpu(cpu_state, me) = CPU_ONLINE;
+ per_cpu(idletask_ti_flags, me) = &task_thread_info(current)->flags;
}
void __init native_smp_cpus_done(unsigned int max_cpus)
--
1.7.7.3
next prev parent reply other threads:[~2012-02-24 22:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-24 22:33 [PATCH 0/4] Extend mwait idle to optimize away CAL and RES interrupts to an idle CPU -v2 Venkatesh Pallipadi
2012-02-24 22:33 ` [PATCH 1/4] tile, ia64, x86: TS_POLLING cleanup Venkatesh Pallipadi
2012-02-24 22:33 ` [PATCH 2/4] x86: Mwait idle optimization to avoid CAL+RES IPIs -v2 Venkatesh Pallipadi
2012-02-24 22:33 ` [PATCH 3/4] x86: Extend IPIless wake to C1_mwait and poll_idle Venkatesh Pallipadi
2012-02-24 22:33 ` Venkatesh Pallipadi [this message]
2012-02-27 7:32 ` [PATCH 0/4] Extend mwait idle to optimize away CAL and RES interrupts to an idle CPU -v2 Ingo Molnar
2012-02-27 18:21 ` Venki Pallipadi
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=1330122800-834-5-git-send-email-venki@google.com \
--to=venki@google.com \
--cc=adurbin@google.com \
--cc=andi@firstfloor.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=yong.zhang0@gmail.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
Powered by JetHome