All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Stephane Eranian <eranian@google.com>, Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 3/7] perf, x86: Extract DS alloc/free functions
Date: Tue, 19 Oct 2010 15:42:59 +0200	[thread overview]
Message-ID: <20101019134808.304495776@chello.nl> (raw)
In-Reply-To: 20101019134256.087045503@chello.nl

[-- Attachment #1: perf-perf-event-improve-ds-4.patch --]
[-- Type: text/plain, Size: 1809 bytes --]

Again, mostly a cleanup to unclutter the reserve_ds_buffer() code.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c |   40 +++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 14 deletions(-)

Index: linux-2.6/arch/x86/kernel/cpu/perf_event_intel_ds.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ linux-2.6/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -148,6 +148,30 @@ static void release_bts_buffer(int cpu)
 	ds->bts_buffer_base = 0;
 }
 
+static int alloc_ds_buffer(int cpu)
+{
+	struct debug_store *ds;
+
+	ds = kzalloc(sizeof(*ds), GFP_KERNEL);
+	if (unlikely(!ds))
+		return -ENOMEM;
+
+	per_cpu(cpu_hw_events, cpu).ds = ds;
+
+	return 0;
+}
+
+static void release_ds_buffer(int cpu)
+{
+	struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
+
+	if (!ds)
+		return;
+
+	per_cpu(cpu_hw_events, cpu).ds = NULL;
+	kfree(ds);
+}
+
 static void release_ds_buffers(void)
 {
 	int cpu;
@@ -160,16 +184,9 @@ static void release_ds_buffers(void)
 		fini_debug_store_on_cpu(cpu);
 
 	for_each_possible_cpu(cpu) {
-		struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
-
-		if (!ds)
-			continue;
-
 		release_pebs_buffer(cpu);
 		release_bts_buffer(cpu);
-
-		per_cpu(cpu_hw_events, cpu).ds = NULL;
-		kfree(ds);
+		release_ds_buffer(cpu);
 	}
 	put_online_cpus();
 }
@@ -184,13 +201,8 @@ static int reserve_ds_buffers(void)
 	get_online_cpus();
 
 	for_each_possible_cpu(cpu) {
-		struct debug_store *ds;
-
-		err = -ENOMEM;
-		ds = kzalloc(sizeof(*ds), GFP_KERNEL);
-		if (unlikely(!ds))
+		if (alloc_ds_buffer(cpu))
 			break;
-		per_cpu(cpu_hw_events, cpu).ds = ds;
 
 		if (alloc_bts_buffer(cpu))
 			break;



  parent reply	other threads:[~2010-10-19 13:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19 13:42 [PATCH 0/7] perf,x86: PEBS/BTS buffer allocation changes Peter Zijlstra
2010-10-19 13:42 ` [PATCH 1/7] perf, x86: Extract PEBS/BTS buffer free routines Peter Zijlstra
2010-10-22 13:02   ` [tip:perf/urgent] " tip-bot for Peter Zijlstra
2010-10-19 13:42 ` [PATCH 2/7] perf, x86: Extract PEBS/BTS allocation functions Peter Zijlstra
2010-10-22 13:02   ` [tip:perf/urgent] " tip-bot for Peter Zijlstra
2010-10-19 13:42 ` Peter Zijlstra [this message]
2010-10-22 13:03   ` [tip:perf/urgent] perf, x86: Extract DS alloc/free functions tip-bot for Peter Zijlstra
2010-10-19 13:43 ` [PATCH 4/7] perf, x86: Fixup the precise_ip computation Peter Zijlstra
2010-10-22 13:03   ` [tip:perf/urgent] " tip-bot for Peter Zijlstra
2010-10-22 13:04   ` [tip:perf/urgent] perf, x86: Less disastrous PEBS/BTS buffer allocation failure tip-bot for Peter Zijlstra
2010-10-19 13:43 ` [PATCH 5/7] " Peter Zijlstra
2010-10-19 13:43 ` [PATCH 6/7] perf, x86: Clean up reserve_ds_buffers() signature Peter Zijlstra
2010-10-22 13:04   ` [tip:perf/urgent] " tip-bot for Peter Zijlstra
2010-10-19 13:43 ` [PATCH 7/7] perf, x86: Use NUMA aware allocations for PEBS/BTS/DS allocations Peter Zijlstra
2010-10-22 13:04   ` [tip:perf/urgent] " tip-bot for Peter Zijlstra
2010-10-21 11:35 ` [PATCH 0/7] perf,x86: PEBS/BTS buffer allocation changes Peter Zijlstra
2010-10-21 11:45   ` Stephane Eranian
2010-10-21 14:30   ` Stephane Eranian
2010-10-21 14:34     ` Peter Zijlstra
2010-10-21 14:35       ` Stephane Eranian

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=20101019134808.304495776@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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.