diff mbox series

[-next] rcu: Use bitwise instead of arithmetic operator for flags

Message ID 20240823092158.3173241-1-lihongbo22@huawei.com (mailing list archive)
State Accepted
Commit d8e6ca2f39da05f2b4c2e2baa0e86cfdcae8ac81
Headers show
Series [-next] rcu: Use bitwise instead of arithmetic operator for flags | expand

Commit Message

Hongbo Li Aug. 23, 2024, 9:21 a.m. UTC
This silences the following coccinelle warning:
  WARNING: sum of probable bitmasks, consider |

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 kernel/rcu/tree_plugin.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Paul E. McKenney Aug. 30, 2024, 10:40 a.m. UTC | #1
On Fri, Aug 23, 2024 at 05:21:58PM +0800, Hongbo Li wrote:
> This silences the following coccinelle warning:
>   WARNING: sum of probable bitmasks, consider |
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>

> ---
>  kernel/rcu/tree_plugin.h | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 1c7cbd145d5e..3927ea5f7955 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -183,9 +183,9 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
>  	switch (blkd_state) {
>  	case 0:
>  	case                RCU_EXP_TASKS:
> -	case                RCU_EXP_TASKS + RCU_GP_BLKD:
> +	case                RCU_EXP_TASKS | RCU_GP_BLKD:
>  	case RCU_GP_TASKS:
> -	case RCU_GP_TASKS + RCU_EXP_TASKS:
> +	case RCU_GP_TASKS | RCU_EXP_TASKS:
>  
>  		/*
>  		 * Blocking neither GP, or first task blocking the normal
> @@ -198,10 +198,10 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
>  
>  	case                                              RCU_EXP_BLKD:
>  	case                                RCU_GP_BLKD:
> -	case                                RCU_GP_BLKD + RCU_EXP_BLKD:
> -	case RCU_GP_TASKS +                               RCU_EXP_BLKD:
> -	case RCU_GP_TASKS +                 RCU_GP_BLKD + RCU_EXP_BLKD:
> -	case RCU_GP_TASKS + RCU_EXP_TASKS + RCU_GP_BLKD + RCU_EXP_BLKD:
> +	case                                RCU_GP_BLKD | RCU_EXP_BLKD:
> +	case RCU_GP_TASKS |                               RCU_EXP_BLKD:
> +	case RCU_GP_TASKS |                 RCU_GP_BLKD | RCU_EXP_BLKD:
> +	case RCU_GP_TASKS | RCU_EXP_TASKS | RCU_GP_BLKD | RCU_EXP_BLKD:
>  
>  		/*
>  		 * First task arriving that blocks either GP, or first task
> @@ -214,9 +214,9 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
>  		list_add_tail(&t->rcu_node_entry, &rnp->blkd_tasks);
>  		break;
>  
> -	case                RCU_EXP_TASKS +               RCU_EXP_BLKD:
> -	case                RCU_EXP_TASKS + RCU_GP_BLKD + RCU_EXP_BLKD:
> -	case RCU_GP_TASKS + RCU_EXP_TASKS +               RCU_EXP_BLKD:
> +	case                RCU_EXP_TASKS |               RCU_EXP_BLKD:
> +	case                RCU_EXP_TASKS | RCU_GP_BLKD | RCU_EXP_BLKD:
> +	case RCU_GP_TASKS | RCU_EXP_TASKS |               RCU_EXP_BLKD:
>  
>  		/*
>  		 * Second or subsequent task blocking the expedited GP.
> @@ -227,8 +227,8 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
>  		list_add(&t->rcu_node_entry, rnp->exp_tasks);
>  		break;
>  
> -	case RCU_GP_TASKS +                 RCU_GP_BLKD:
> -	case RCU_GP_TASKS + RCU_EXP_TASKS + RCU_GP_BLKD:
> +	case RCU_GP_TASKS |                 RCU_GP_BLKD:
> +	case RCU_GP_TASKS | RCU_EXP_TASKS | RCU_GP_BLKD:
>  
>  		/*
>  		 * Second or subsequent task blocking the normal GP.
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 1c7cbd145d5e..3927ea5f7955 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -183,9 +183,9 @@  static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
 	switch (blkd_state) {
 	case 0:
 	case                RCU_EXP_TASKS:
-	case                RCU_EXP_TASKS + RCU_GP_BLKD:
+	case                RCU_EXP_TASKS | RCU_GP_BLKD:
 	case RCU_GP_TASKS:
-	case RCU_GP_TASKS + RCU_EXP_TASKS:
+	case RCU_GP_TASKS | RCU_EXP_TASKS:
 
 		/*
 		 * Blocking neither GP, or first task blocking the normal
@@ -198,10 +198,10 @@  static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
 
 	case                                              RCU_EXP_BLKD:
 	case                                RCU_GP_BLKD:
-	case                                RCU_GP_BLKD + RCU_EXP_BLKD:
-	case RCU_GP_TASKS +                               RCU_EXP_BLKD:
-	case RCU_GP_TASKS +                 RCU_GP_BLKD + RCU_EXP_BLKD:
-	case RCU_GP_TASKS + RCU_EXP_TASKS + RCU_GP_BLKD + RCU_EXP_BLKD:
+	case                                RCU_GP_BLKD | RCU_EXP_BLKD:
+	case RCU_GP_TASKS |                               RCU_EXP_BLKD:
+	case RCU_GP_TASKS |                 RCU_GP_BLKD | RCU_EXP_BLKD:
+	case RCU_GP_TASKS | RCU_EXP_TASKS | RCU_GP_BLKD | RCU_EXP_BLKD:
 
 		/*
 		 * First task arriving that blocks either GP, or first task
@@ -214,9 +214,9 @@  static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
 		list_add_tail(&t->rcu_node_entry, &rnp->blkd_tasks);
 		break;
 
-	case                RCU_EXP_TASKS +               RCU_EXP_BLKD:
-	case                RCU_EXP_TASKS + RCU_GP_BLKD + RCU_EXP_BLKD:
-	case RCU_GP_TASKS + RCU_EXP_TASKS +               RCU_EXP_BLKD:
+	case                RCU_EXP_TASKS |               RCU_EXP_BLKD:
+	case                RCU_EXP_TASKS | RCU_GP_BLKD | RCU_EXP_BLKD:
+	case RCU_GP_TASKS | RCU_EXP_TASKS |               RCU_EXP_BLKD:
 
 		/*
 		 * Second or subsequent task blocking the expedited GP.
@@ -227,8 +227,8 @@  static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
 		list_add(&t->rcu_node_entry, rnp->exp_tasks);
 		break;
 
-	case RCU_GP_TASKS +                 RCU_GP_BLKD:
-	case RCU_GP_TASKS + RCU_EXP_TASKS + RCU_GP_BLKD:
+	case RCU_GP_TASKS |                 RCU_GP_BLKD:
+	case RCU_GP_TASKS | RCU_EXP_TASKS | RCU_GP_BLKD:
 
 		/*
 		 * Second or subsequent task blocking the normal GP.