Commit ffe0d5a5 authored by Tejun Heo's avatar Tejun Heo

percpu: fix unit_map[] verification in pcpu_setup_first_chunk()

pcpu_setup_first_chunk() incorrectly used NR_CPUS as the impossible
unit number while unit number can equal and go over NR_CPUS with
sparse unit map.  This triggers BUG_ON() spuriously on machines which
have non-power-of-two number of cpus.  Use UINT_MAX instead.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reported-and-tested-by: default avatarTony Vroon <tony@linx.net>
parent 17d857be
...@@ -1604,7 +1604,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, ...@@ -1604,7 +1604,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
unit_off = alloc_bootmem(nr_cpu_ids * sizeof(unit_off[0])); unit_off = alloc_bootmem(nr_cpu_ids * sizeof(unit_off[0]));
for (cpu = 0; cpu < nr_cpu_ids; cpu++) for (cpu = 0; cpu < nr_cpu_ids; cpu++)
unit_map[cpu] = NR_CPUS; unit_map[cpu] = UINT_MAX;
pcpu_first_unit_cpu = NR_CPUS; pcpu_first_unit_cpu = NR_CPUS;
for (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) { for (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) {
...@@ -1619,7 +1619,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, ...@@ -1619,7 +1619,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
continue; continue;
BUG_ON(cpu > nr_cpu_ids || !cpu_possible(cpu)); BUG_ON(cpu > nr_cpu_ids || !cpu_possible(cpu));
BUG_ON(unit_map[cpu] != NR_CPUS); BUG_ON(unit_map[cpu] != UINT_MAX);
unit_map[cpu] = unit + i; unit_map[cpu] = unit + i;
unit_off[cpu] = gi->base_offset + i * ai->unit_size; unit_off[cpu] = gi->base_offset + i * ai->unit_size;
...@@ -1632,7 +1632,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, ...@@ -1632,7 +1632,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
pcpu_nr_units = unit; pcpu_nr_units = unit;
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
BUG_ON(unit_map[cpu] == NR_CPUS); BUG_ON(unit_map[cpu] == UINT_MAX);
pcpu_nr_groups = ai->nr_groups; pcpu_nr_groups = ai->nr_groups;
pcpu_group_offsets = group_offsets; pcpu_group_offsets = group_offsets;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment