From 4cb3067944991f350b342a01b7078199714ea223 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sat, 13 Oct 2018 22:25:45 -0400 Subject: [PATCH] ck_epoch_poll: make it safe to call ck_epoch_poll in a protected section. This work is from jtl@FreeBSD.org. FreeBSD expects to call ck_epoch_poll from a record that is in an active section. Previously, it was considered an API violation to call write-side functions while in a read section. This is now permitted for poll as we we serialize behind the global epoch counter. Note that these functions are not reentrant. In the case of the FreeBSD kernel, all these functions are called with preemption disabled. --- src/ck_epoch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ck_epoch.c b/src/ck_epoch.c index 114ff62..4871930 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -589,10 +589,8 @@ ck_epoch_poll_deferred(struct ck_epoch_record *record, ck_stack_t *deferred) n_dispatch = ck_epoch_dispatch(record, epoch - 2, deferred); cr = ck_epoch_scan(global, cr, epoch, &active); - if (cr != NULL) { - record->epoch = epoch; + if (cr != NULL) return (n_dispatch > 0); - } /* We are at a grace period if all threads are inactive. */ if (active == false) {