Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4052133ybg; Fri, 25 Oct 2019 12:37:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTUoq4/gomKv/PZFGG9s9uqLC0RDlkgjoE6QEHPrRg7zUGEYJYRAzWU/c7qPtfVobTiRGd X-Received: by 2002:a17:906:7212:: with SMTP id m18mr5136474ejk.88.1572032233893; Fri, 25 Oct 2019 12:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572032233; cv=none; d=google.com; s=arc-20160816; b=k0e0fbePv8KNtzTUDBOL0W2Z3gxOS/j1LieigoTimG65wWVc8iGFA4Eu3zt1Fe2Ift a2GZwo+8YDl61XOvkPFONgeXzip/ZWXDOGbY8RSAXnG5EXqv++AdZrAMclFkhj5dda37 v10r+pk3w4BiYeCdJjCQCxxvboEtxTEXe+b1KZBK/0JNdv8fkNi38bH2LhF1M2SwFHiq Tgt4MnRQ72Cvn4MThrCS3WTDfKKA5cux+vYE7tITA4jjbrNjcLWKx13YXbmDTTbxqufW XvH/ZokzL5cWk9mgj/jQb4915cvY+hAnpY24VoiNBQ6iZWIkzh5YtRCsfTtv/emvuSKB hb9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=1FeL79v40MRMQO/PhmeGop6ZTUrn2djDzGkQEXm8jQA=; b=z4nIEZcwQSYFlIqhaCuoODMNqEAAN8Kg2fUGeoPla/mRREbb+rsrvGTsplm4WLOgf0 uYqLi12aYyjDLZ/lrzxOcc02DFtPRcpj6aPzhe156mEdWVrAwNnrLbRUXdyi7eUdVBn8 YpoysgHaHPj3x9eSo/zGDabGxGdbB9beTdSX0akqixjT3C31+7ZvKWVYtV9b1EMvA0g6 VhiebqatDGkrpNlRxrX3+X8hkOyx4JsA7sCAF8A+BoienceE5ICIfDE2p+cVWXLvtSFy ju7p/T56mdW3AskZ+cIdhDOwyomKciUeWTwiDrpZWPD40f6+EvvErtGhAGVCPvivO2pX Ajvg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si1738923eju.251.2019.10.25.12.36.50; Fri, 25 Oct 2019 12:37:13 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501973AbfJYJ7j (ORCPT + 99 others); Fri, 25 Oct 2019 05:59:39 -0400 Received: from mga03.intel.com ([134.134.136.65]:6275 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2501943AbfJYJ7j (ORCPT ); Fri, 25 Oct 2019 05:59:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 02:59:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,228,1569308400"; d="scan'208";a="228849164" Received: from fyin-mobl.ccr.corp.intel.com (HELO [10.239.204.247]) ([10.239.204.247]) by fmsmga002.fm.intel.com with ESMTP; 25 Oct 2019 02:59:37 -0700 Subject: Re: [PATCH v4] ACPI/processor_idle: Remove dummy wait if kernel is in guest To: "Rafael J. Wysocki" Cc: Linux Kernel Mailing List , ACPI Devel Maling List , "Rafael J. Wysocki" , Len Brown References: <20191024070420.4512-1-fengwei.yin@intel.com> From: "Yin, Fengwei" Message-ID: <13725e35-03ec-abb5-466d-0961775a4800@intel.com> Date: Fri, 25 Oct 2019 17:59:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/25/2019 5:06 PM, Rafael J. Wysocki wrote: > On Thu, Oct 24, 2019 at 9:04 AM Yin Fengwei wrote: >> >> 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 >> environment. >> >> If it's in virtualization environment, the deeper C state enter >> operation (inb()) will trap to hypervisor. It's not needed to do >> dummy wait after the inb() call. So we could just remove the >> dummy io port access to avoid unnecessary VMexit. >> >> And keep dummy io port access to maintain timing for native >> environment. >> >> Signed-off-by: Yin Fengwei >> --- >> ChangeLog: >> v3 -> v4: >> - Drop overengineered function pointer and do check whether >> we are in guest before dummy inl call. >> >> 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 | 21 +++++++++++++++------ >> 1 file changed, 15 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c >> index ed56c6d20b08..2ae95df2e74f 100644 >> --- a/drivers/acpi/processor_idle.c >> +++ b/drivers/acpi/processor_idle.c >> @@ -642,6 +642,19 @@ static int acpi_idle_bm_check(void) >> return bm_status; >> } >> >> +static void wait_for_freeze(void) >> +{ >> +#ifdef CONFIG_X86 >> + /* No delay is needed if we are in 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); >> +} >> + >> /** >> * acpi_idle_do_entry - enter idle state using the appropriate method >> * @cx: cstate data >> @@ -658,10 +671,7 @@ static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx) >> } else { >> /* IO port based C-state */ >> inb(cx->address); >> - /* 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); >> + wait_for_freeze(); >> } >> } >> >> @@ -682,8 +692,7 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) >> safe_halt(); >> else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { >> inb(cx->address); >> - /* See comment in acpi_idle_do_entry() */ >> - inl(acpi_gbl_FADT.xpm_timer_block.address); >> + wait_for_freeze(); >> } else >> return -ENODEV; >> } >> -- > > Applying as 5.5 material, thanks! Thanks a lot. Regards Yin, Fengwei >