mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	eranian@google.com, tglx@linutronix.de,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] perf, x86: Fall back to vmalloc for BTS buffer allocation
Date: Tue,  9 Sep 2014 17:03:21 -0700	[thread overview]
Message-ID: <1410307401-12401-1-git-send-email-andi@firstfloor.org> (raw)

From: Andi Kleen <ak@linux.intel.com>

On my workstation the order 4 BTS buffer allocation fails regularly
after the system has been up for some time due to memory
fragmentation.

BTS is virtual memory, so we can just fall back to vmalloc
instead of failing.

Do this here.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 9dc4199..3cf5b74 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -312,8 +312,11 @@ static int alloc_bts_buffer(int cpu)
 
 	buffer = kzalloc_node(BTS_BUFFER_SIZE, GFP_KERNEL | __GFP_NOWARN, node);
 	if (unlikely(!buffer)) {
-		WARN_ONCE(1, "%s: BTS buffer allocation failure\n", __func__);
-		return -ENOMEM;
+		buffer = vmalloc_node(BTS_BUFFER_SIZE, node);
+		if (!buffer) {
+			WARN_ONCE(1, "%s: BTS buffer allocation failure\n", __func__);
+			return -ENOMEM;
+		}
 	}
 
 	max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE;
@@ -336,7 +339,7 @@ static void release_bts_buffer(int cpu)
 	if (!ds || !x86_pmu.bts)
 		return;
 
-	kfree((void *)(unsigned long)ds->bts_buffer_base);
+	kvfree((void *)(unsigned long)ds->bts_buffer_base);
 	ds->bts_buffer_base = 0;
 }
 
-- 
1.9.3


             reply	other threads:[~2014-09-10  0:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10  0:03 Andi Kleen [this message]
2014-09-10  7:57 ` Peter Zijlstra
2014-09-10 14:40   ` Andi Kleen
2014-09-10 16:35     ` Peter Zijlstra
2014-09-10 16:58       ` Peter Zijlstra
2014-09-10 18:27         ` Andi Kleen
2014-09-10 18:52           ` Peter Zijlstra

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=1410307401-12401-1-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome