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

Re: [Xen-devel] [PATCH v2 3/5] x86/AMD: make C-state handling independent of Dom0


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Wed, 17 Jul 2019 09:04:55 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.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-SenderADCheck; bh=L4X3NNoIS/3FEsUQfr86EkFXjK602BejdYs0u249wKw=; b=XYjdIsFQT/BiIN1ZnMzOxfhNL+AOKfT7qGR/Mbjw0zKeC4gB+c4n+XmWnCyqwhUlbB/QdcFI8RpympWHzL3+0jnbkqqzfp1VZ8B0Qny+llkoE7z30/M7V+6KVbsrgN60Z/H9PleuKVy74U+LP9HBioN3JBEK9wvqqQVbSAFzP1DLaa+JdSK6DgyFRPLNY4+1BoiPHKvjdf+2g6ZGZ/eD5G7+cQzmvEMj09O/gh6n7CoLJqGTvxtuW5Z1s8LR1wDJhoeIbqJzq6u9FinlvEjedoqBjN+qHpilSK2eaKroZ0yeZX3RO5CGDMCopb30p6OPCAW9s1vI+1zpLPS58z7YIg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UT/WWc4yaEAmzbGZcimunO4GenytDyVNoANYKv9+tm/pHJ7zTLOWh5p95p4DOY/oqTKIY/cAZDZaCdMuenLwKBH/O+dkKFQsgeHLAjPFpbMQ9nYmlXAgifZ19ultt0ghGneWEY0LlodORWFoKaiTczkviP24CCyhk9ZNloougvM9uXxSRnSBxle2L7z3WwQxTkfuxbYjyB+ZAxvDKHtc+klBYVsRoIyPzQ5qr1H2finkyAzN8mVcSmZp9aHtFOt+5or2xDsAapkPhlvVL4JpPNvr0kvaEvCJyFtuNyJPqX/c8IdR8gqngIldN9PsDXxdqNcta9dHQCMBhL9suV5BRg==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: AndrewCooper <andrew.cooper3@xxxxxxxxxx>, Brian Woods <brian.woods@xxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 17 Jul 2019 09:05:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVMZ95Pg5KTi9KKk6xsZ3jj2BciKbNYdpqgAE4SYA=
  • Thread-topic: [PATCH v2 3/5] x86/AMD: make C-state handling independent of Dom0

On 16.07.2019 16:26, Roger Pau Monné  wrote:
> On Wed, Jul 03, 2019 at 01:01:48PM +0000, Jan Beulich wrote:
>> --- a/xen/arch/x86/acpi/cpu_idle.c
>> +++ b/xen/arch/x86/acpi/cpu_idle.c
>> @@ -110,6 +110,8 @@ boolean_param("lapic_timer_c2_ok", local
>>    
>>    struct acpi_processor_power *__read_mostly processor_powers[NR_CPUS];
>>    
>> +static int8_t __read_mostly vendor_override;
> 
> AFAICT from the code below this is a tri-state (-1, 0, 1). Could it
> maybe be turned into an enum with definitions of the different
> states?
> 
> I think it would make the usage clearer.

Well, personally I prefer doing it this way for tristates. I'll
wait to see what others think.

>> @@ -1286,6 +1291,103 @@ long set_cx_pminfo(uint32_t acpi_id, str
>>        return 0;
>>    }
>>    
>> +static void amd_cpuidle_init(struct acpi_processor_power *power)
>> +{
>> +    unsigned int i, nr = 0;
>> +    const struct cpuinfo_x86 *c = &current_cpu_data;
>> +    const unsigned int ecx_req = CPUID5_ECX_EXTENSIONS_SUPPORTED |
>> +                                 CPUID5_ECX_INTERRUPT_BREAK;
>> +    const struct acpi_processor_cx *cx = NULL;
>> +    static const struct acpi_processor_cx fam17[] = {
>> +        {
>> +            .type = ACPI_STATE_C1,
>> +            .entry_method = ACPI_CSTATE_EM_FFH,
>> +            .address = 0,
> 
> address field will already get set to 0 by default.

Hmm, yes. I'm never really sure whether adding explicit zero
initializers for fields where they aren't don't-cares is better.
Nor (mostly for that reason) am I really consistent in this. I
guess I'll drop the line.

>> +            .latency = 1,
>> +        },
>> +        {
>> +            .type = ACPI_STATE_C2,
>> +            .entry_method = ACPI_CSTATE_EM_HALT,
>> +            .latency = 400,
> 
> Maybe the latency values could be added to cpuidle.h as defines?

I'd rather not, as such constants wouldn't be used in more than one
place. See xen/arch/x86/cpu/mwait-idle.c's respective tables.

>> +        },
>> +    };
>> +
>> +    if ( pm_idle_save && pm_idle != acpi_processor_idle )
>> +        return;
>> +
>> +    if ( vendor_override < 0 )
>> +        return;
>> +
>> +    switch ( c->x86 )
>> +    {
>> +    case 0x18:
>> +        if ( boot_cpu_data.x86_vendor != X86_VENDOR_HYGON )
>> +        {
>> +    default:
>> +            vendor_override = -1;
>> +            return;
>> +        }
>> +        /* fall through */
>> +    case 0x17:
>> +        if ( cpu_has_monitor && c->cpuid_level >= CPUID_MWAIT_LEAF &&
>> +             (cpuid_ecx(CPUID_MWAIT_LEAF) & ecx_req) == ecx_req )
>> +        {
>> +            cx = fam17;
>> +            nr = ARRAY_SIZE(fam17);
>> +            local_apic_timer_c2_ok = true;
>> +            break;
>> +        }
>> +        /* fall through */
>> +    case 0x15:
>> +    case 0x16:
>> +        cx = &fam17[1];
>> +        nr = ARRAY_SIZE(fam17) - 1;
>> +        break;
>> +    }
>> +
>> +    power->flags.has_cst = true;
>> +
>> +    for ( i = 0; i < nr; ++i )
>> +    {
>> +        if ( cx[i].type > max_cstate )
>> +            break;
>> +        power->states[i + 1] = cx[i];
>> +        power->states[i + 1].idx = i + 1;
>> +        power->states[i + 1].target_residency = cx[i].latency * 
>> latency_factor;
> 
> You could set target_residency as part of the initialization, but I
> guess latency_factor being non-const that would move fam17 outside of
> .rodata?

The static being function local - yes, I could, but besides the array
moving out of .rodata I'd then also need to duplicate the latency
values (and as said above I'd like to avoid introducing #define-s for
them).

Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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