aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/kernel/rcu
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2020-05-26 11:40:52 -0700
committerPaul E. McKenney <paulmck@kernel.org>2020-06-29 12:00:45 -0700
commit86e0da2bb8ed934d3dce5a337895f1118f59c087 (patch)
treed0ab05f6bd4cdc3e1d29fd6d27a999e954219331 /kernel/rcu
parentrefperf: Convert reader_task structure's "start" field to int (diff)
downloadwireguard-linux-86e0da2bb8ed934d3dce5a337895f1118f59c087.tar.xz
wireguard-linux-86e0da2bb8ed934d3dce5a337895f1118f59c087.zip
refperf: More closely synchronize reader start times
Currently, readers are awakened individually. On most systems, this results in significant wakeup delay from one reader to the next, which can result in the first and last reader having sole access to the synchronization primitive in question. If that synchronization primitive involves shared memory, those readers will rack up a huge number of operations in a very short time, causing large perturbations in the results. This commit therefore has the readers busy-wait after being awakened, and uses a new n_started variable to synchronize their start times. Cc: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'kernel/rcu')
-rw-r--r--kernel/rcu/refperf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/rcu/refperf.c b/kernel/rcu/refperf.c
index 2fd3ed1a0d0d..234bb0e84a8b 100644
--- a/kernel/rcu/refperf.c
+++ b/kernel/rcu/refperf.c
@@ -99,6 +99,7 @@ static atomic_t nreaders_exp;
// Use to wait for all threads to start.
static atomic_t n_init;
+static atomic_t n_started;
// Track which experiment is currently running.
static int exp_idx;
@@ -253,6 +254,9 @@ repeat:
WARN_ON_ONCE(smp_processor_id() != me);
WRITE_ONCE(rt->start_reader, 0);
+ if (!atomic_dec_return(&n_started))
+ while (atomic_read_acquire(&n_started))
+ cpu_relax();
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
@@ -367,6 +371,7 @@ static int main_func(void *arg)
reset_readers();
atomic_set(&nreaders_exp, nreaders);
+ atomic_set(&n_started, nreaders);
exp_idx = exp;