Re: [PATCH v2 1/2] xen/sched: core: skip missing vcpu slots in sched_move_domain()
Jan Beulich <[email protected]>
| Newsgroups | gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <[email protected]> |
On 19.08.2026 09:28, Furkan Çalışkan wrote:
>
>
> On 8/19/26 09:53, Jan Beulich wrote:
>> On 19.08.2026 07:15, Furkan Caliskan wrote:
>>> --- a/xen/common/sched/core.c
>>> +++ b/xen/common/sched/core.c
>>> @@ -745,6 +745,38 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
>>>
>>> for ( unit_idx = 0; unit_idx < n_units; unit_idx++ )
>>> {
>>> + /*
>>> + * A vcpu slot can be missing if creation failed partway
>>> + * through. A dying domain is being torn down regardless, so
>>> + * skip the unit -- but a domain that isn't dying still needs
>>> + * every vcpu it has schedulable, so fail instead of silently
>>> + * dropping some of them.
>>> + */
>>> + bool vcpu_failed = false;
>>> +
>>> + for ( unsigned int i = 0;
>>> + i < gran && unit_idx * gran + i < d->max_vcpus; i++ )
>>> + {
>>> + if ( !d->vcpu[unit_idx * gran + i] )
>>
>> Is there a particular reason domain_vcpu() cannot be used here?
>
> We still need to guard against d->max_vcpus so that out-of-bounds
> indices in a partially filled unit don't get treated as missing
> vCPUs by domain_vcpu() returning NULL.
Ah, right - the bounds check cannot really be folded here. Then ...
> However, domain_vcpu(unit_idx * gran + i) can be used here instead of
> d->vcpu[unit_idx * gran + i]. I simply used d->vcpu[] because the rest
> of the function uses it that way.
... best wait for Jürgen to comment. Outside of the scheduler we're
trying to replace open-coding of domain_vcpu(), but inside the
scheduler things may be different.
Jan