Re: [PATCH linux v3 3/9] xen: introduce xen_vcpu_id mapping

From: Boris Ostrovsky
Date: Sun Sep 04 2016 - 17:13:37 EST


On 09/02/2016 11:29 AM, Julien Grall wrote:
>
>> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
>> index 0f87db2..c833912 100644
>> --- a/arch/x86/xen/enlighten.c
>> +++ b/arch/x86/xen/enlighten.c
>> @@ -1795,6 +1806,12 @@ static void __init init_hvm_pv_info(void)
>>
>> xen_setup_features();
>>
>> + cpuid(base + 4, &eax, &ebx, &ecx, &edx);
>> + if (eax & XEN_HVM_CPUID_VCPU_ID_PRESENT)
>> + this_cpu_write(xen_vcpu_id, ebx);
>> + else
>> + this_cpu_write(xen_vcpu_id, smp_processor_id());
>> +
>> pv_info.name = "Xen HVM";
>>
>> xen_domain_type = XEN_HVM_DOMAIN;
>> @@ -1806,6 +1823,10 @@ static int xen_hvm_cpu_notify(struct
>> notifier_block *self, unsigned long action,
>> int cpu = (long)hcpu;
>> switch (action) {
>> case CPU_UP_PREPARE:
>> + if (cpu_acpi_id(cpu) != U32_MAX)
>> + per_cpu(xen_vcpu_id, cpu) = cpu_acpi_id(cpu);
>> + else
>> + per_cpu(xen_vcpu_id, cpu) = cpu;
>
> I have not tried myself. But looking at the code, the notifiers
> xen_hvm_cpu_notifier and evtchn_fifo_cpu_notifier have the same
> priority. So what does prevent the code above to be executed after the
> event channel callback?


We will be converting to new hotplug state machine where this order will
be guaranteed:

https://lists.xenproject.org/archives/html/xen-devel/2016-08/msg01914.html


-boris