aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/perf_event.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 8d61d292f719..6ae62186dd0c 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2320,6 +2320,19 @@ perf_mmap_to_page(struct perf_mmap_data *data, unsigned long pgoff)
2320 return virt_to_page(data->data_pages[pgoff - 1]); 2320 return virt_to_page(data->data_pages[pgoff - 1]);
2321} 2321}
2322 2322
2323static void *perf_mmap_alloc_page(int cpu)
2324{
2325 struct page *page;
2326 int node;
2327
2328 node = (cpu == -1) ? cpu : cpu_to_node(cpu);
2329 page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
2330 if (!page)
2331 return NULL;
2332
2333 return page_address(page);
2334}
2335
2323static struct perf_mmap_data * 2336static struct perf_mmap_data *
2324perf_mmap_data_alloc(struct perf_event *event, int nr_pages) 2337perf_mmap_data_alloc(struct perf_event *event, int nr_pages)
2325{ 2338{
@@ -2336,12 +2349,12 @@ perf_mmap_data_alloc(struct perf_event *event, int nr_pages)
2336 if (!data) 2349 if (!data)
2337 goto fail; 2350 goto fail;
2338 2351
2339 data->user_page = (void *)get_zeroed_page(GFP_KERNEL); 2352 data->user_page = perf_mmap_alloc_page(event->cpu);
2340 if (!data->user_page) 2353 if (!data->user_page)
2341 goto fail_user_page; 2354 goto fail_user_page;
2342 2355
2343 for (i = 0; i < nr_pages; i++) { 2356 for (i = 0; i < nr_pages; i++) {
2344 data->data_pages[i] = (void *)get_zeroed_page(GFP_KERNEL); 2357 data->data_pages[i] = perf_mmap_alloc_page(event->cpu);
2345 if (!data->data_pages[i]) 2358 if (!data->data_pages[i])
2346 goto fail_data_pages; 2359 goto fail_data_pages;
2347 } 2360 }