Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp544591ybg; Wed, 23 Oct 2019 02:05:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4boHWCTFZcv8E9N75pcMCZiZOxHTECbvLDn2gQWQ8iHSdRShlAXeysgyNZb8qYyhLAYSZ X-Received: by 2002:a17:906:5c0a:: with SMTP id e10mr31662176ejq.285.1571821550215; Wed, 23 Oct 2019 02:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571821550; cv=none; d=google.com; s=arc-20160816; b=Mx5nFfDaH7dFqWDuwSMhxpUpWf3ZPJeinxwVqcuqkArkDBGo1qk4f16Zr3lJ8vSA2q 9tG8jUopWWnYSNT2l6s+WTzfXz2yGlfFUHbKybdBBUpugruNBxo3e1w8yJcnHZzn9FlD 0WtjOLPWQjDDCB8C3UWHYbh3pdjGj5aKZ6Y8bTBfRdBlx2ExEEVgbxSNS/5cPx8JPI1T T7ouUM1r7SHEFGZV/ugzeaGn1Z9vsIY24GSRkP6eI6e58887pDP9uYxbVM6BpQ+nSBqb ZAOOQHT16/vle0Mg1j6+6ZPLOM3u7jOAaQSJP1lEFY2gWoi6ib/fl2BKgRr48V+BC9mT r+sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=JUN9J/2vsghSQEDoYKjkArcf/+ULxW+MHO+ZanwPpo4=; b=QenqnKBHa9sCDuJ/Qb9Tu6OyDobQSJkltPYz4ZJ4pCPdWGQM1kt+Pmsfp66OngyPd5 tgM+5+MRJpcmtKhXx0gTGuUPwWS+3ghj+NJY/SGigwZ+XCda0MWlMQcB6B2dqX7FGoe/ MjSBNdxP/n/HhMMXHnoVu+GGMVlCzseX0Ra5dGF9P1anSnM7dNZkyp1CmSarwdAEnc/h BZS+ovEKt/Gmi8ZMaWmSxUQYLC1FrvBIzc2nHqx5MoX18ZOutAuV5+BlhN4rmwqbcT0o uzxGRNa12dT5XoPV/XNYW7L+5W7XBSXbunnsbVYsCTBQT9GVjj0d+J18uYjl10cS4wPU TYcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a26si13599174edv.35.2019.10.23.02.05.26; Wed, 23 Oct 2019 02:05:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390838AbfJWJDd (ORCPT + 99 others); Wed, 23 Oct 2019 05:03:33 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:43758 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390828AbfJWJDb (ORCPT ); Wed, 23 Oct 2019 05:03:31 -0400 Received: by mail-oi1-f195.google.com with SMTP id s5so1324378oie.10; Wed, 23 Oct 2019 02:03:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JUN9J/2vsghSQEDoYKjkArcf/+ULxW+MHO+ZanwPpo4=; b=gsvSpxN8asmmJPaABTh0U7UQr4o1rZIqS6m6NbPa1f9vlQ7DPCM7tz1n9y/Nwa1WfI dQVVzLdpzhZ1I0ur3nKHHMl+3CX5ERnkxHNtFUdIBNFqE8Kn2vM6Rjac8qJb0UIV+IQt rv3VgX1Vo53WsqiLUfaWEb2e52sZsooDt6XTh1qpSn+e24v+VwbQp3nAxIes8ObbcPiN QN/gjimkQpSq/tkzmqHAHi5qXuCPxE3uN2iYg5yaIH4Mnrq6pY8VOmCPIsxTmI9J084S TlW+tDSexTnnIY7kb4nU7zi9iAze3agfwMiuKhQ4XzW2TIN/BcNp1TE5b7nLb2AkmPmN qKdg== X-Gm-Message-State: APjAAAUfYFk0i+GW7Qo64YsSi3pTP8HOgQ63O6ckbotBBtcNg9uwe24p 4iuYMEs5ydQToTc9ILZhc7f+livCDpFoLsOFN54= X-Received: by 2002:aca:d706:: with SMTP id o6mr6936010oig.57.1571821410371; Wed, 23 Oct 2019 02:03:30 -0700 (PDT) MIME-Version: 1.0 References: <20191023074945.17016-1-fengwei.yin@intel.com> <30ee0a348f624698801691f65eeecd87@AcuMS.aculab.com> In-Reply-To: <30ee0a348f624698801691f65eeecd87@AcuMS.aculab.com> From: "Rafael J. Wysocki" Date: Wed, 23 Oct 2019 11:03:19 +0200 Message-ID: Subject: Re: [PATCH v3] ACPI/processor_idle: Remove dummy wait if kernel is in guest mode To: David Laight Cc: Yin Fengwei , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "rjw@rjwysocki.net" , "lenb@kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 10:45 AM David Laight 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 > > --- > > 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.