From: Eric Dumazet <dada1@cosmosbay.com>
To: Robert Richter <robert.richter@amd.com>,
Steven Rostedt <rostedt@redhat.com>
Cc: linux kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] ring_buffer: NUMA aware page allocations
Date: Mon, 12 Jan 2009 20:20:17 +0100 [thread overview]
Message-ID: <496B97F1.70200@cosmosbay.com> (raw)
Hi Robert & Steven
While browsing oprofile code in current tree, I discovered
drivers/oprofile/cpu_buffer.c was using new ring_buffer code.
Apparently we lost in the conversion NUMA allocations, unless
I am mistaken, since rb_allocate_pages() uses plain
__get_free_page(GFP_KERNEL) calls to allocate pages.
All "buffer_page" structs are allocated with kzalloc_node(),
but not the pages themselves.
Thank you
[PATCH] ring_buffer: NUMA aware page allocations
rb_allocate_pages() & ring_buffer_resize() should use alloc_pages_node()
instead of __get_free_page() to allocate pages.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 8b0daf0..feb8482 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -333,21 +333,22 @@ static int rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
{
struct list_head *head = &cpu_buffer->pages;
struct buffer_page *bpage, *tmp;
- unsigned long addr;
+ struct page *page;
LIST_HEAD(pages);
unsigned i;
+ int node = cpu_to_node(cpu_buffer->cpu);
for (i = 0; i < nr_pages; i++) {
bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()),
- GFP_KERNEL, cpu_to_node(cpu_buffer->cpu));
+ GFP_KERNEL, node);
if (!bpage)
goto free_pages;
list_add(&bpage->list, &pages);
- addr = __get_free_page(GFP_KERNEL);
- if (!addr)
+ page = alloc_pages_node(node, GFP_KERNEL, 0);
+ if (!page)
goto free_pages;
- bpage->page = (void *)addr;
+ bpage->page = page_address(page);
rb_init_page(bpage->page);
}
@@ -605,7 +606,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
unsigned nr_pages, rm_pages, new_pages;
struct buffer_page *bpage, *tmp;
unsigned long buffer_size;
- unsigned long addr;
+ struct page *page;
LIST_HEAD(pages);
int i, cpu;
@@ -663,17 +664,19 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
new_pages = nr_pages - buffer->pages;
for_each_buffer_cpu(buffer, cpu) {
+ int node = cpu_to_node(cpu);
+
for (i = 0; i < new_pages; i++) {
bpage = kzalloc_node(ALIGN(sizeof(*bpage),
cache_line_size()),
- GFP_KERNEL, cpu_to_node(cpu));
+ GFP_KERNEL, node);
if (!bpage)
goto free_pages;
list_add(&bpage->list, &pages);
- addr = __get_free_page(GFP_KERNEL);
- if (!addr)
+ page = alloc_pages_node(node, GFP_KERNEL, 0);
+ if (!page)
goto free_pages;
- bpage->page = (void *)addr;
+ bpage->page = page_address(page);
rb_init_page(bpage->page);
}
}
next reply other threads:[~2009-01-12 19:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-12 19:20 Eric Dumazet [this message]
2009-01-13 1:29 ` [PATCH] ring_buffer: NUMA aware page allocations Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=496B97F1.70200@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.richter@amd.com \
--cc=rostedt@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.