From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754684Ab0EQQsa (ORCPT ); Mon, 17 May 2010 12:48:30 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:52031 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754098Ab0EQQs3 convert rfc822-to-8bit (ORCPT ); Mon, 17 May 2010 12:48:29 -0400 Subject: Re: [RFC] perf: perf record sets inherit by default From: Peter Zijlstra To: Stephane Eranian Cc: LKML , =?ISO-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Arnaldo Carvalho de Melo , mingo@elte.hu, Paul Mackerras , "David S. Miller" , perfmon2-devel@lists.sf.net In-Reply-To: References: <1273589282.1810.10.camel@laptop> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Date: Mon, 17 May 2010 18:48:00 +0200 Message-ID: <1274114880.5605.5236.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2010-05-17 at 16:25 +0200, Stephane Eranian wrote: > > Right, but I think the default of inherit is right, and once you do that > > you basically have to do the per-task-per-cpu thing, otherwise your > > fancy 16-way will start spending most of its time in cacheline bounces. > > > In that case, don't you think you should also ensure that the buffer is > allocated on the NUMA node of the designated per-thread-per-cpu? > I don't think it is the case today. Yeah, something like the below ought to do I guess.. Almost-Signed-off-by: Peter Zijlstra --- kernel/perf_event.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 9dbe8cd..85e2d32 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c @@ -2288,6 +2288,19 @@ perf_mmap_to_page(struct perf_mmap_data *data, unsigned long pgoff) 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 * perf_mmap_data_alloc(struct perf_event *event, int nr_pages) { @@ -2304,12 +2317,12 @@ perf_mmap_data_alloc(struct perf_event *event, int nr_pages) if (!data) goto fail; - data->user_page = (void *)get_zeroed_page(GFP_KERNEL); + data->user_page = perf_mmap_alloc_page(event->cpu); if (!data->user_page) goto fail_user_page; 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]) goto fail_data_pages; }