Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
On Monday 14 August 2017 09:00 AM, Michael Ellerman wrote: Dan Carpenterwrites: There is a typo so we call unlock instead of lock. Fixes: 885dcd709ba9 ("powerpc/perf: Add nest IMC PMU support") Signed-off-by: Dan Carpenter --- I also don't understand how the _imc_refc[node_id].lock works. Why can't we use ref->lock everywhere? They seem equivalent, and my static checker complains if we call the same lock different names. That looks like a bug to me, ie. we should always use ref. ok. will send a fix. Thanks Maddy Maddy? cheers diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c index 46cd912af060..52017f6eafd9 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -1124,7 +1124,7 @@ static void cleanup_all_thread_imc_memory(void) static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr) { if (pmu_ptr->domain == IMC_DOMAIN_NEST) { - mutex_unlock(_init_lock); + mutex_lock(_init_lock); if (nest_pmus == 1) { cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE); kfree(nest_imc_refc);
Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
On Saturday 12 August 2017 01:35 AM, Dan Carpenter wrote: There is a typo so we call unlock instead of lock. Reviewed-by: Madhavan Srinivasannest_imc_refc used to maintain list of perf sessions thats using the nest units currently. This is needed in turning off nest engine microcode when not in use. Yes will send a patch to fix ref->lock change. Thanks for fix Maddy Fixes: 885dcd709ba9 ("powerpc/perf: Add nest IMC PMU support") Signed-off-by: Dan Carpenter --- I also don't understand how the _imc_refc[node_id].lock works. Why can't we use ref->lock everywhere? They seem equivalent, and my static checker complains if we call the same lock different names. diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c index 46cd912af060..52017f6eafd9 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -1124,7 +1124,7 @@ static void cleanup_all_thread_imc_memory(void) static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr) { if (pmu_ptr->domain == IMC_DOMAIN_NEST) { - mutex_unlock(_init_lock); + mutex_lock(_init_lock); if (nest_pmus == 1) { cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE); kfree(nest_imc_refc);
Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
Dan Carpenterwrites: > There is a typo so we call unlock instead of lock. > > Fixes: 885dcd709ba9 ("powerpc/perf: Add nest IMC PMU support") > Signed-off-by: Dan Carpenter > --- > I also don't understand how the _imc_refc[node_id].lock works. Why > can't we use ref->lock everywhere? They seem equivalent, and my static > checker complains if we call the same lock different names. That looks like a bug to me, ie. we should always use ref. Maddy? cheers > diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c > index 46cd912af060..52017f6eafd9 100644 > --- a/arch/powerpc/perf/imc-pmu.c > +++ b/arch/powerpc/perf/imc-pmu.c > @@ -1124,7 +1124,7 @@ static void cleanup_all_thread_imc_memory(void) > static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr) > { > if (pmu_ptr->domain == IMC_DOMAIN_NEST) { > - mutex_unlock(_init_lock); > + mutex_lock(_init_lock); > if (nest_pmus == 1) { > > cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE); > kfree(nest_imc_refc);