|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v1.1 2/3] xen/sched: fix theoretical races accessing vcpu->dirty_cpu
On 04.05.20 14:48, Jan Beulich wrote: On 04.05.2020 14:41, Jürgen Groß wrote:On 04.05.20 13:51, Jan Beulich wrote:On 30.04.2020 17:28, Juergen Gross wrote: I'll go with both tests inside the ASSERT(), as this will hurt debug build only. However, having stared at it for a while now - is this race free? I can see this being fine in the (initial) case of dirty_cpu == smp_processor_id(), but if this is for a foreign CPU, can't the vCPU have gone back to that same CPU again in the meantime?This should never happen. Either the vcpu in question is paused, or it has been forced off the cpu due to not being allowed to run there (e.g. affinity has been changed, or cpu is about to be removed from cpupool). I can add a comment explaining it.There is a time window from late in flush_mask() to the assertion you add. All sorts of things can happen during this window on other CPUs. IOW what guarantees the vCPU not getting unpaused or its affinity getting changed yet another time? Hmm, very unlikely, but not impossible (especially in nested virt case). This makes me wonder whether adding the call to sync_vcpu_execstate() to sched_unit_migrate_finish() was really a good idea. There might be cases where it is not necessary (e.g. in the case you are mentioning, but with a much larger time window), or where it is more expensive than doing it the lazy way. Dropping this call of sync_vcpu_execstate() will remove the race you are mentioning completely. Juergen
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |