Re: [PATCH 2/2] srcu: Early test SRCU polling start

2021-04-14 Thread Paul E. McKenney
On Wed, Apr 14, 2021 at 03:24:13PM +0200, Frederic Weisbecker wrote:
> Test an early call to start_poll_synchronize_srcu() and place it before
> the early test to call_srcu() on the same ssp.
> 
> After the later call to srcu_barrier(), we expect the first grace period
> completion to be visible by a subsequent call to
> poll_state_synchronize_srcu(). Report otherwise.
> 
> Signed-off-by: Frederic Weisbecker 

Given the first patch, this one looks good, give or take my usual
editing compulsion.

Thanx, Paul

> Cc: Boqun Feng 
> Cc: Lai Jiangshan 
> Cc: Neeraj Upadhyay 
> Cc: Josh Triplett 
> Cc: Joel Fernandes 
> Cc: Uladzislau Rezki 
> ---
>  kernel/rcu/update.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
> index dd94a602a6d2..c21b38cc25e9 100644
> --- a/kernel/rcu/update.c
> +++ b/kernel/rcu/update.c
> @@ -524,6 +524,7 @@ static void test_callback(struct rcu_head *r)
>  }
>  
>  DEFINE_STATIC_SRCU(early_srcu);
> +static unsigned long early_srcu_cookie;
>  
>  struct early_boot_kfree_rcu {
>   struct rcu_head rh;
> @@ -536,8 +537,10 @@ static void early_boot_test_call_rcu(void)
>   struct early_boot_kfree_rcu *rhp;
>  
>   call_rcu(, test_callback);
> - if (IS_ENABLED(CONFIG_SRCU))
> + if (IS_ENABLED(CONFIG_SRCU)) {
> + early_srcu_cookie = start_poll_synchronize_srcu(_srcu);
>   call_srcu(_srcu, , test_callback);
> + }
>   rhp = kmalloc(sizeof(*rhp), GFP_KERNEL);
>   if (!WARN_ON_ONCE(!rhp))
>   kfree_rcu(rhp, rh);
> @@ -563,6 +566,7 @@ static int rcu_verify_early_boot_tests(void)
>   if (IS_ENABLED(CONFIG_SRCU)) {
>   early_boot_test_counter++;
>   srcu_barrier(_srcu);
> + WARN_ON_ONCE(!poll_state_synchronize_srcu(_srcu, 
> early_srcu_cookie));
>   }
>   }
>   if (rcu_self_test_counter != early_boot_test_counter) {
> -- 
> 2.25.1
> 


[PATCH 2/2] srcu: Early test SRCU polling start

2021-04-14 Thread Frederic Weisbecker
Test an early call to start_poll_synchronize_srcu() and place it before
the early test to call_srcu() on the same ssp.

After the later call to srcu_barrier(), we expect the first grace period
completion to be visible by a subsequent call to
poll_state_synchronize_srcu(). Report otherwise.

Signed-off-by: Frederic Weisbecker 
Cc: Boqun Feng 
Cc: Lai Jiangshan 
Cc: Neeraj Upadhyay 
Cc: Josh Triplett 
Cc: Joel Fernandes 
Cc: Uladzislau Rezki 
---
 kernel/rcu/update.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index dd94a602a6d2..c21b38cc25e9 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -524,6 +524,7 @@ static void test_callback(struct rcu_head *r)
 }
 
 DEFINE_STATIC_SRCU(early_srcu);
+static unsigned long early_srcu_cookie;
 
 struct early_boot_kfree_rcu {
struct rcu_head rh;
@@ -536,8 +537,10 @@ static void early_boot_test_call_rcu(void)
struct early_boot_kfree_rcu *rhp;
 
call_rcu(, test_callback);
-   if (IS_ENABLED(CONFIG_SRCU))
+   if (IS_ENABLED(CONFIG_SRCU)) {
+   early_srcu_cookie = start_poll_synchronize_srcu(_srcu);
call_srcu(_srcu, , test_callback);
+   }
rhp = kmalloc(sizeof(*rhp), GFP_KERNEL);
if (!WARN_ON_ONCE(!rhp))
kfree_rcu(rhp, rh);
@@ -563,6 +566,7 @@ static int rcu_verify_early_boot_tests(void)
if (IS_ENABLED(CONFIG_SRCU)) {
early_boot_test_counter++;
srcu_barrier(_srcu);
+   WARN_ON_ONCE(!poll_state_synchronize_srcu(_srcu, 
early_srcu_cookie));
}
}
if (rcu_self_test_counter != early_boot_test_counter) {
-- 
2.25.1