Skip to content

Commit

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

Pull percpu fixes from Tejun Heo:
 "One patch to fix a failure path in the alloc path.  The bug is
  dangerous but probably not too likely to actually trigger in the wild
  given that there hasn't been any report yet.

  The other two are low impact fixes"

* 'for-3.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
  percpu: free percpu allocation info for uniprocessor system
  percpu: perform tlb flush after pcpu_map_pages() failure
  percpu: fix pcpu_alloc_pages() failure path
  • Loading branch information
Linus Torvalds committed Sep 8, 2014
2 parents cfa7c64 + 3189edd commit 6a5c75c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 16 additions & 6 deletions mm/percpu-vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,31 @@ static int pcpu_alloc_pages(struct pcpu_chunk *chunk,
int page_start, int page_end)
{
const gfp_t gfp = GFP_KERNEL | __GFP_HIGHMEM | __GFP_COLD;
unsigned int cpu;
unsigned int cpu, tcpu;
int i;

for_each_possible_cpu(cpu) {
for (i = page_start; i < page_end; i++) {
struct page **pagep = &pages[pcpu_page_idx(cpu, i)];

*pagep = alloc_pages_node(cpu_to_node(cpu), gfp, 0);
if (!*pagep) {
pcpu_free_pages(chunk, pages, populated,
page_start, page_end);
return -ENOMEM;
}
if (!*pagep)
goto err;
}
}
return 0;

err:
while (--i >= page_start)
__free_page(pages[pcpu_page_idx(cpu, i)]);

for_each_possible_cpu(tcpu) {
if (tcpu == cpu)
break;
for (i = page_start; i < page_end; i++)
__free_page(pages[pcpu_page_idx(tcpu, i)]);
}
return -ENOMEM;
}

/**
Expand Down Expand Up @@ -263,6 +272,7 @@ static int pcpu_map_pages(struct pcpu_chunk *chunk,
__pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start),
page_end - page_start);
}
pcpu_post_unmap_tlb_flush(chunk, page_start, page_end);
return err;
}

Expand Down
2 changes: 2 additions & 0 deletions mm/percpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,8 @@ void __init setup_per_cpu_areas(void)

if (pcpu_setup_first_chunk(ai, fc) < 0)
panic("Failed to initialize percpu areas.");

pcpu_free_alloc_info(ai);
}

#endif /* CONFIG_SMP */
Expand Down

0 comments on commit 6a5c75c

Please sign in to comment.