Commit 2e672ab2 authored by Paul E. McKenney's avatar Paul E. McKenney

rcu: Avoid ->dynticks_nmi_nesting store tearing

NMIs can nest, and store tearing could in theory happen on carries
from one byte to the next.  This commit therefore adds the WRITE_ONCE()
macros preventing this.
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 4fbd8d19
...@@ -1103,7 +1103,8 @@ void rcu_nmi_enter(void) ...@@ -1103,7 +1103,8 @@ void rcu_nmi_enter(void)
rcu_dynticks_eqs_exit(); rcu_dynticks_eqs_exit();
incby = 1; incby = 1;
} }
rdtp->dynticks_nmi_nesting += incby; WRITE_ONCE(rdtp->dynticks_nmi_nesting, /* Prevent store tearing. */
rdtp->dynticks_nmi_nesting + incby);
barrier(); barrier();
} }
...@@ -1135,12 +1136,13 @@ void rcu_nmi_exit(void) ...@@ -1135,12 +1136,13 @@ void rcu_nmi_exit(void)
* leave it in non-RCU-idle state. * leave it in non-RCU-idle state.
*/ */
if (rdtp->dynticks_nmi_nesting != 1) { if (rdtp->dynticks_nmi_nesting != 1) {
rdtp->dynticks_nmi_nesting -= 2; WRITE_ONCE(rdtp->dynticks_nmi_nesting, /* No store tearing. */
rdtp->dynticks_nmi_nesting - 2);
return; return;
} }
/* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */ /* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */
rdtp->dynticks_nmi_nesting = 0; WRITE_ONCE(rdtp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */
rcu_dynticks_eqs_enter(); rcu_dynticks_eqs_enter();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment