public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2][v2] cpuidle-haltpoll: Replace default_idle with arch_cpu_idle
@ 2022-12-07 12:41 lirongqing
  2022-12-07 12:41 ` [PATCH 2/2][v2] cpuidle-haltpoll: Build as module by default lirongqing
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: lirongqing @ 2022-12-07 12:41 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, rafael, daniel.lezcano, peterz,
	akpm, tony.luck, jpoimboe, linux-kernel, linux-pm

From: Li RongQing <lirongqing@baidu.com>

When KVM guest has MWAIT and mwait_idle is used as default idle function,
but once cpuidle-haltpoll is loaded, default_idle in default_enter_idle is
used, which is using HLT, and cause a performance regression. As the commit
aebef63cf7ff ("x86: Remove vendor checks from prefer_mwait_c1_over_halt")
explains that mwait is preferred

so replace default_idle with arch_cpu_idle which can using MWAIT
optimization.

latency of sockperf ping-pong localhost test is reduced by more 20%
unixbench has 5% performance improvements for single core

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 arch/x86/kernel/process.c          | 1 +
 drivers/cpuidle/cpuidle-haltpoll.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index c21b734..303afad 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -721,6 +721,7 @@ void arch_cpu_idle(void)
 {
 	x86_idle();
 }
+EXPORT_SYMBOL(arch_cpu_idle);
 
 /*
  * We use this if we don't have any better idle routine..
diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c
index 3a39a7f..e66df22 100644
--- a/drivers/cpuidle/cpuidle-haltpoll.c
+++ b/drivers/cpuidle/cpuidle-haltpoll.c
@@ -32,7 +32,7 @@ static int default_enter_idle(struct cpuidle_device *dev,
 		local_irq_enable();
 		return index;
 	}
-	default_idle();
+	arch_cpu_idle();
 	return index;
 }
 
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-12-16 15:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07 12:41 [PATCH 1/2][v2] cpuidle-haltpoll: Replace default_idle with arch_cpu_idle lirongqing
2022-12-07 12:41 ` [PATCH 2/2][v2] cpuidle-haltpoll: Build as module by default lirongqing
2022-12-07 14:39   ` Rafael J. Wysocki
     [not found]   ` <080936016634.CAJZ5v0i9J2YimfQsqJiZjFMR9MLG0fdBf+Regr+_PcsYrAE=SQ@mail.gmail.com>
2022-12-08  2:32     ` Li,Rongqing
2022-12-08 11:42       ` Rafael J. Wysocki
2022-12-08 12:42         ` Li,Rongqing
2022-12-08 13:11           ` Rafael J. Wysocki
2022-12-16 15:01       ` Peter Zijlstra
2022-12-07 14:37 ` [PATCH 1/2][v2] cpuidle-haltpoll: Replace default_idle with arch_cpu_idle Rafael J. Wysocki
     [not found] ` <080936167059.CAJZ5v0g5kTRE+x-8xC2WwQr11j01ox=Nk0aguiC1_HGPU8W=Rw@mail.gmail.com>
2022-12-08  1:46   ` Li,Rongqing
2022-12-08 11:39     ` Rafael J. Wysocki
2022-12-08 12:41       ` Li,Rongqing
2022-12-08 13:01         ` Rafael J. Wysocki
2022-12-09 13:44   ` Li,Rongqing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox