Skip to content

Commit

Permalink
Merge branch 'for-3.4-fixes' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/tj/percpu

Pull percpu fixes from Tejun Heo:
 "This pull request contains two patches.  One is kmemleak annotation
  fix which isn't critical.  The other is kinda serious.

  Depending on NUMA topology, percpu allocator may end up assigning
  overlapping regions for the static percpu areas for different CPUs.
  While critical, the bug has been there for a very long time and only
  few configurations seem to be affected (NUMA configurations w/ no
  memory nodes for example) - so, while it's critical, it isn't exactly
  urgent."

* 'for-3.4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
  kmemleak: Fix the kmemleak tracking of the percpu areas with !SMP
  percpu: pcpu_embed_first_chunk() should free unused parts after all allocs are complete
  • Loading branch information
torvalds committed May 10, 2012
2 parents fda27be + 100d13c commit f3b2692
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mm/percpu.c
Expand Up @@ -1650,6 +1650,16 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
areas[group] = ptr;

base = min(ptr, base);
}

/*
* Copy data and free unused parts. This should happen after all
* allocations are complete; otherwise, we may end up with
* overlapping groups.
*/
for (group = 0; group < ai->nr_groups; group++) {
struct pcpu_group_info *gi = &ai->groups[group];
void *ptr = areas[group];

for (i = 0; i < gi->nr_units; i++, ptr += ai->unit_size) {
if (gi->cpu_map[i] == NR_CPUS) {
Expand Down Expand Up @@ -1885,6 +1895,8 @@ void __init setup_per_cpu_areas(void)
fc = __alloc_bootmem(unit_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
if (!ai || !fc)
panic("Failed to allocate memory for percpu areas.");
/* kmemleak tracks the percpu allocations separately */
kmemleak_free(fc);

ai->dyn_size = unit_size;
ai->unit_size = unit_size;
Expand Down

0 comments on commit f3b2692

Please sign in to comment.