On Tue, Sep 09, 2014 at 05:03:21PM -0700, Andi Kleen wrote:
> From: Andi Kleen <[email protected]>
> 
> 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 <[email protected]>
> ---
>  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;

We did this once, and that blew up big time.

Even now, vmalloc_fault() has a very explicit:

  WARN_ON_ONCE(in_nmi());

So this isn't going to happen until you fix that.

Attachment: pgpigghSask6J.pgp
Description: PGP signature

Reply via email to