linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yin Fengwei <fengwei.yin@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	David Laight <David.Laight@aculab.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
	"lenb@kernel.org" <lenb@kernel.org>
Subject: Re: [PATCH v3] ACPI/processor_idle: Remove dummy wait if kernel is in guest mode
Date: Thu, 24 Oct 2019 09:22:42 +0800	[thread overview]
Message-ID: <07760c4a-b3f0-83a3-ed1b-6df45f8deb35@intel.com> (raw)
In-Reply-To: <CAJZ5v0jizy95pVh1gek5rmaVvGeZUMkVdKJUdesZeXGbj=mwRw@mail.gmail.com>



On 2019/10/23 下午5:03, Rafael J. Wysocki wrote:
> On Wed, Oct 23, 2019 at 10:45 AM David Laight <David.Laight@aculab.com> wrote:
>>
>> From: Yin Fengwei
>>> Sent: 23 October 2019 08:50
>>
>>
>>> In function acpi_idle_do_entry(), an ioport access is used for dummy
>>> wait to guarantee hardware behavior. But it could trigger unnecessary
>>> vmexit if kernel is running as guest in virtualization environtment.
>>>
>>> If it's in virtualization environment, the deeper C state enter
>>> operation (inb()) will trap to hyervisor. It's not needed to do
>>> dummy wait after the inb() call. So we remove the dummy io port
>>> access to avoid unnecessary VMexit.
>>>
>>> We keep dummy io port access to maintain timing for native environment.
>>>
>>> Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
>>> ---
>>> ChangeLog:
>>> v2 -> v3:
>>>   - Remove dummy io port access totally for virtualization env.
>>>
>>> v1 -> v2:
>>>   - Use ndelay instead of dead loop for dummy delay.
>>>
>>>   drivers/acpi/processor_idle.c | 36 ++++++++++++++++++++++++++++++++---
>>>   1 file changed, 33 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
>>> index ed56c6d20b08..0c4a97dd6917 100644
>>> --- a/drivers/acpi/processor_idle.c
>>> +++ b/drivers/acpi/processor_idle.c
>>> @@ -58,6 +58,17 @@ struct cpuidle_driver acpi_idle_driver = {
>>>   static
>>>   DEFINE_PER_CPU(struct acpi_processor_cx * [CPUIDLE_STATE_MAX], acpi_cstate);
>>>
>>> +static void (*dummy_wait)(u64 address);
>>> +
>>> +static void default_dummy_wait(u64 address)
>>> +{
>>> +     inl(address);
>>> +}
>>> +
>>> +static void default_noop_wait(u64 address)
>>> +{
>>> +}
>>> +
>>
>> Overengineered...
>> Just add:
>>
>> static void wait_for_freeze(void)
>> {
>> #ifdef  CONFIG_X86
>>          /* No delay is needed if we are a guest */
>>          if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
>>                  return;
>> #endif
>>
>>          /* Dummy wait op - must do something useless after P_LVL2 read
>>             because chipsets cannot guarantee that STPCLK# signal
>>             gets asserted in time to freeze execution properly. */
>>          inl(acpi_gbl_FADT.xpm_timer_block.address);
>> }
>>
>> and use it to replace the inl().
> 
> I was about to make a similar comment.
OK. Will send v4 soon.

Regards
Yin, Fengwei

> 

  reply	other threads:[~2019-10-24  1:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23  7:49 [PATCH v3] ACPI/processor_idle: Remove dummy wait if kernel is in guest mode Yin Fengwei
2019-10-23  8:45 ` David Laight
2019-10-23  9:03   ` Rafael J. Wysocki
2019-10-24  1:22     ` Yin Fengwei [this message]
2019-10-24  1:22   ` Yin Fengwei

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=07760c4a-b3f0-83a3-ed1b-6df45f8deb35@intel.com \
    --to=fengwei.yin@intel.com \
    --cc=David.Laight@aculab.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /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;
as well as URLs for NNTP newsgroup(s).