mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/sched: Fix the sorted insertion in sched_domain_insert_unit()
The loop links the new unit in front of the unit whose successor has a
higher unit_id, rather than after it: inserting 1 into {0, 2} gives
{1, 0, 2}. Stop at the first unit with a higher unit_id instead.
This goes unnoticed as long as units are inserted in unit_id order, as
guest vCPUs typically are.
Also rename prev_unit to next_unit: the new unit is linked in front of
*next_unit, not after it.
Fixes: 141db7fd4d ("xen/sched: build a linked list of struct sched_unit")
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
1 parent
8b0a70ddd2
commit
999c22e481
1 file changed
+6
-7
@@ -483,18 +483,17 @@ static struct sched_unit *sched_alloc_unit_mem(void)
|
|||||||
|
|
||||||
static void sched_domain_insert_unit(struct sched_unit *unit, struct domain *d)
|
static void sched_domain_insert_unit(struct sched_unit *unit, struct domain *d)
|
||||||
{
|
{
|
||||||
struct sched_unit **prev_unit;
|
struct sched_unit **next_unit;
|
||||||
|
|
||||||
unit->domain = d;
|
unit->domain = d;
|
||||||
|
|
||||||
for ( prev_unit = &d->sched_unit_list; *prev_unit;
|
for ( next_unit = &d->sched_unit_list; *next_unit;
|
||||||
prev_unit = &(*prev_unit)->next_in_list )
|
next_unit = &(*next_unit)->next_in_list )
|
||||||
if ( (*prev_unit)->next_in_list &&
|
if ( (*next_unit)->unit_id > unit->unit_id )
|
||||||
(*prev_unit)->next_in_list->unit_id > unit->unit_id )
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
unit->next_in_list = *prev_unit;
|
unit->next_in_list = *next_unit;
|
||||||
*prev_unit = unit;
|
*next_unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sched_unit *sched_alloc_unit(struct vcpu *v)
|
static struct sched_unit *sched_alloc_unit(struct vcpu *v)
|
||||||
|
|||||||