Today the number of cpupools in a system is unlimited. This can lead to
multiple problems (e.g. duplicate cpupool-id or scalability issues).
Limit the number of cpupools to twice the number of maximum possible
cpus, allowing to have one cpupool per physical cpu plus some spare
cpupools for special means (there are already existing use cases for
such spare cpupools).
Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
cpumask_t cpupool_free_cpus; /* cpus not in any cpupool */
static LIST_HEAD(cpupool_list); /* linked list, sorted by poolid */
+static unsigned int n_cpupools;
static int cpupool_moving_cpu = -1;
static struct cpupool *cpupool_cpu_moving = NULL;
spin_lock(&cpupool_lock);
+ /* Don't allow too many cpupools. */
+ if ( n_cpupools >= 2 * nr_cpu_ids )
+ {
+ ret = -ENOSPC;
+ goto unlock;
+ }
+ n_cpupools++;
+
if ( poolid != CPUPOOLID_NONE )
{
q = __cpupool_find_by_id(poolid, false);
err:
list_del(&c->list);
+ n_cpupools--;
+ unlock:
spin_unlock(&cpupool_lock);
free_cpupool_struct(c);
return -EBUSY;
}
+ n_cpupools--;
list_del(&c->list);
spin_unlock(&cpupool_lock);