Skip to content

Commit

Permalink
percpu: fix trivial bugs in pcpu_build_alloc_info()
Browse files Browse the repository at this point in the history
Fix the following two trivial bugs in pcpu_build_alloc_info()

* we should memset group_cnt to 0 by size of group_cnt, not size of
  group_map (both are of the same size, so the bug isn't dangerous)

* we can delete useless variable group_cnt_max.

Signed-off-by: Pavel V. Panteleev <pp_84@mail.ru>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Pavel V. Panteleev authored and Tejun Heo committed Jun 17, 2010
1 parent 7e27d6e commit a92d3ff
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/percpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ struct pcpu_alloc_info * __init pcpu_build_alloc_info(
static int group_map[NR_CPUS] __initdata;
static int group_cnt[NR_CPUS] __initdata;
const size_t static_size = __per_cpu_end - __per_cpu_start;
int group_cnt_max = 0, nr_groups = 1, nr_units = 0;
int nr_groups = 1, nr_units = 0;
size_t size_sum, min_unit_size, alloc_size;
int upa, max_upa, uninitialized_var(best_upa); /* units_per_alloc */
int last_allocs, group, unit;
Expand All @@ -1096,7 +1096,7 @@ struct pcpu_alloc_info * __init pcpu_build_alloc_info(

/* this function may be called multiple times */
memset(group_map, 0, sizeof(group_map));
memset(group_cnt, 0, sizeof(group_map));
memset(group_cnt, 0, sizeof(group_cnt));

/*
* Determine min_unit_size, alloc_size and max_upa such that
Expand Down Expand Up @@ -1130,7 +1130,6 @@ struct pcpu_alloc_info * __init pcpu_build_alloc_info(
}
group_map[cpu] = group;
group_cnt[group]++;
group_cnt_max = max(group_cnt_max, group_cnt[group]);
}

/*
Expand Down

0 comments on commit a92d3ff

Please sign in to comment.