Commit a19d35c1 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf: Optimize buffer placement by allocating buffers NUMA aware

Ensure cpu bound buffers live on the right NUMA node.
Suggested-by: default avatarStephane Eranian <eranian@google.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1274114880.5605.5236.camel@twins>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 00d1d0b0
...@@ -2320,6 +2320,19 @@ perf_mmap_to_page(struct perf_mmap_data *data, unsigned long pgoff) ...@@ -2320,6 +2320,19 @@ perf_mmap_to_page(struct perf_mmap_data *data, unsigned long pgoff)
return virt_to_page(data->data_pages[pgoff - 1]); return virt_to_page(data->data_pages[pgoff - 1]);
} }
static void *perf_mmap_alloc_page(int cpu)
{
struct page *page;
int node;
node = (cpu == -1) ? cpu : cpu_to_node(cpu);
page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
if (!page)
return NULL;
return page_address(page);
}
static struct perf_mmap_data * static struct perf_mmap_data *
perf_mmap_data_alloc(struct perf_event *event, int nr_pages) perf_mmap_data_alloc(struct perf_event *event, int nr_pages)
{ {
...@@ -2336,12 +2349,12 @@ perf_mmap_data_alloc(struct perf_event *event, int nr_pages) ...@@ -2336,12 +2349,12 @@ perf_mmap_data_alloc(struct perf_event *event, int nr_pages)
if (!data) if (!data)
goto fail; goto fail;
data->user_page = (void *)get_zeroed_page(GFP_KERNEL); data->user_page = perf_mmap_alloc_page(event->cpu);
if (!data->user_page) if (!data->user_page)
goto fail_user_page; goto fail_user_page;
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
data->data_pages[i] = (void *)get_zeroed_page(GFP_KERNEL); data->data_pages[i] = perf_mmap_alloc_page(event->cpu);
if (!data->data_pages[i]) if (!data->data_pages[i])
goto fail_data_pages; goto fail_data_pages;
} }
......
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