[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: disable HPET legacy mode after timer check


  • To: Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 11 Apr 2023 12:20:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mF6vPimqJVDHjhK2HcaQdB5HMWxQvcp8sa26GFl1IT8=; b=nwMpN3Vue2OrrBlrwiyHrx0tJzsSQNgy9H4dsdUll1u41EJ6JCIcDnpY+Ix5Q1O5kVEtT4xJ+CmBUIznLMG09IXc/aCLK3dX7SEdiSclP+MJew5YzpcxgGI7bLaBH9XxGL1LS107vy7v4zA8AqemFUStGz71WH3YszUdAFzqDm/c2BUcUNqhDisOyF7j2q9h1eEIKgxEAumAUh6TBi4tnjd6GXJRVYfvlOuCMFt5zDDe3OPb8WmaXZj+ycLnvM+Cdb5aN81e2sLzywI1ORXXJcJXaDwMbRhd6QatDtp3MZh+LgbtN6YAX6GG9GyKo0+3EZFy72YlzHC+HrRx5pxuXA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ECABTnGxn/BCHjXlOaT3EWISMacfPIgxb+i3A1QgYV8aA769SsNyobmuXPn5yTieO62GErYSTUPrgL7QipEEpIWaue5AF6znshNaWpBx6uT4CNuMvCdpNmSKdMHABjUmUAgssAZXYCsTfvZYw5IExzRMQUuO31zIoevNresstLXFT6+ABGehg/Cm78Os4hp8kWPqqIRChXe9Ky06T+4DMIXf1lHtywQkgEvquERMXmTthOdXYLrahBjDgVGwN+vXnnKaSs/Q6gR4tthftzox2TOQfuprnnIY7R4j5XtS04G7c/yjLETdJGxq67IKTJx0xLi0RmV1gmF13N12i0g9kQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 11 Apr 2023 11:21:26 +0000
  • Ironport-data: A9a23:GpgvPqkkyEbcy2VIO7nafd3o5gxMJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xIdXWGBMquCNmr2ct1/adu19U0C68eBy4BhGwA4rSE3QiMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icfHgqH2eIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE4p7aSaVA8w5ARkPqgX5QaGzhH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 d0CbzcRPzPdvt31zLbiTcNBqcpzIPC+aevzulk4pd3YJdAPZMmZBonvu5pf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkV03ieewWDbWUoXiqcF9t0CUv G/ZuU/+BQkXLoe3wjuZ6HO8wOTImEsXXapLTODgpq463QT7Kmo7ORwmcWCJoN+ArGGZVtRTK 1EbpiQrhP1nnKCsZpynN/Gim1afvxsbXfJRFfM78wCHzqfI4wefCXMARzQHY9sj3OcmSDpv2 lKXktfBAT10rKbTWX+b7q2Trz65JW4SN2BqTSoNVw4M+dTgiIA1kBPUT9xnHbK1j9v6AjX5y XaBqy1WulkIpcsC1qH+8VWZhTup/8LNVlRsuViRWX+55ARkYoLjf5av9VXQ8fdHKsCeU0WFu 38H3cOZ6YjiEK2wqcBEe81VdJnB2hpPGGe0bYJHd3X5ywmQxg==
  • Ironport-hdrordr: A9a23:SaC0SqgUzNIaoS31RKTXaRtKvnBQXh4ji2hC6mlwRA09TyX5ra 2TdZUgpHrJYVMqMk3I9uruBEDtex3hHP1OkOss1NWZPDUO0VHARO1fBOPZqAEIcBeOldK1u5 0AT0B/YueAd2STj6zBkXSF+wBL+qj6zEiq792usEuEVWtRGsVdB58SMHfiLqVxLjM2YqYRJd 6nyedsgSGvQngTZtTTPAh/YwCSz+e78q4PeHQ9dmca1DU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11/04/2023 11:30 am, Simon Gaiser wrote:
> Hi,
>
> I have been recently looking into getting S0ix working on Xen [1].
>
> Thanks to a tip from Andrew I found that the HPET legacy mode was
> preventing my test system from reaching a package C-state lower than PC7
> and thereby also preventing S0ix residency.
>
> For testing I simply modified check_timer() to disable it again after it
> checked the timer irq:
>
> --- a/xen/arch/x86/io_apic.c
> +++ b/xen/arch/x86/io_apic.c
> @@ -1966,6 +1969,8 @@ static void __init check_timer(void)
>  
>              if ( timer_irq_works() )
>              {
> +                hpet_disable_legacy_replacement_mode();
>                  local_irq_restore(flags);
>                  return;
>              }
>
>
> With this [2] I'm able to reach S0ix residency for some time and for short
> periods the systems power consumption goes down to the same level as with
> native Linux!

Excellent progress!

> It reaches low power states only for a fraction of the suspend to idle
> time, so something still makes the CPU/chipset think it should leave the
> low power mode, but that's another topic.

Do you have any further info here?  There are a range of possibilities,
from excess timers in Xen (e.g. PV guests default to a 100Hz timer even
though no guests actually want it AFAICT), or the 1s TSC rendezvous
(which isn't actually needed on modern systems), all the way to the
platform devices not entering d3hot.

>
> I tried to understand how all the timer code interacts with disabling
> the legacy mode. I think it only would break cpuidle if X86_FEATURE_ARAT
> is not available (Which is available on my test system and indeed I
> didn't run into obvious breakage). 
>
> Is this (disabled PIT && !ARAT) a configuration that exists (and needs
> to be supported)?
>
> Did I miss something else? (Very much possible, given that this is way
> above my existing experience with X86 and Xen internals.)

Xen's code is a mess and needs an overhaul.

Right now, we're using the timer as "a source of interrupts" to try and
check that we've got things set up suitably.  But this doesn't need to
be the PIT, or a timer at all - it just needs to be "an interrupt coming
in from the platform".

Furthermore, there will soon be client platforms with no PIT/HPET/etc at
all.  (HPET is known broken in <PC7, and not used these days anyway in
order to get deeper sleep working), so this logic is going to explode on
us yet again.

AFAICT moving forwards, the expectation is to use TSCs as the
clocksource, and the deadline timer for interrupts.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.