Skip to content

Commit

Permalink
xen/sched: do some minor cleanup of sched_move_domain()
Browse files Browse the repository at this point in the history
Do some minor cleanups:

- Move setting of old_domdata and old_units next to each other
- Drop incrementing unit_idx in the final loop of sched_move_domain()
  as it isn't used afterwards
- Rename new_p to new_cpu and unit_p to unit_cpu

Signed-off-by: Juergen Gross <[email protected]>
Reviewed-by: George Dunlap <[email protected]>
  • Loading branch information
jgross1 authored and gwd committed Dec 7, 2023
1 parent 23792cc commit 2514700
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions xen/common/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
struct sched_unit *unit, *old_unit;
struct sched_unit *new_units = NULL, *old_units;
struct sched_unit **unit_ptr = &new_units;
unsigned int new_p, unit_idx;
unsigned int new_cpu, unit_idx;
void *domdata;
struct scheduler *old_ops = dom_scheduler(d);
void *old_domdata;
Expand Down Expand Up @@ -748,26 +748,25 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
domain_pause(d);

old_domdata = d->sched_priv;
old_units = d->sched_unit_list;

/*
* Remove all units from the old scheduler, and temporarily move them to
* the same processor to make locking easier when moving the new units to
* new processors.
*/
new_p = cpumask_first(d->cpupool->cpu_valid);
new_cpu = cpumask_first(d->cpupool->cpu_valid);
for_each_sched_unit ( d, unit )
{
spinlock_t *lock;

sched_remove_unit(old_ops, unit);

lock = unit_schedule_lock_irq(unit);
sched_set_res(unit, get_sched_res(new_p));
sched_set_res(unit, get_sched_res(new_cpu));
spin_unlock_irq(lock);
}

old_units = d->sched_unit_list;

d->cpupool = c;
d->sched_priv = domdata;

Expand All @@ -781,32 +780,32 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
unit->state_entry_time = old_unit->state_entry_time;
unit->runstate_cnt[v->runstate.state]++;
/* Temporarily use old resource assignment */
unit->res = get_sched_res(new_p);
unit->res = get_sched_res(new_cpu);

v->sched_unit = unit;
}

d->sched_unit_list = new_units;

new_p = cpumask_first(c->cpu_valid);
new_cpu = cpumask_first(c->cpu_valid);
for_each_sched_unit ( d, unit )
{
spinlock_t *lock;
unsigned int unit_p = new_p;
unsigned int unit_cpu = new_cpu;

for_each_sched_unit_vcpu ( unit, v )
{
migrate_timer(&v->periodic_timer, new_p);
migrate_timer(&v->singleshot_timer, new_p);
migrate_timer(&v->poll_timer, new_p);
new_p = cpumask_cycle(new_p, c->cpu_valid);
migrate_timer(&v->periodic_timer, new_cpu);
migrate_timer(&v->singleshot_timer, new_cpu);
migrate_timer(&v->poll_timer, new_cpu);
new_cpu = cpumask_cycle(new_cpu, c->cpu_valid);
}

lock = unit_schedule_lock_irq(unit);

sched_set_affinity(unit, &cpumask_all, &cpumask_all);

sched_set_res(unit, get_sched_res(unit_p));
sched_set_res(unit, get_sched_res(unit_cpu));
/*
* With v->processor modified we must not
* - make any further changes assuming we hold the scheduler lock,
Expand All @@ -818,8 +817,6 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
sched_move_irqs(unit);

sched_insert_unit(c->sched, unit);

unit_idx++;
}

domain_update_node_affinity(d);
Expand Down

0 comments on commit 2514700

Please sign in to comment.