Message ID | 1670416895-50172-1-git-send-email-lirongqing@baidu.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp156946wrr; Wed, 7 Dec 2022 04:44:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ihKSdRacEZigJgplwrFk51G2PRHpRngRwWPUKH5WD3KEbVMn9jIYftZSkMcNn/akuxATw X-Received: by 2002:a50:fd08:0:b0:46c:7117:3cae with SMTP id i8-20020a50fd08000000b0046c71173caemr15612546eds.195.1670417043595; Wed, 07 Dec 2022 04:44:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670417043; cv=none; d=google.com; s=arc-20160816; b=D5VS0kpuHjcHLn0O0ZqLxmxJQoCb+64m6C2hz9onbNA68HIsfpFbNXnp3rsxZ+8O0j DoFCFhqPkJIOskma7cKsU1t+VAe0OjKjAFkVdmMO9Ps2XKIM6ifKL0TUQRCISBjFxUdi bi1NvhbkOoIqCB9ddcQ/V3utoTW4z1ZD8TMdJtuS1eKklLNHkVLHxFIsJJf81roZr/q9 yBqhCxSA+6/bOuR+xmnBX4MmvoqffS5KAm9xIpicpjYjcslWAsNIm7nvyuGKYyQyIGKd PE94r35XsxF1ProfDQyXHf8sKp5/XLRLXPdEQnSk6d/U3JCQbaFYCslGIe1wNge8YUxn HpXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from; bh=cxH0z7PyTfXWjJ8SJyP9knDtYade4KeHPvBjYjlJnJ4=; b=SvdVzSL19UYgUXjVT8lT0YI9yrCYyoaz4/LI1JdcWvB8ohcpO3Ktov//5CSkgA05zN UbePGNoCr5jhR9ynKH2VKJo/4QuDq3ovJI1Vza/8p9i2finZCWBdxuMK5Ted/oWBy+5K 7An+W/DcTPUYR/U+YFNSmJ+hbPb6YHlqnXMW6e/XvZeQVW9xjNuqox5mJJzGF851NusS EdZOzRDns5DismCHEQpxtqP1SnvqgBtheoFzEIswPeFmWgBZcOEFgytzS8ujeYmfUT81 4ke0sEYy+cgL3+I0WXNJ2j4X4sZmXJp9W/tnxxRkqI1ifxnDwdviUcYZ5MkqMUmYcXlo /eBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a1709064ac100b007adb868f102si12691032ejt.476.2022.12.07.04.43.39; Wed, 07 Dec 2022 04:44:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbiLGMmc (ORCPT <rfc822;b08248@gmail.com> + 99 others); Wed, 7 Dec 2022 07:42:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbiLGMm2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 07:42:28 -0500 Received: from bddwd-sys-mailin01.bddwd.baidu.com (mx402.baidu.com [124.64.201.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C6E76391C2; Wed, 7 Dec 2022 04:42:27 -0800 (PST) Received: from bjhw-sys-rpm015653cc5.bjhw.baidu.com (bjhw-sys-rpm015653cc5.bjhw.baidu.com [10.227.53.39]) by bddwd-sys-mailin01.bddwd.baidu.com (Postfix) with ESMTP id 6087A11980033; Wed, 7 Dec 2022 20:41:35 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by bjhw-sys-rpm015653cc5.bjhw.baidu.com (Postfix) with ESMTP id 59702D9932; Wed, 7 Dec 2022 20:41:35 +0800 (CST) From: lirongqing@baidu.com To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org, peterz@infradead.org, akpm@linux-foundation.org, tony.luck@intel.com, jpoimboe@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 1/2][v2] cpuidle-haltpoll: Replace default_idle with arch_cpu_idle Date: Wed, 7 Dec 2022 20:41:34 +0800 Message-Id: <1670416895-50172-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751559222235810278?= X-GMAIL-MSGID: =?utf-8?q?1751559222235810278?= |
Series |
[1/2,v2] cpuidle-haltpoll: Replace default_idle with arch_cpu_idle
|
|
Commit Message
Li,Rongqing
Dec. 7, 2022, 12:41 p.m. UTC
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(-)
Comments
On Wed, Dec 7, 2022 at 1:42 PM <lirongqing@baidu.com> wrote: > > 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); Why do you need this export at all? > > /* > * 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 >
> -----Original Message----- > From: Rafael J. Wysocki <rafael@kernel.org> > Sent: Wednesday, December 7, 2022 10:38 PM > To: Li,Rongqing <lirongqing@baidu.com> > Cc: tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; > dave.hansen@linux.intel.com; x86@kernel.org; rafael@kernel.org; > daniel.lezcano@linaro.org; peterz@infradead.org; akpm@linux-foundation.org; > tony.luck@intel.com; jpoimboe@kernel.org; linux-kernel@vger.kernel.org; > linux-pm@vger.kernel.org > Subject: Re: [PATCH 1/2][v2] cpuidle-haltpoll: Replace default_idle with > arch_cpu_idle > > On Wed, Dec 7, 2022 at 1:42 PM <lirongqing@baidu.com> wrote: > > > > 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); > > Why do you need this export at all? > When cpuidle-haltpoll is built as module, if arch_cpu_idle is not export, cpuidle-haltpoll will complain "arch_cpu_idle" undefined Like ERROR: modpost: "arch_cpu_idle" [drivers/cpuidle/cpuidle-haltpoll.ko] undefined! make[1]: *** [scripts/Makefile.modpost:126: Module.symvers] Error 1 make: *** [Makefile:1944: modpost] Error 2 Error: Make failed! I will add the reason to v3 Thanks -Li
On Thu, Dec 8, 2022 at 2:48 AM Li,Rongqing <lirongqing@baidu.com> wrote: > > > > > -----Original Message----- > > From: Rafael J. Wysocki <rafael@kernel.org> > > Sent: Wednesday, December 7, 2022 10:38 PM > > To: Li,Rongqing <lirongqing@baidu.com> > > Cc: tglx@linutronix.de; mingo@redhat.com; bp@alien8.de; > > dave.hansen@linux.intel.com; x86@kernel.org; rafael@kernel.org; > > daniel.lezcano@linaro.org; peterz@infradead.org; akpm@linux-foundation.org; > > tony.luck@intel.com; jpoimboe@kernel.org; linux-kernel@vger.kernel.org; > > linux-pm@vger.kernel.org > > Subject: Re: [PATCH 1/2][v2] cpuidle-haltpoll: Replace default_idle with > > arch_cpu_idle > > > > On Wed, Dec 7, 2022 at 1:42 PM <lirongqing@baidu.com> wrote: > > > > > > 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); > > > > Why do you need this export at all? > > > > When cpuidle-haltpoll is built as module, But it isn't now. > if arch_cpu_idle is not export, cpuidle-haltpoll will complain "arch_cpu_idle" undefined So no, this won't happen.
> > > > When cpuidle-haltpoll is built as module, > > But it isn't now. Centos is compiling it as module, it will fail; Other user wants to compile it as module, they will fail, Syzbot random configuration building will fail Unless prohibit to build it as module as below: config HALTPOLL_CPUIDLE - tristate "Halt poll cpuidle driver" + bool "Halt poll cpuidle driver" depends on X86 && KVM_GUEST default y help thanks -Li
On Thu, Dec 8, 2022 at 1:43 PM Li,Rongqing <lirongqing@baidu.com> wrote: > > > > > > > When cpuidle-haltpoll is built as module, > > > > But it isn't now. > > Centos is compiling it as module, it will fail; > Other user wants to compile it as module, they will fail, > Syzbot random configuration building will fail > > Unless prohibit to build it as module as below: > > config HALTPOLL_CPUIDLE > - tristate "Halt poll cpuidle driver" > + bool "Halt poll cpuidle driver" > depends on X86 && KVM_GUEST > default y > help Ah, OK. Sorry about the confusion. Yes, the driver (not the governor, though), can be modular, so yes you need the export, but please change it to EXPORT_SYMBOL_GPL().
> > latency of sockperf ping-pong localhost test is reduced by more 20% > > unixbench has 5% performance improvements for single core > > Sorry, The upper data are wrong since wrong governor is used when guest has mwait, and haltpoll driver is loaded and haltpoll governor is used. on Intel cpu, unixbench score are nearly same, but sockperf has 20% low latency on AMD milan cpu, the sockperf latency are similar , but unixbench single core score has 10% loss, because AMD cpu maybe has weak smt capability Replace default idle with arch cpu idle has little effect Thanks -Li I
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; }