linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex ***
@ 2016-06-08  7:50 Binoy Jayan
  2016-06-08  7:50 ` [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion Binoy Jayan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Binoy Jayan @ 2016-06-08  7:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Oleg Drokin, Andreas Dilger, lustre-devel
  Cc: Arnd Bergmann, driverdev-devel, linux-kernel, Binoy Jayan

Hi,

These are a set of patches which removes semaphores from:

drivers/staging/lustre  (lnet)

These are part of a bigger effort to eliminate all semaphores 
from the linux kernel.

They build correctly (individually and as a whole).

Thanks,
Binoy


Binoy Jayan (2):
  staging: lustre: lloop_device: Replace semaphore lo_sem with
    completion
  staging: lustre: lnet: Replace semaphore ln_rc_signal with completion

 drivers/staging/lustre/include/linux/lnet/lib-types.h |  3 ++-
 drivers/staging/lustre/lnet/lnet/router.c             |  9 +++++----
 drivers/staging/lustre/lustre/llite/lloop.c           | 14 +++++++-------
 3 files changed, 14 insertions(+), 12 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion
  2016-06-08  7:50 [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** Binoy Jayan
@ 2016-06-08  7:50 ` Binoy Jayan
  2016-06-08 17:49   ` James Simmons
  2016-06-08  7:50 ` [PATCH 2/2] staging: lustre: lnet: Replace semaphore ln_rc_signal " Binoy Jayan
  2016-06-08 17:46 ` [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** James Simmons
  2 siblings, 1 reply; 6+ messages in thread
From: Binoy Jayan @ 2016-06-08  7:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Oleg Drokin, Andreas Dilger, lustre-devel
  Cc: Arnd Bergmann, driverdev-devel, linux-kernel, Binoy Jayan

The semaphore 'lo_sem' in lloop_device is used as completion, so it
should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/staging/lustre/lustre/llite/lloop.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c
index 813a9a3..90b31ba 100644
--- a/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/drivers/staging/lustre/lustre/llite/lloop.c
@@ -131,7 +131,7 @@ struct lloop_device {
 	struct bio		*lo_bio;
 	struct bio		*lo_biotail;
 	int			lo_state;
-	struct semaphore	lo_sem;
+	struct completion	lo_comp;
 	struct mutex		lo_ctl_mutex;
 	atomic_t	 lo_pending;
 	wait_queue_head_t	  lo_bh_wait;
@@ -423,9 +423,9 @@ static int loop_thread(void *data)
 	lo->lo_pvec.ldp_offsets = lo->lo_requests[0].lrd_offsets;
 
 	/*
-	 * up sem, we are running
+	 * signal completion, we are running
 	 */
-	up(&lo->lo_sem);
+	complete(&lo->lo_comp);
 
 	for (;;) {
 		wait_event(lo->lo_bh_wait, loop_active(lo));
@@ -466,7 +466,7 @@ static int loop_thread(void *data)
 	cl_env_put(env, &refcheck);
 
 out:
-	up(&lo->lo_sem);
+	complete(&lo->lo_comp);
 	return ret;
 }
 
@@ -539,7 +539,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
 	set_blocksize(bdev, lo->lo_blocksize);
 
 	kthread_run(loop_thread, lo, "lloop%d", lo->lo_number);
-	down(&lo->lo_sem);
+	wait_for_completion(&lo->lo_comp);
 	return 0;
 
 out:
@@ -568,7 +568,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
 	spin_unlock_irq(&lo->lo_lock);
 	wake_up(&lo->lo_bh_wait);
 
-	down(&lo->lo_sem);
+	wait_for_completion(&lo->lo_comp);
 	lo->lo_backing_file = NULL;
 	lo->lo_device = NULL;
 	lo->lo_offset = 0;
@@ -821,7 +821,7 @@ static int __init lloop_init(void)
 			goto out_mem4;
 
 		mutex_init(&lo->lo_ctl_mutex);
-		sema_init(&lo->lo_sem, 0);
+		init_completion(&lo->lo_comp);
 		init_waitqueue_head(&lo->lo_bh_wait);
 		lo->lo_number = i;
 		spin_lock_init(&lo->lo_lock);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* [PATCH 2/2] staging: lustre: lnet: Replace semaphore ln_rc_signal with completion
  2016-06-08  7:50 [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** Binoy Jayan
  2016-06-08  7:50 ` [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion Binoy Jayan
@ 2016-06-08  7:50 ` Binoy Jayan
  2016-06-08 22:52   ` James Simmons
  2016-06-08 17:46 ` [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** James Simmons
  2 siblings, 1 reply; 6+ messages in thread
From: Binoy Jayan @ 2016-06-08  7:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Oleg Drokin, Andreas Dilger, lustre-devel
  Cc: Arnd Bergmann, driverdev-devel, linux-kernel, Binoy Jayan

The semaphore ln_rc_signal is used as completion, so convert it to
struct completion.  Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/staging/lustre/include/linux/lnet/lib-types.h | 3 ++-
 drivers/staging/lustre/lnet/lnet/router.c             | 9 +++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index 24c4a08..7967b01 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -38,6 +38,7 @@
 #include <linux/kthread.h>
 #include <linux/uio.h>
 #include <linux/types.h>
+#include <linux/completion.h>
 
 #include "types.h"
 #include "lnetctl.h"
@@ -610,7 +611,7 @@ typedef struct {
 	/* rcd ready for free */
 	struct list_head		  ln_rcd_zombie;
 	/* serialise startup/shutdown */
-	struct semaphore		  ln_rc_signal;
+	struct completion		  ln_rc_signal;
 
 	struct mutex			  ln_api_mutex;
 	struct mutex			  ln_lnd_mutex;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index b01dc42..0635432 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -18,6 +18,7 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
+#include <linux/completion.h>
 #include "../../include/linux/lnet/lib-lnet.h"
 
 #define LNET_NRB_TINY_MIN	512	/* min value for each CPT */
@@ -1065,7 +1066,7 @@ lnet_router_checker_start(void)
 		return -EINVAL;
 	}
 
-	sema_init(&the_lnet.ln_rc_signal, 0);
+	init_completion(&the_lnet.ln_rc_signal);
 
 	rc = LNetEQAlloc(0, lnet_router_checker_event, &the_lnet.ln_rc_eqh);
 	if (rc) {
@@ -1079,7 +1080,7 @@ lnet_router_checker_start(void)
 		rc = PTR_ERR(task);
 		CERROR("Can't start router checker thread: %d\n", rc);
 		/* block until event callback signals exit */
-		down(&the_lnet.ln_rc_signal);
+		wait_for_completion(&the_lnet.ln_rc_signal);
 		rc = LNetEQFree(the_lnet.ln_rc_eqh);
 		LASSERT(!rc);
 		the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
@@ -1112,7 +1113,7 @@ lnet_router_checker_stop(void)
 	wake_up(&the_lnet.ln_rc_waitq);
 
 	/* block until event callback signals exit */
-	down(&the_lnet.ln_rc_signal);
+	wait_for_completion(&the_lnet.ln_rc_signal);
 	LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
 
 	rc = LNetEQFree(the_lnet.ln_rc_eqh);
@@ -1295,7 +1296,7 @@ rescan:
 	lnet_prune_rc_data(1); /* wait for UNLINK */
 
 	the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
-	up(&the_lnet.ln_rc_signal);
+	complete(&the_lnet.ln_rc_signal);
 	/* The unlink event callback will signal final completion */
 	return 0;
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex ***
  2016-06-08  7:50 [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** Binoy Jayan
  2016-06-08  7:50 ` [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion Binoy Jayan
  2016-06-08  7:50 ` [PATCH 2/2] staging: lustre: lnet: Replace semaphore ln_rc_signal " Binoy Jayan
@ 2016-06-08 17:46 ` James Simmons
  2 siblings, 0 replies; 6+ messages in thread
From: James Simmons @ 2016-06-08 17:46 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Greg Kroah-Hartman, Oleg Drokin, Andreas Dilger, lustre-devel,
	driverdev-devel, linux-kernel, Arnd Bergmann


> Hi,
> 
> These are a set of patches which removes semaphores from:
> 
> drivers/staging/lustre  (lnet)
> 
> These are part of a bigger effort to eliminate all semaphores 
> from the linux kernel.
> 
> They build correctly (individually and as a whole).
> 
> Thanks,
> Binoy

I just finishing running the latest staging tree againt our
test suite so I'm going to look to testing your patch next.
 
> Binoy Jayan (2):
>   staging: lustre: lloop_device: Replace semaphore lo_sem with
>     completion

This patch can be dropped. I will be shortly submitting a patch
to remove the lloop back device. 

>   staging: lustre: lnet: Replace semaphore ln_rc_signal with completion

Will send a ack once I'm done testing.

>  drivers/staging/lustre/include/linux/lnet/lib-types.h |  3 ++-
>  drivers/staging/lustre/lnet/lnet/router.c             |  9 +++++----
>  drivers/staging/lustre/lustre/llite/lloop.c           | 14 +++++++-------
>  3 files changed, 14 insertions(+), 12 deletions(-)
> 
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 

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

* Re: [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion
  2016-06-08  7:50 ` [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion Binoy Jayan
@ 2016-06-08 17:49   ` James Simmons
  0 siblings, 0 replies; 6+ messages in thread
From: James Simmons @ 2016-06-08 17:49 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Greg Kroah-Hartman, Oleg Drokin, Andreas Dilger, lustre-devel,
	driverdev-devel, linux-kernel, Arnd Bergmann


> The semaphore 'lo_sem' in lloop_device is used as completion, so it
> should be written as one. Semaphores are going away in the future.
> 
> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>

NAK. The lloop_device is about to get deleted.

> ---
>  drivers/staging/lustre/lustre/llite/lloop.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c
> index 813a9a3..90b31ba 100644
> --- a/drivers/staging/lustre/lustre/llite/lloop.c
> +++ b/drivers/staging/lustre/lustre/llite/lloop.c
> @@ -131,7 +131,7 @@ struct lloop_device {
>  	struct bio		*lo_bio;
>  	struct bio		*lo_biotail;
>  	int			lo_state;
> -	struct semaphore	lo_sem;
> +	struct completion	lo_comp;
>  	struct mutex		lo_ctl_mutex;
>  	atomic_t	 lo_pending;
>  	wait_queue_head_t	  lo_bh_wait;
> @@ -423,9 +423,9 @@ static int loop_thread(void *data)
>  	lo->lo_pvec.ldp_offsets = lo->lo_requests[0].lrd_offsets;
>  
>  	/*
> -	 * up sem, we are running
> +	 * signal completion, we are running
>  	 */
> -	up(&lo->lo_sem);
> +	complete(&lo->lo_comp);
>  
>  	for (;;) {
>  		wait_event(lo->lo_bh_wait, loop_active(lo));
> @@ -466,7 +466,7 @@ static int loop_thread(void *data)
>  	cl_env_put(env, &refcheck);
>  
>  out:
> -	up(&lo->lo_sem);
> +	complete(&lo->lo_comp);
>  	return ret;
>  }
>  
> @@ -539,7 +539,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
>  	set_blocksize(bdev, lo->lo_blocksize);
>  
>  	kthread_run(loop_thread, lo, "lloop%d", lo->lo_number);
> -	down(&lo->lo_sem);
> +	wait_for_completion(&lo->lo_comp);
>  	return 0;
>  
>  out:
> @@ -568,7 +568,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
>  	spin_unlock_irq(&lo->lo_lock);
>  	wake_up(&lo->lo_bh_wait);
>  
> -	down(&lo->lo_sem);
> +	wait_for_completion(&lo->lo_comp);
>  	lo->lo_backing_file = NULL;
>  	lo->lo_device = NULL;
>  	lo->lo_offset = 0;
> @@ -821,7 +821,7 @@ static int __init lloop_init(void)
>  			goto out_mem4;
>  
>  		mutex_init(&lo->lo_ctl_mutex);
> -		sema_init(&lo->lo_sem, 0);
> +		init_completion(&lo->lo_comp);
>  		init_waitqueue_head(&lo->lo_bh_wait);
>  		lo->lo_number = i;
>  		spin_lock_init(&lo->lo_lock);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 

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

* Re: [PATCH 2/2] staging: lustre: lnet: Replace semaphore ln_rc_signal with completion
  2016-06-08  7:50 ` [PATCH 2/2] staging: lustre: lnet: Replace semaphore ln_rc_signal " Binoy Jayan
@ 2016-06-08 22:52   ` James Simmons
  0 siblings, 0 replies; 6+ messages in thread
From: James Simmons @ 2016-06-08 22:52 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Greg Kroah-Hartman, Oleg Drokin, Andreas Dilger, lustre-devel,
	driverdev-devel, linux-kernel, Arnd Bergmann


> The semaphore ln_rc_signal is used as completion, so convert it to
> struct completion.  Semaphores are going away in the future.
> 
> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>

No problems in testing.

Acked-by: James Simmons <jsimmons@infradead.org>

> ---
>  drivers/staging/lustre/include/linux/lnet/lib-types.h | 3 ++-
>  drivers/staging/lustre/lnet/lnet/router.c             | 9 +++++----
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
> index 24c4a08..7967b01 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
> @@ -38,6 +38,7 @@
>  #include <linux/kthread.h>
>  #include <linux/uio.h>
>  #include <linux/types.h>
> +#include <linux/completion.h>
>  
>  #include "types.h"
>  #include "lnetctl.h"
> @@ -610,7 +611,7 @@ typedef struct {
>  	/* rcd ready for free */
>  	struct list_head		  ln_rcd_zombie;
>  	/* serialise startup/shutdown */
> -	struct semaphore		  ln_rc_signal;
> +	struct completion		  ln_rc_signal;
>  
>  	struct mutex			  ln_api_mutex;
>  	struct mutex			  ln_lnd_mutex;
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index b01dc42..0635432 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #define DEBUG_SUBSYSTEM S_LNET
> +#include <linux/completion.h>
>  #include "../../include/linux/lnet/lib-lnet.h"
>  
>  #define LNET_NRB_TINY_MIN	512	/* min value for each CPT */
> @@ -1065,7 +1066,7 @@ lnet_router_checker_start(void)
>  		return -EINVAL;
>  	}
>  
> -	sema_init(&the_lnet.ln_rc_signal, 0);
> +	init_completion(&the_lnet.ln_rc_signal);
>  
>  	rc = LNetEQAlloc(0, lnet_router_checker_event, &the_lnet.ln_rc_eqh);
>  	if (rc) {
> @@ -1079,7 +1080,7 @@ lnet_router_checker_start(void)
>  		rc = PTR_ERR(task);
>  		CERROR("Can't start router checker thread: %d\n", rc);
>  		/* block until event callback signals exit */
> -		down(&the_lnet.ln_rc_signal);
> +		wait_for_completion(&the_lnet.ln_rc_signal);
>  		rc = LNetEQFree(the_lnet.ln_rc_eqh);
>  		LASSERT(!rc);
>  		the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
> @@ -1112,7 +1113,7 @@ lnet_router_checker_stop(void)
>  	wake_up(&the_lnet.ln_rc_waitq);
>  
>  	/* block until event callback signals exit */
> -	down(&the_lnet.ln_rc_signal);
> +	wait_for_completion(&the_lnet.ln_rc_signal);
>  	LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
>  
>  	rc = LNetEQFree(the_lnet.ln_rc_eqh);
> @@ -1295,7 +1296,7 @@ rescan:
>  	lnet_prune_rc_data(1); /* wait for UNLINK */
>  
>  	the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
> -	up(&the_lnet.ln_rc_signal);
> +	complete(&the_lnet.ln_rc_signal);
>  	/* The unlink event callback will signal final completion */
>  	return 0;
>  }
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 

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

end of thread, other threads:[~2016-06-08 22:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08  7:50 [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** Binoy Jayan
2016-06-08  7:50 ` [PATCH 1/2] staging: lustre: lloop_device: Replace semaphore lo_sem with completion Binoy Jayan
2016-06-08 17:49   ` James Simmons
2016-06-08  7:50 ` [PATCH 2/2] staging: lustre: lnet: Replace semaphore ln_rc_signal " Binoy Jayan
2016-06-08 22:52   ` James Simmons
2016-06-08 17:46 ` [PATCH 0/2] *** staging: lustre: Replace semaphore lock with mutex *** James Simmons

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).