All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] umh: Optimize 'proc_cap_handler()'
@ 2017-10-20 19:33 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2017-10-20 19:33 UTC (permalink / raw)
  To: mcgrof; +Cc: linux-kernel, kernel-janitors, Christophe JAILLET

If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 kernel/umh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/umh.c b/kernel/umh.c
index 6ff9905250ff..18e5fa4b0e71 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -537,14 +537,14 @@ static int proc_cap_handler(struct ctl_table *table, int write,
 	/*
 	 * Drop everything not in the new_cap (but don't add things)
 	 */
-	spin_lock(&umh_sysctl_lock);
 	if (write) {
+		spin_lock(&umh_sysctl_lock);
 		if (table->data == CAP_BSET)
 			usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
 		if (table->data == CAP_PI)
 			usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
+		spin_unlock(&umh_sysctl_lock);
 	}
-	spin_unlock(&umh_sysctl_lock);
 
 	return 0;
 }
-- 
2.14.1

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

* [PATCH] umh: Optimize 'proc_cap_handler()'
@ 2017-10-20 19:33 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2017-10-20 19:33 UTC (permalink / raw)
  To: mcgrof; +Cc: linux-kernel, kernel-janitors, Christophe JAILLET

If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 kernel/umh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/umh.c b/kernel/umh.c
index 6ff9905250ff..18e5fa4b0e71 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -537,14 +537,14 @@ static int proc_cap_handler(struct ctl_table *table, int write,
 	/*
 	 * Drop everything not in the new_cap (but don't add things)
 	 */
-	spin_lock(&umh_sysctl_lock);
 	if (write) {
+		spin_lock(&umh_sysctl_lock);
 		if (table->data = CAP_BSET)
 			usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
 		if (table->data = CAP_PI)
 			usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
+		spin_unlock(&umh_sysctl_lock);
 	}
-	spin_unlock(&umh_sysctl_lock);
 
 	return 0;
 }
-- 
2.14.1


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

* Re: [PATCH] umh: Optimize 'proc_cap_handler()'
  2017-10-20 19:33 ` Christophe JAILLET
@ 2017-11-08  1:02   ` Luis R. Rodriguez
  -1 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2017-11-08  1:02 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: mcgrof, linux-kernel, kernel-janitors

On Fri, Oct 20, 2017 at 09:33:31PM +0200, Christophe JAILLET wrote:
> If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Sorry for the delay, I was travelling and will start nose diving now.  I hope
to have a concrete review and answer by tomorrow. Sorry for the two week delay
on the review and thanks for the patch!

  Luis

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

* Re: [PATCH] umh: Optimize 'proc_cap_handler()'
@ 2017-11-08  1:02   ` Luis R. Rodriguez
  0 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2017-11-08  1:02 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: mcgrof, linux-kernel, kernel-janitors

On Fri, Oct 20, 2017 at 09:33:31PM +0200, Christophe JAILLET wrote:
> If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Sorry for the delay, I was travelling and will start nose diving now.  I hope
to have a concrete review and answer by tomorrow. Sorry for the two week delay
on the review and thanks for the patch!

  Luis

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

* Re: [PATCH] umh: Optimize 'proc_cap_handler()'
  2017-10-20 19:33 ` Christophe JAILLET
@ 2017-11-10 23:51   ` Luis R. Rodriguez
  -1 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2017-11-10 23:51 UTC (permalink / raw)
  To: Christophe JAILLET, akpm; +Cc: mcgrof, linux-kernel, kernel-janitors

On Fri, Oct 20, 2017 at 09:33:31PM +0200, Christophe JAILLET wrote:
> If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thanks for the patch!

Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>

I'll bounce a copy to Andrew for integration next.

  Luis


> ---
>  kernel/umh.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/umh.c b/kernel/umh.c
> index 6ff9905250ff..18e5fa4b0e71 100644
> --- a/kernel/umh.c
> +++ b/kernel/umh.c
> @@ -537,14 +537,14 @@ static int proc_cap_handler(struct ctl_table *table, int write,
>  	/*
>  	 * Drop everything not in the new_cap (but don't add things)
>  	 */
> -	spin_lock(&umh_sysctl_lock);
>  	if (write) {
> +		spin_lock(&umh_sysctl_lock);
>  		if (table->data == CAP_BSET)
>  			usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
>  		if (table->data == CAP_PI)
>  			usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
> +		spin_unlock(&umh_sysctl_lock);
>  	}
> -	spin_unlock(&umh_sysctl_lock);
>  
>  	return 0;
>  }
> -- 
> 2.14.1
> 
> 

-- 
Luis Rodriguez, SUSE LINUX GmbH
Maxfeldstrasse 5; D-90409 Nuernberg

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

* Re: [PATCH] umh: Optimize 'proc_cap_handler()'
@ 2017-11-10 23:51   ` Luis R. Rodriguez
  0 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2017-11-10 23:51 UTC (permalink / raw)
  To: Christophe JAILLET, akpm; +Cc: mcgrof, linux-kernel, kernel-janitors

On Fri, Oct 20, 2017 at 09:33:31PM +0200, Christophe JAILLET wrote:
> If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thanks for the patch!

Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>

I'll bounce a copy to Andrew for integration next.

  Luis


> ---
>  kernel/umh.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/umh.c b/kernel/umh.c
> index 6ff9905250ff..18e5fa4b0e71 100644
> --- a/kernel/umh.c
> +++ b/kernel/umh.c
> @@ -537,14 +537,14 @@ static int proc_cap_handler(struct ctl_table *table, int write,
>  	/*
>  	 * Drop everything not in the new_cap (but don't add things)
>  	 */
> -	spin_lock(&umh_sysctl_lock);
>  	if (write) {
> +		spin_lock(&umh_sysctl_lock);
>  		if (table->data = CAP_BSET)
>  			usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
>  		if (table->data = CAP_PI)
>  			usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
> +		spin_unlock(&umh_sysctl_lock);
>  	}
> -	spin_unlock(&umh_sysctl_lock);
>  
>  	return 0;
>  }
> -- 
> 2.14.1
> 
> 

-- 
Luis Rodriguez, SUSE LINUX GmbH
Maxfeldstrasse 5; D-90409 Nuernberg

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

end of thread, other threads:[~2017-11-10 23:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20 19:33 [PATCH] umh: Optimize 'proc_cap_handler()' Christophe JAILLET
2017-10-20 19:33 ` Christophe JAILLET
2017-11-08  1:02 ` Luis R. Rodriguez
2017-11-08  1:02   ` Luis R. Rodriguez
2017-11-10 23:51 ` Luis R. Rodriguez
2017-11-10 23:51   ` Luis R. Rodriguez

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.