Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Like Xu
On 2021/3/24 12:04, Namhyung Kim wrote: On Wed, Mar 24, 2021 at 12:47 PM Like Xu wrote: Hi Namhyung, On 2021/3/24 9:32, Namhyung Kim wrote: Hello, On Mon, Mar 22, 2021 at 3:14 PM Like Xu wrote: +void reserve_lbr_buffers(struct perf_event *event) +{ + struct kmem_cache *kmem_cache =

Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Namhyung Kim
On Wed, Mar 24, 2021 at 12:47 PM Like Xu wrote: > > Hi Namhyung, > > On 2021/3/24 9:32, Namhyung Kim wrote: > > Hello, > > > > On Mon, Mar 22, 2021 at 3:14 PM Like Xu wrote: > >> +void reserve_lbr_buffers(struct perf_event *event) > >> +{ > >> + struct kmem_cache *kmem_cache =

Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Like Xu
Hi Namhyung, On 2021/3/24 9:32, Namhyung Kim wrote: Hello, On Mon, Mar 22, 2021 at 3:14 PM Like Xu wrote: +void reserve_lbr_buffers(struct perf_event *event) +{ + struct kmem_cache *kmem_cache = x86_get_pmu()->task_ctx_cache; + struct cpu_hw_events *cpuc; + int cpu; + +

Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Namhyung Kim
Hello, On Mon, Mar 22, 2021 at 3:14 PM Like Xu wrote: > +void reserve_lbr_buffers(struct perf_event *event) > +{ > + struct kmem_cache *kmem_cache = x86_get_pmu()->task_ctx_cache; > + struct cpu_hw_events *cpuc; > + int cpu; > + > + if

Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Liang, Kan
On 3/23/2021 5:41 PM, Peter Zijlstra wrote: On Mon, Mar 22, 2021 at 02:06:33PM +0800, Like Xu wrote: diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 18df17129695..a4ce669cc78d 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -373,7 +373,7 @@

Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Peter Zijlstra
On Mon, Mar 22, 2021 at 02:06:33PM +0800, Like Xu wrote: > diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c > index 18df17129695..a4ce669cc78d 100644 > --- a/arch/x86/events/core.c > +++ b/arch/x86/events/core.c > @@ -373,7 +373,7 @@ set_ext_hw_attr(struct hw_perf_event *hwc, struct >

Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-23 Thread Liang, Kan
On 3/22/2021 2:06 AM, Like Xu wrote: If the kernel is compiled with the CONFIG_LOCKDEP option, the conditional might_sleep_if() deep in kmem_cache_alloc() will generate the following trace, and potentially cause a deadlock when another LBR event is added: [ 243.115549] BUG: sleeping

[PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region

2021-03-22 Thread Like Xu
If the kernel is compiled with the CONFIG_LOCKDEP option, the conditional might_sleep_if() deep in kmem_cache_alloc() will generate the following trace, and potentially cause a deadlock when another LBR event is added: [ 243.115549] BUG: sleeping function called from invalid context at