Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5796262ybp; Tue, 15 Oct 2019 05:17:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWLPOZBqTlThEV3l77wwaZBfY7R8ONbRScKSvEwHvxuzm2+CxHpM9DEuStVLEP2bJbpAOb X-Received: by 2002:a17:906:31d4:: with SMTP id f20mr3545538ejf.265.1571141852852; Tue, 15 Oct 2019 05:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571141852; cv=none; d=google.com; s=arc-20160816; b=JmdErLZ16MbmnT7dzvEwmEMsKsPNNktY+N60sE0ssWfoiaR/R+CZ46uIKDVLC0Eueb Hbi0EHHzn/9hTHAeuL6marY1iObopm0YgwG02hoGvpTtQbPmHCTQEcBBiUVtHbIiN+tm MaA3rViY0doZ4BKYJgIlu+PfEoeroCOoHltkKdZmgBw3JCeT+39yPyaluQInsmMr4gC6 GW8t2tiVW8Oq2XJhydnqssOhsku+eT8F9s65w6jtvE7X9NoYdGFvJ40AnlXBAn0L4Rob LrYwHhp8agKOeR0iDwocEPTCcbVdcqRS1VuQAtKoQ5qzDu6lCREljyR7LJT0OkZ3TbHW JTwQ== 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from; bh=vYsrlkPxySVuyTMVVYAmmeQt9cTTtpgr/W9nDJGXaUo=; b=UfHSiTnWB1/yrmHqou4NMCc9oo483/tbyya73jZ/8dEMi+AfoctrbJphMHc0PDQART 5Zw3qE+QBoLkeXSuOSvOfNI69wI9tuTna5Dt96rEfyAQhsy4Cw9/LWe45bR0KNqjbUpQ kJn6v4I7WNx7DidZXljQIdUDD+gcR0B4m7wRa/8A/ujaObkjrNnIeRWKzcsocMLogBJA XQNmYwZep9KrCaIH0AikS425J+WApleW8ztaSGBFEGK8NcKcVBfX5ofY/9Lrt/xk/MBG BQuOPIrmZguzDv1Ybql3qHaJ6DXvSnNor/TeKw5Gctnw1dlBvcLBd2wFqRyFz/pZMCgO wnVw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v27si12839824ejb.182.2019.10.15.05.17.09; Tue, 15 Oct 2019 05:17:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729555AbfJOLsU convert rfc822-to-8bit (ORCPT + 99 others); Tue, 15 Oct 2019 07:48:20 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([146.101.78.151]:51364 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728386AbfJOLsT (ORCPT ); Tue, 15 Oct 2019 07:48:19 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-235-E9r2Iy20MAWay1Auj4hFhA-1; Tue, 15 Oct 2019 12:48:16 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 15 Oct 2019 12:48:16 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 15 Oct 2019 12:48:16 +0100 From: David Laight To: 'Yin Fengwei' , "rjw@rjwysocki.net" , "lenb@kernel.org" , "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2] ACPI / processor_idle: use ndelay instead of io port access for wait Thread-Topic: [PATCH v2] ACPI / processor_idle: use ndelay instead of io port access for wait Thread-Index: AQHVgy8hI4gW7D6kAEmU4JIecWCIJ6dblHkg Date: Tue, 15 Oct 2019 11:48:15 +0000 Message-ID: References: <20191015080404.6013-1-fengwei.yin@intel.com> In-Reply-To: <20191015080404.6013-1-fengwei.yin@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: E9r2Iy20MAWay1Auj4hFhA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yin Fengwei > Sent: 15 October 2019 09:04 > In function acpi_idle_do_entry(), an ioport access is used for dummy > wait to guarantee hardware behavior. But it could trigger unnecessary > vmexit in virtualization environment. > > If we run linux as guest and export all available native C state to > guest, we did see many PM timer access triggered VMexit when guest > enter deeper C state in our environment (We used ACRN hypervisor > instead of kvm or xen which has PM timer emulated and exports all > native C state to guest). > > According to the original comments of this part of code, io port > access is only for dummy wait. We could use busy wait instead of io > port access to guarantee hardware behavior and avoid unnecessary > VMexit. You need some hard synchronisation instruction(s) after the inb() and before any kind of delay to ensure your delay code is executed after the inb() completes. I'm pretty sure that inb() is only synchronised with memory reads. ... > + /* profiling the time used for dummy wait op */ > + ktime_get_real_ts64(&ts0); > + inl(acpi_gbl_FADT.xpm_timer_block.address); > + ktime_get_real_ts64(&ts1); That could be dominated by the cost of ktime_get_real_ts64(). It also need synchronising instructions. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)