dynticks: Remove atomic ops for dynticks_idle
This is on top of the first patch (but still not against your tree). I wonder what you think about this one. No special operations.
Since dynticks_idle is only ever modified by the local cpu we do not need to use atomics there.
kernel/rcu/tree.c +1 -1
@@ -213,7 +213,7 @@ static DEFINE_PER_CPU(struct rcu_dyntick .dynticks = ATOMIC_INIT(1), #ifdef CONFIG_NO_HZ_FULL_SYSIDLE .dynticks_idle_nesting = DYNTICK_TASK_NEST_VALUE, - .dynticks_idle = ATOMIC_INIT(1), + .dynticks_idle = 1,#endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ };
kernel/rcu/tree.h +1 -1
@@ -91,7 +91,7 @@ struct rcu_dynticks {#ifdef CONFIG_NO_HZ_FULL_SYSIDLE long long dynticks_idle_nesting;/* irq/process nesting level from idle. */ -atomic_t dynticks_idle;/* Even value for idle, else odd. */ +long dynticks_idle;/* Even value for idle, else odd. */ /* "Idle" excludes userspace execution. */ unsigned long dynticks_idle_jiffies;/* End of last non-NMI non-idle period. */
kernel/rcu/tree_plugin.h +5 -5
@@ -2644,9 +2644,9 @@ static void rcu_sysidle_enter(int irq) j = jiffies;ACCESS_ONCE (rdtp->dynticks_idle_jiffies) = j;smp_mb__before_atomic (); -atomic_inc (&rdtp->dynticks_idle); + rdtp->dynticks_idle++;smp_mb__after_atomic (); -WARN_ON_ONCE (atomic_read (&rdtp->dynticks_idle) &0x1 ); +WARN_ON_ONCE (rdtp->dynticks_idle &0x1 ); }/*
@@ -2712,9 +2712,9 @@ static void rcu_sysidle_exit(int irq)/* Record end of idle period. */ smp_mb__before_atomic (); -atomic_inc (&rdtp->dynticks_idle); + rdtp->dynticks_idle++;smp_mb__after_atomic (); -WARN_ON_ONCE (!(atomic_read (&rdtp->dynticks_idle) &0x1 )); +WARN_ON_ONCE (!(rdtp->dynticks_idle &0x1 ));/* * If we are the timekeeping CPU, we are permitted to be non-idle
@@ -2755,7 +2755,7 @@ static void rcu_sysidle_check_cpu(structWARN_ON_ONCE (smp_processor_id () != tick_do_timer_cpu);/* Pick up current idle and NMI-nesting counter and check. */ - cur =atomic_read (&rdtp->dynticks_idle); + cur = rdtp->dynticks_idle;if (cur &0x1 ) { *isidle = false;/* We are not idle! */ return ;
Quoted 8 lines · Christoph Lameter
This is on top of the first patch (but still not against your tree). I wonder what you think about this one. No special operations.
Since
dynticks_idleis only ever modified by the local cpu we do not need to use atomics there.Signed-off-by Christoph Lameter <[email protected]>
Sorry, as discussed earlier, this change is non-trivial. In addition, you have not justified the change.
Quoted 31 lines
Index:
linux/kernel/rcu/tree.c
===================================================================kernel/rcu/tree.c +1
-1@@ -213,7 +213,7 @@ static DEFINE_PER_CPU(struct rcu_dyntick .dynticks = ATOMIC_INIT(1), #ifdef CONFIG_NO_HZ_FULL_SYSIDLE .dynticks_idle_nesting = DYNTICK_TASK_NEST_VALUE, - .dynticks_idle = ATOMIC_INIT(1), + .dynticks_idle = 1,#endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ };Index:
linux/kernel/rcu/tree.h
===================================================================kernel/rcu/tree.h +1
-1@@ -91,7 +91,7 @@ struct rcu_dynticks {#ifdef CONFIG_NO_HZ_FULL_SYSIDLE long long dynticks_idle_nesting;/* irq/process nesting level from idle. */ -atomic_t dynticks_idle;/* Even value for idle, else odd. */ +long dynticks_idle;/* Even value for idle, else odd. */ /* "Idle" excludes userspace execution. */ unsigned long dynticks_idle_jiffies;/* End of last non-NMI non-idle period. */ Index:
linux/kernel/rcu/tree_plugin.h
===================================================================
kernel/rcu/tree_plugin.h static void rcu_sysidle_enter(int irq) · line 2648
Quoted 6 lines
kernel/rcu/tree_plugin.h +1
-1@@ -2644,9 +2644,9 @@ static void rcu_sysidle_enter(int irq) j = jiffies;ACCESS_ONCE (rdtp->dynticks_idle_jiffies) = j;smp_mb__before_atomic (); -atomic_inc (&rdtp->dynticks_idle); + rdtp->dynticks_idle++;smp_mb__after_atomic ();
And this is completely broken.
kernel/rcu/tree_plugin.h static void rcu_sysidle_exit(int irq) · line 2716
Quoted 12 lines
kernel/rcu/tree_plugin.h +2
-2-WARN_ON_ONCE (atomic_read (&rdtp->dynticks_idle) &0x1 ); +WARN_ON_ONCE (rdtp->dynticks_idle &0x1 ); }/* @@ -2712,9 +2712,9 @@ static void rcu_sysidle_exit(int irq)/* Record end of idle period. */ smp_mb__before_atomic (); -atomic_inc (&rdtp->dynticks_idle); + rdtp->dynticks_idle++;smp_mb__after_atomic ();
As is this.
kernel/rcu/tree_plugin.h static void rcu_sysidle_check_cpu(struct · line 2758
Quoted 11 lines
kernel/rcu/tree_plugin.h +2
-2-WARN_ON_ONCE (!(atomic_read (&rdtp->dynticks_idle) &0x1 )); +WARN_ON_ONCE (!(rdtp->dynticks_idle &0x1 ));/* * If we are the timekeeping CPU, we are permitted to be non-idle @@ -2755,7 +2755,7 @@ static void rcu_sysidle_check_cpu(structWARN_ON_ONCE (smp_processor_id () != tick_do_timer_cpu);/* Pick up current idle and NMI-nesting counter and check. */ - cur =atomic_read (&rdtp->dynticks_idle); + cur = rdtp->dynticks_idle;
And this as well.
Thanx, Paul
Quoted 4 lines
kernel/rcu/tree_plugin.h +0
-0if (cur &0x1 ) { *isidle = false;/* We are not idle! */ return ;
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · Christoph Lameter
This is on top of the first patch (but still not against your tree). I wonder what you think about this one. No special operations.
Quoted 7 lines
Quoted 4 lines
Since
dynticks_idleis only ever modified by the local cpu we do not need to use atomics there.Signed-off-by Christoph Lameter <[email protected]>Sorry, as discussed earlier, this change is non-trivial. In addition, you have not justified the change.
The rationale is quite clear: Use of atomics without the need to use them.