All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
@ 2017-08-11 20:05 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-08-11 20:05 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Michael Ellerman, Madhavan Srinivasan,
	Hemant Kumar, linuxppc-dev, kernel-janitors

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 <dan.carpenter@oracle.com>
---
I also don't understand how the &nest_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(&nest_init_lock);
+		mutex_lock(&nest_init_lock);
 		if (nest_pmus = 1) {
 			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
 			kfree(nest_imc_refc);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
@ 2017-08-11 20:05 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-08-11 20:05 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Michael Ellerman, Madhavan Srinivasan,
	Hemant Kumar, linuxppc-dev, kernel-janitors

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 <dan.carpenter@oracle.com>
---
I also don't understand how the &nest_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(&nest_init_lock);
+		mutex_lock(&nest_init_lock);
 		if (nest_pmus == 1) {
 			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
 			kfree(nest_imc_refc);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
  2017-08-11 20:05 ` Dan Carpenter
@ 2017-08-14  3:30   ` Michael Ellerman
  -1 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2017-08-14  3:30 UTC (permalink / raw)
  To: Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Madhavan Srinivasan, Hemant Kumar, linuxppc-dev,
	kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> 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 <dan.carpenter@oracle.com>
> ---
> I also don't understand how the &nest_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(&nest_init_lock);
> +		mutex_lock(&nest_init_lock);
>  		if (nest_pmus = 1) {
>  			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
>  			kfree(nest_imc_refc);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
@ 2017-08-14  3:30   ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2017-08-14  3:30 UTC (permalink / raw)
  To: Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Madhavan Srinivasan, Hemant Kumar, linuxppc-dev,
	kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> 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 <dan.carpenter@oracle.com>
> ---
> I also don't understand how the &nest_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(&nest_init_lock);
> +		mutex_lock(&nest_init_lock);
>  		if (nest_pmus == 1) {
>  			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
>  			kfree(nest_imc_refc);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
  2017-08-11 20:05 ` Dan Carpenter
@ 2017-08-14  3:59   ` Madhavan Srinivasan
  -1 siblings, 0 replies; 10+ messages in thread
From: Madhavan Srinivasan @ 2017-08-14  3:58 UTC (permalink / raw)
  To: Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Michael Ellerman, Hemant Kumar, linuxppc-dev,
	kernel-janitors



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 Srinivasan <maddy@linux.vnet.ibm.com>

nest_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 <dan.carpenter@oracle.com>
> ---
> I also don't understand how the &nest_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(&nest_init_lock);
> +		mutex_lock(&nest_init_lock);
>   		if (nest_pmus == 1) {
>   			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
>   			kfree(nest_imc_refc);
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
@ 2017-08-14  3:59   ` Madhavan Srinivasan
  0 siblings, 0 replies; 10+ messages in thread
From: Madhavan Srinivasan @ 2017-08-14  3:59 UTC (permalink / raw)
  To: Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Michael Ellerman, Hemant Kumar, linuxppc-dev,
	kernel-janitors



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 Srinivasan <maddy@linux.vnet.ibm.com>

nest_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 <dan.carpenter@oracle.com>
> ---
> I also don't understand how the &nest_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(&nest_init_lock);
> +		mutex_lock(&nest_init_lock);
>   		if (nest_pmus = 1) {
>   			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
>   			kfree(nest_imc_refc);
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
  2017-08-14  3:30   ` Michael Ellerman
@ 2017-08-14  4:12     ` Madhavan Srinivasan
  -1 siblings, 0 replies; 10+ messages in thread
From: Madhavan Srinivasan @ 2017-08-14  4:00 UTC (permalink / raw)
  To: Michael Ellerman, Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Hemant Kumar, linuxppc-dev, kernel-janitors



On Monday 14 August 2017 09:00 AM, Michael Ellerman wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
>
>> 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 <dan.carpenter@oracle.com>
>> ---
>> I also don't understand how the &nest_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(&nest_init_lock);
>> +		mutex_lock(&nest_init_lock);
>>   		if (nest_pmus == 1) {
>>   			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
>>   			kfree(nest_imc_refc);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
@ 2017-08-14  4:12     ` Madhavan Srinivasan
  0 siblings, 0 replies; 10+ messages in thread
From: Madhavan Srinivasan @ 2017-08-14  4:12 UTC (permalink / raw)
  To: Michael Ellerman, Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Paul Mackerras, Hemant Kumar, linuxppc-dev, kernel-janitors



On Monday 14 August 2017 09:00 AM, Michael Ellerman wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
>
>> 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 <dan.carpenter@oracle.com>
>> ---
>> I also don't understand how the &nest_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(&nest_init_lock);
>> +		mutex_lock(&nest_init_lock);
>>   		if (nest_pmus = 1) {
>>   			cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
>>   			kfree(nest_imc_refc);


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
  2017-08-11 20:05 ` Dan Carpenter
@ 2017-08-16 12:29   ` Michael Ellerman
  -1 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2017-08-16 12:29 UTC (permalink / raw)
  To: Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Madhavan Srinivasan, kernel-janitors, linuxppc-dev,
	Paul Mackerras, Hemant Kumar

On Fri, 2017-08-11 at 20:05:41 UTC, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b3376dcc6c62452fe24e76d8fc35bb

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free()
@ 2017-08-16 12:29   ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2017-08-16 12:29 UTC (permalink / raw)
  To: Dan Carpenter, Benjamin Herrenschmidt, Anju T Sudhakar
  Cc: Madhavan Srinivasan, kernel-janitors, linuxppc-dev,
	Paul Mackerras, Hemant Kumar

On Fri, 2017-08-11 at 20:05:41 UTC, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b3376dcc6c62452fe24e76d8fc35bb

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-08-16 12:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-11 20:05 [PATCH] powerpc/perf: double unlock bug in imc_common_cpuhp_mem_free() Dan Carpenter
2017-08-11 20:05 ` Dan Carpenter
2017-08-14  3:30 ` Michael Ellerman
2017-08-14  3:30   ` Michael Ellerman
2017-08-14  4:00   ` Madhavan Srinivasan
2017-08-14  4:12     ` Madhavan Srinivasan
2017-08-14  3:58 ` Madhavan Srinivasan
2017-08-14  3:59   ` Madhavan Srinivasan
2017-08-16 12:29 ` Michael Ellerman
2017-08-16 12:29   ` Michael Ellerman

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.