RE: [PATCH] cpuidle-haltpoll: Disable kvm guest polling when mwait_idle is used

From: Li,Rongqing
Date: Tue Dec 06 2022 - 23:39:42 EST




> -----Original Message-----
> From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Sent: Tuesday, December 6, 2022 8:08 PM
> To: Rafael J. Wysocki <rafael@xxxxxxxxxx>; Li,Rongqing <lirongqing@xxxxxxxxx>
> Cc: mingo@xxxxxxxxxx; bp@xxxxxxxxx; dave.hansen@xxxxxxxxxxxxxxx;
> x86@xxxxxxxxxx; rafael@xxxxxxxxxx; daniel.lezcano@xxxxxxxxxx;
> peterz@xxxxxxxxxxxxx; akpm@xxxxxxxxxxxxxxxxxxxx; tony.luck@xxxxxxxxx;
> jpoimboe@xxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; linux-pm@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH] cpuidle-haltpoll: Disable kvm guest polling when
> mwait_idle is used
>
> On Tue, Dec 06 2022 at 12:59, Rafael J. Wysocki wrote:
> > On Tue, Dec 6, 2022 at 7:43 AM <lirongqing@xxxxxxxxx> wrote:
> >>
> >> +bool is_mwait_idle(void)
> >> +{
> >> + return x86_idle == mwait_idle; }
> >> +EXPORT_SYMBOL_GPL(is_mwait_idle);
>
> No, this is just another adhoc check, which scratches ONE particular itch.
>
> >> @@ -111,6 +112,9 @@ static int __init haltpoll_init(void)
> >> if (!kvm_para_available() || !haltpoll_want())
> >> return -ENODEV;
> >>
> >> + if (is_mwait_idle())
> >> + return -ENODEV;
> >> +
> >
> > So perhaps you could make default_enter_idle() be a bit more careful
> > about what it calls as the "default idle" routine?
>
> Correct. arch_cpu_idle() is the one which should be called.
>

Greats, using arch_cpu_idle() can get best latency,

Before change, "sockperf ping-pong -i 127.0.0.1 -p 20001 --tcp " latency is:
sockperf: Summary: Latency is 6.245 usec

this patch, disable cpuidle-haltpoll
sockperf: Summary: Latency is 4.671 usec


using arch_cpu_idle() in default_enter_idle()
sockperf: Summary: Latency is 4.285 usec


thanks

-LiRongQing


> Thanks,
>
> tglx