Re: [PATCH 4/4] rcutorture: use DEFINE_STATIC_SRCU()

2012-10-12 Thread Josh Triplett
On Sat, Oct 13, 2012 at 01:14:17AM +0800, Lai Jiangshan wrote:
> use DEFINE_STATIC_SRCU() to simplify the rcutorture.c
> 
> Signed-off-by: Lai Jiangshan 

Reviewed-by: Josh Triplett 

> ---
>  kernel/rcutorture.c |   41 ++---
>  1 files changed, 6 insertions(+), 35 deletions(-)
> 
> diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
> index 25b1503..7939edf 100644
> --- a/kernel/rcutorture.c
> +++ b/kernel/rcutorture.c
> @@ -332,7 +332,6 @@ rcu_stutter_wait(char *title)
>  
>  struct rcu_torture_ops {
>   void (*init)(void);
> - void (*cleanup)(void);
>   int (*readlock)(void);
>   void (*read_delay)(struct rcu_random_state *rrsp);
>   void (*readunlock)(int idx);
> @@ -424,7 +423,6 @@ static void rcu_torture_deferred_free(struct rcu_torture 
> *p)
>  
>  static struct rcu_torture_ops rcu_ops = {
>   .init   = NULL,
> - .cleanup= NULL,
>   .readlock   = rcu_torture_read_lock,
>   .read_delay = rcu_read_delay,
>   .readunlock = rcu_torture_read_unlock,
> @@ -468,7 +466,6 @@ static void rcu_sync_torture_init(void)
>  
>  static struct rcu_torture_ops rcu_sync_ops = {
>   .init   = rcu_sync_torture_init,
> - .cleanup= NULL,
>   .readlock   = rcu_torture_read_lock,
>   .read_delay = rcu_read_delay,
>   .readunlock = rcu_torture_read_unlock,
> @@ -486,7 +483,6 @@ static struct rcu_torture_ops rcu_sync_ops = {
>  
>  static struct rcu_torture_ops rcu_expedited_ops = {
>   .init   = rcu_sync_torture_init,
> - .cleanup= NULL,
>   .readlock   = rcu_torture_read_lock,
>   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
>   .readunlock = rcu_torture_read_unlock,
> @@ -529,7 +525,6 @@ static void rcu_bh_torture_deferred_free(struct 
> rcu_torture *p)
>  
>  static struct rcu_torture_ops rcu_bh_ops = {
>   .init   = NULL,
> - .cleanup= NULL,
>   .readlock   = rcu_bh_torture_read_lock,
>   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
>   .readunlock = rcu_bh_torture_read_unlock,
> @@ -546,7 +541,6 @@ static struct rcu_torture_ops rcu_bh_ops = {
>  
>  static struct rcu_torture_ops rcu_bh_sync_ops = {
>   .init   = rcu_sync_torture_init,
> - .cleanup= NULL,
>   .readlock   = rcu_bh_torture_read_lock,
>   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
>   .readunlock = rcu_bh_torture_read_unlock,
> @@ -563,7 +557,6 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
>  
>  static struct rcu_torture_ops rcu_bh_expedited_ops = {
>   .init   = rcu_sync_torture_init,
> - .cleanup= NULL,
>   .readlock   = rcu_bh_torture_read_lock,
>   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
>   .readunlock = rcu_bh_torture_read_unlock,
> @@ -582,19 +575,7 @@ static struct rcu_torture_ops rcu_bh_expedited_ops = {
>   * Definitions for srcu torture testing.
>   */
>  
> -static struct srcu_struct srcu_ctl;
> -
> -static void srcu_torture_init(void)
> -{
> - init_srcu_struct(_ctl);
> - rcu_sync_torture_init();
> -}
> -
> -static void srcu_torture_cleanup(void)
> -{
> - synchronize_srcu(_ctl);
> - cleanup_srcu_struct(_ctl);
> -}
> +DEFINE_STATIC_SRCU(srcu_ctl);
>  
>  static int srcu_torture_read_lock(void) __acquires(_ctl)
>  {
> @@ -665,8 +646,7 @@ static int srcu_torture_stats(char *page)
>  }
>  
>  static struct rcu_torture_ops srcu_ops = {
> - .init   = srcu_torture_init,
> - .cleanup= srcu_torture_cleanup,
> + .init   = rcu_sync_torture_init,
>   .readlock   = srcu_torture_read_lock,
>   .read_delay = srcu_read_delay,
>   .readunlock = srcu_torture_read_unlock,
> @@ -680,8 +660,7 @@ static struct rcu_torture_ops srcu_ops = {
>  };
>  
>  static struct rcu_torture_ops srcu_sync_ops = {
> - .init   = srcu_torture_init,
> - .cleanup= srcu_torture_cleanup,
> + .init   = rcu_sync_torture_init,
>   .readlock   = srcu_torture_read_lock,
>   .read_delay = srcu_read_delay,
>   .readunlock = srcu_torture_read_unlock,
> @@ -705,8 +684,7 @@ static void srcu_torture_read_unlock_raw(int idx) 
> __releases(_ctl)
>  }
>  
>  static struct rcu_torture_ops srcu_raw_ops = {
> - .init   = srcu_torture_init,
> - .cleanup= srcu_torture_cleanup,
> + .init   = rcu_sync_torture_init,
>   .readlock   = srcu_torture_read_lock_raw,
>   .read_delay = srcu_read_delay,
>   .readunlock = srcu_torture_read_unlock_raw,
> @@ -720,8 +698,7 @@ static struct rcu_torture_ops srcu_raw_ops = {
>  };
>  
>  static struct rcu_torture_ops srcu_raw_sync_ops = {
> - .init   = srcu_torture_init,
> - .cleanup= srcu_torture_cleanup,
> + .init   = 

[PATCH 4/4] rcutorture: use DEFINE_STATIC_SRCU()

2012-10-12 Thread Lai Jiangshan
use DEFINE_STATIC_SRCU() to simplify the rcutorture.c

Signed-off-by: Lai Jiangshan 
---
 kernel/rcutorture.c |   41 ++---
 1 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 25b1503..7939edf 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -332,7 +332,6 @@ rcu_stutter_wait(char *title)
 
 struct rcu_torture_ops {
void (*init)(void);
-   void (*cleanup)(void);
int (*readlock)(void);
void (*read_delay)(struct rcu_random_state *rrsp);
void (*readunlock)(int idx);
@@ -424,7 +423,6 @@ static void rcu_torture_deferred_free(struct rcu_torture *p)
 
 static struct rcu_torture_ops rcu_ops = {
.init   = NULL,
-   .cleanup= NULL,
.readlock   = rcu_torture_read_lock,
.read_delay = rcu_read_delay,
.readunlock = rcu_torture_read_unlock,
@@ -468,7 +466,6 @@ static void rcu_sync_torture_init(void)
 
 static struct rcu_torture_ops rcu_sync_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_torture_read_lock,
.read_delay = rcu_read_delay,
.readunlock = rcu_torture_read_unlock,
@@ -486,7 +483,6 @@ static struct rcu_torture_ops rcu_sync_ops = {
 
 static struct rcu_torture_ops rcu_expedited_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_torture_read_unlock,
@@ -529,7 +525,6 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture 
*p)
 
 static struct rcu_torture_ops rcu_bh_ops = {
.init   = NULL,
-   .cleanup= NULL,
.readlock   = rcu_bh_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_bh_torture_read_unlock,
@@ -546,7 +541,6 @@ static struct rcu_torture_ops rcu_bh_ops = {
 
 static struct rcu_torture_ops rcu_bh_sync_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_bh_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_bh_torture_read_unlock,
@@ -563,7 +557,6 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
 
 static struct rcu_torture_ops rcu_bh_expedited_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_bh_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_bh_torture_read_unlock,
@@ -582,19 +575,7 @@ static struct rcu_torture_ops rcu_bh_expedited_ops = {
  * Definitions for srcu torture testing.
  */
 
-static struct srcu_struct srcu_ctl;
-
-static void srcu_torture_init(void)
-{
-   init_srcu_struct(_ctl);
-   rcu_sync_torture_init();
-}
-
-static void srcu_torture_cleanup(void)
-{
-   synchronize_srcu(_ctl);
-   cleanup_srcu_struct(_ctl);
-}
+DEFINE_STATIC_SRCU(srcu_ctl);
 
 static int srcu_torture_read_lock(void) __acquires(_ctl)
 {
@@ -665,8 +646,7 @@ static int srcu_torture_stats(char *page)
 }
 
 static struct rcu_torture_ops srcu_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock,
@@ -680,8 +660,7 @@ static struct rcu_torture_ops srcu_ops = {
 };
 
 static struct rcu_torture_ops srcu_sync_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock,
@@ -705,8 +684,7 @@ static void srcu_torture_read_unlock_raw(int idx) 
__releases(_ctl)
 }
 
 static struct rcu_torture_ops srcu_raw_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock_raw,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock_raw,
@@ -720,8 +698,7 @@ static struct rcu_torture_ops srcu_raw_ops = {
 };
 
 static struct rcu_torture_ops srcu_raw_sync_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock_raw,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock_raw,
@@ -740,8 +717,7 @@ static void 

[PATCH 4/4] rcutorture: use DEFINE_STATIC_SRCU()

2012-10-12 Thread Lai Jiangshan
use DEFINE_STATIC_SRCU() to simplify the rcutorture.c

Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com
---
 kernel/rcutorture.c |   41 ++---
 1 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 25b1503..7939edf 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -332,7 +332,6 @@ rcu_stutter_wait(char *title)
 
 struct rcu_torture_ops {
void (*init)(void);
-   void (*cleanup)(void);
int (*readlock)(void);
void (*read_delay)(struct rcu_random_state *rrsp);
void (*readunlock)(int idx);
@@ -424,7 +423,6 @@ static void rcu_torture_deferred_free(struct rcu_torture *p)
 
 static struct rcu_torture_ops rcu_ops = {
.init   = NULL,
-   .cleanup= NULL,
.readlock   = rcu_torture_read_lock,
.read_delay = rcu_read_delay,
.readunlock = rcu_torture_read_unlock,
@@ -468,7 +466,6 @@ static void rcu_sync_torture_init(void)
 
 static struct rcu_torture_ops rcu_sync_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_torture_read_lock,
.read_delay = rcu_read_delay,
.readunlock = rcu_torture_read_unlock,
@@ -486,7 +483,6 @@ static struct rcu_torture_ops rcu_sync_ops = {
 
 static struct rcu_torture_ops rcu_expedited_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_torture_read_unlock,
@@ -529,7 +525,6 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture 
*p)
 
 static struct rcu_torture_ops rcu_bh_ops = {
.init   = NULL,
-   .cleanup= NULL,
.readlock   = rcu_bh_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_bh_torture_read_unlock,
@@ -546,7 +541,6 @@ static struct rcu_torture_ops rcu_bh_ops = {
 
 static struct rcu_torture_ops rcu_bh_sync_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_bh_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_bh_torture_read_unlock,
@@ -563,7 +557,6 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
 
 static struct rcu_torture_ops rcu_bh_expedited_ops = {
.init   = rcu_sync_torture_init,
-   .cleanup= NULL,
.readlock   = rcu_bh_torture_read_lock,
.read_delay = rcu_read_delay,  /* just reuse rcu's version. */
.readunlock = rcu_bh_torture_read_unlock,
@@ -582,19 +575,7 @@ static struct rcu_torture_ops rcu_bh_expedited_ops = {
  * Definitions for srcu torture testing.
  */
 
-static struct srcu_struct srcu_ctl;
-
-static void srcu_torture_init(void)
-{
-   init_srcu_struct(srcu_ctl);
-   rcu_sync_torture_init();
-}
-
-static void srcu_torture_cleanup(void)
-{
-   synchronize_srcu(srcu_ctl);
-   cleanup_srcu_struct(srcu_ctl);
-}
+DEFINE_STATIC_SRCU(srcu_ctl);
 
 static int srcu_torture_read_lock(void) __acquires(srcu_ctl)
 {
@@ -665,8 +646,7 @@ static int srcu_torture_stats(char *page)
 }
 
 static struct rcu_torture_ops srcu_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock,
@@ -680,8 +660,7 @@ static struct rcu_torture_ops srcu_ops = {
 };
 
 static struct rcu_torture_ops srcu_sync_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock,
@@ -705,8 +684,7 @@ static void srcu_torture_read_unlock_raw(int idx) 
__releases(srcu_ctl)
 }
 
 static struct rcu_torture_ops srcu_raw_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock_raw,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock_raw,
@@ -720,8 +698,7 @@ static struct rcu_torture_ops srcu_raw_ops = {
 };
 
 static struct rcu_torture_ops srcu_raw_sync_ops = {
-   .init   = srcu_torture_init,
-   .cleanup= srcu_torture_cleanup,
+   .init   = rcu_sync_torture_init,
.readlock   = srcu_torture_read_lock_raw,
.read_delay = srcu_read_delay,
.readunlock = srcu_torture_read_unlock_raw,
@@ -740,8 

Re: [PATCH 4/4] rcutorture: use DEFINE_STATIC_SRCU()

2012-10-12 Thread Josh Triplett
On Sat, Oct 13, 2012 at 01:14:17AM +0800, Lai Jiangshan wrote:
 use DEFINE_STATIC_SRCU() to simplify the rcutorture.c
 
 Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com

Reviewed-by: Josh Triplett j...@joshtriplett.org

 ---
  kernel/rcutorture.c |   41 ++---
  1 files changed, 6 insertions(+), 35 deletions(-)
 
 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
 index 25b1503..7939edf 100644
 --- a/kernel/rcutorture.c
 +++ b/kernel/rcutorture.c
 @@ -332,7 +332,6 @@ rcu_stutter_wait(char *title)
  
  struct rcu_torture_ops {
   void (*init)(void);
 - void (*cleanup)(void);
   int (*readlock)(void);
   void (*read_delay)(struct rcu_random_state *rrsp);
   void (*readunlock)(int idx);
 @@ -424,7 +423,6 @@ static void rcu_torture_deferred_free(struct rcu_torture 
 *p)
  
  static struct rcu_torture_ops rcu_ops = {
   .init   = NULL,
 - .cleanup= NULL,
   .readlock   = rcu_torture_read_lock,
   .read_delay = rcu_read_delay,
   .readunlock = rcu_torture_read_unlock,
 @@ -468,7 +466,6 @@ static void rcu_sync_torture_init(void)
  
  static struct rcu_torture_ops rcu_sync_ops = {
   .init   = rcu_sync_torture_init,
 - .cleanup= NULL,
   .readlock   = rcu_torture_read_lock,
   .read_delay = rcu_read_delay,
   .readunlock = rcu_torture_read_unlock,
 @@ -486,7 +483,6 @@ static struct rcu_torture_ops rcu_sync_ops = {
  
  static struct rcu_torture_ops rcu_expedited_ops = {
   .init   = rcu_sync_torture_init,
 - .cleanup= NULL,
   .readlock   = rcu_torture_read_lock,
   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
   .readunlock = rcu_torture_read_unlock,
 @@ -529,7 +525,6 @@ static void rcu_bh_torture_deferred_free(struct 
 rcu_torture *p)
  
  static struct rcu_torture_ops rcu_bh_ops = {
   .init   = NULL,
 - .cleanup= NULL,
   .readlock   = rcu_bh_torture_read_lock,
   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
   .readunlock = rcu_bh_torture_read_unlock,
 @@ -546,7 +541,6 @@ static struct rcu_torture_ops rcu_bh_ops = {
  
  static struct rcu_torture_ops rcu_bh_sync_ops = {
   .init   = rcu_sync_torture_init,
 - .cleanup= NULL,
   .readlock   = rcu_bh_torture_read_lock,
   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
   .readunlock = rcu_bh_torture_read_unlock,
 @@ -563,7 +557,6 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
  
  static struct rcu_torture_ops rcu_bh_expedited_ops = {
   .init   = rcu_sync_torture_init,
 - .cleanup= NULL,
   .readlock   = rcu_bh_torture_read_lock,
   .read_delay = rcu_read_delay,  /* just reuse rcu's version. */
   .readunlock = rcu_bh_torture_read_unlock,
 @@ -582,19 +575,7 @@ static struct rcu_torture_ops rcu_bh_expedited_ops = {
   * Definitions for srcu torture testing.
   */
  
 -static struct srcu_struct srcu_ctl;
 -
 -static void srcu_torture_init(void)
 -{
 - init_srcu_struct(srcu_ctl);
 - rcu_sync_torture_init();
 -}
 -
 -static void srcu_torture_cleanup(void)
 -{
 - synchronize_srcu(srcu_ctl);
 - cleanup_srcu_struct(srcu_ctl);
 -}
 +DEFINE_STATIC_SRCU(srcu_ctl);
  
  static int srcu_torture_read_lock(void) __acquires(srcu_ctl)
  {
 @@ -665,8 +646,7 @@ static int srcu_torture_stats(char *page)
  }
  
  static struct rcu_torture_ops srcu_ops = {
 - .init   = srcu_torture_init,
 - .cleanup= srcu_torture_cleanup,
 + .init   = rcu_sync_torture_init,
   .readlock   = srcu_torture_read_lock,
   .read_delay = srcu_read_delay,
   .readunlock = srcu_torture_read_unlock,
 @@ -680,8 +660,7 @@ static struct rcu_torture_ops srcu_ops = {
  };
  
  static struct rcu_torture_ops srcu_sync_ops = {
 - .init   = srcu_torture_init,
 - .cleanup= srcu_torture_cleanup,
 + .init   = rcu_sync_torture_init,
   .readlock   = srcu_torture_read_lock,
   .read_delay = srcu_read_delay,
   .readunlock = srcu_torture_read_unlock,
 @@ -705,8 +684,7 @@ static void srcu_torture_read_unlock_raw(int idx) 
 __releases(srcu_ctl)
  }
  
  static struct rcu_torture_ops srcu_raw_ops = {
 - .init   = srcu_torture_init,
 - .cleanup= srcu_torture_cleanup,
 + .init   = rcu_sync_torture_init,
   .readlock   = srcu_torture_read_lock_raw,
   .read_delay = srcu_read_delay,
   .readunlock = srcu_torture_read_unlock_raw,
 @@ -720,8 +698,7 @@ static struct rcu_torture_ops srcu_raw_ops = {
  };
  
  static struct rcu_torture_ops srcu_raw_sync_ops = {
 - .init   = srcu_torture_init,
 - .cleanup= srcu_torture_cleanup,
 + .init   = rcu_sync_torture_init,
   .readlock   =