Skip to content

Commit

Permalink
rcu: demote SRCU_SYNCHRONIZE_DELAY from kernel-parameter status
Browse files Browse the repository at this point in the history
Because the adaptive synchronize_srcu_expedited() approach has
worked very well in testing, remove the kernel parameter and
replace it by a C-preprocessor macro.  If someone finds problems
with this approach, a more complex and aggressively adaptive
approach might be required.

Longer term, SRCU will be merged with the other RCU implementations,
at which point synchronize_srcu_expedited() will be event driven,
just as synchronize_sched_expedited() currently is.  At that point,
there will be no need for this adaptive approach.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  • Loading branch information
paulmck authored and Kali- committed Jan 5, 2012
1 parent 37bc46e commit 38253e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
15 changes: 0 additions & 15 deletions init/Kconfig
Expand Up @@ -481,21 +481,6 @@ config RCU_BOOST_DELAY

Accept the default if unsure.

config SRCU_SYNCHRONIZE_DELAY
int "Microseconds to delay before waiting for readers"
range 0 20
default 10
help
This option controls how long SRCU delays before entering its
loop waiting on SRCU readers. The purpose of this loop is
to avoid the unconditional context-switch penalty that would
otherwise be incurred if there was an active SRCU reader,
in a manner similar to adaptive locking schemes. This should
be set to be a bit longer than the common-case SRCU read-side
critical-section overhead.

Accept the default if unsure.

endmenu # "RCU Subsystem"

config IKCONFIG
Expand Down
15 changes: 13 additions & 2 deletions kernel/srcu.c
Expand Up @@ -157,6 +157,16 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
}
EXPORT_SYMBOL_GPL(__srcu_read_unlock);

/*
* We use an adaptive strategy for synchronize_srcu() and especially for
* synchronize_srcu_expedited(). We spin for a fixed time period
* (defined below) to allow SRCU readers to exit their read-side critical
* sections. If there are still some readers after 10 microseconds,
* we repeatedly block for 1-millisecond time periods. This approach
* has done well in testing, so there is no need for a config parameter.
*/
#define SYNCHRONIZE_SRCU_READER_DELAY 10

/*
* Helper function for synchronize_srcu() and synchronize_srcu_expedited().
*/
Expand Down Expand Up @@ -209,11 +219,12 @@ static void __synchronize_srcu(struct srcu_struct *sp, void (*sync_func)(void))
* will have finished executing. We initially give readers
* an arbitrarily chosen 10 microseconds to get out of their
* SRCU read-side critical sections, then loop waiting 1/HZ
* seconds per iteration.
* seconds per iteration. The 10-microsecond value has done
* very well in testing.
*/

if (srcu_readers_active_idx(sp, idx))
udelay(CONFIG_SRCU_SYNCHRONIZE_DELAY);
udelay(SYNCHRONIZE_SRCU_READER_DELAY);
while (srcu_readers_active_idx(sp, idx))
schedule_timeout_interruptible(1);

Expand Down

0 comments on commit 38253e0

Please sign in to comment.