From dac91d1eddf1e6355f3eb359bcf08824aa3ac83d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 9 Sep 2012 06:34:27 -0400 Subject: [PATCH] ck_epoch: Short-circuit on scan block if epoch tick is encountered. --- src/ck_epoch.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ck_epoch.c b/src/ck_epoch.c index dd47b8a..64426d9 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -302,8 +302,16 @@ ck_epoch_barrier(struct ck_epoch *global, struct ck_epoch_record *record) * We can get away without a fence here. */ while (cr = ck_epoch_scan(global, cr, delta, &active), cr != NULL) { + unsigned int e_d; + ck_pr_stall(); - delta = ck_pr_load_uint(&global->epoch); + + /* Another writer may have already observed a grace period. */ + e_d = ck_pr_load_uint(&global->epoch); + if (e_d != delta) { + delta = e_d; + goto reload; + } } /* @@ -326,7 +334,11 @@ ck_epoch_barrier(struct ck_epoch *global, struct ck_epoch_record *record) */ if (ck_pr_cas_uint_value(&global->epoch, delta, delta + 1, &delta) == true) { delta = delta + 1; - } else if ((goal > epoch) & (delta >= goal)) { + continue; + } + +reload: + if ((goal > epoch) & (delta >= goal)) { /* * Right now, epoch overflow is handled as an edge case. If * we have already observed an epoch generation, then we can