From patchwork Fri Mar 30 17:43:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 10318241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8CDB66063F for ; Fri, 30 Mar 2018 17:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BDF12A614 for ; Fri, 30 Mar 2018 17:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 701802A5B5; Fri, 30 Mar 2018 17:44:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 214482A5B5 for ; Fri, 30 Mar 2018 17:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752232AbeC3RoD (ORCPT ); Fri, 30 Mar 2018 13:44:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37928 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752072AbeC3RoA (ORCPT ); Fri, 30 Mar 2018 13:44:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C976580AD20C; Fri, 30 Mar 2018 17:43:59 +0000 (UTC) Received: from redhat.com (ovpn-121-127.rdu2.redhat.com [10.10.121.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id D440E84453; Fri, 30 Mar 2018 17:43:58 +0000 (UTC) Date: Fri, 30 Mar 2018 20:43:58 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Subject: [PATCH RFC] ACPI: disable extra P_LVLx access on KVM Message-ID: <1522431741-4678-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 30 Mar 2018 17:43:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 30 Mar 2018 17:43:59 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As documented by commit b488f021 "ACPI: restore comment justifying 'extra' P_LVLx access", Linux does an extra IO read after entering idle because on (some) chipsets STPCLK# doesn't get asserted in time to prevent further instruction processing. This can never be the case on KVM, and a timer read causes an expensive VM exit in turn causing useless load on host system. Detect KVM and skip the read. TODO: whitelist more hypervisors? Note: very lightly tested. Pls don't apply this yet, I am working on a _CST implementation for KVM and will repost this without the RFC tag when it's been tested properly. Posting now for early flames/feedback. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: kvm@vger.kernel.org Signed-off-by: Michael S. Tsirkin --- drivers/acpi/processor_idle.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index abb559c..8ae28dc 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -33,6 +33,7 @@ #include #include #include +#include /* * Include the apic definitions for x86 to have the APIC timer related defines @@ -665,7 +666,8 @@ static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx) /* 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); + if (!kvm_para_available()) + inl(acpi_gbl_FADT.xpm_timer_block.address); } } @@ -687,7 +689,8 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) 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); + if (!kvm_para_available()) + inl(acpi_gbl_FADT.xpm_timer_block.address); } else return -ENODEV; }