MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ck_epoch_begin

Function ck_epoch_begin

freebsd/contrib/ck/include/ck_epoch.h:125–167  ·  view source on GitHub ↗

* Marks the beginning of an epoch-protected section. */

Source from the content-addressed store, hash-verified

123 * Marks the beginning of an epoch-protected section.
124 */
125CK_CC_FORCE_INLINE static void
126ck_epoch_begin(ck_epoch_record_t *record, ck_epoch_section_t *section)
127{
128 struct ck_epoch *epoch = record->global;
129
130 /*
131 * Only observe new epoch if thread is not recursing into a read
132 * section.
133 */
134 if (record->active == 0) {
135 unsigned int g_epoch;
136
137 /*
138 * It is possible for loads to be re-ordered before the store
139 * is committed into the caller's epoch and active fields.
140 * For this reason, store to load serialization is necessary.
141 */
142#if defined(CK_MD_TSO)
143 ck_pr_fas_uint(&record->active, 1);
144 ck_pr_fence_atomic_load();
145#else
146 ck_pr_store_uint(&record->active, 1);
147 ck_pr_fence_memory();
148#endif
149
150 /*
151 * This load is allowed to be re-ordered prior to setting
152 * active flag due to monotonic nature of the global epoch.
153 * However, stale values lead to measurable performance
154 * degradation in some torture tests so we disallow early load
155 * of global epoch.
156 */
157 g_epoch = ck_pr_load_uint(&epoch->epoch);
158 ck_pr_store_uint(&record->epoch, g_epoch);
159 } else {
160 ck_pr_store_uint(&record->active, record->active + 1);
161 }
162
163 if (section != NULL)
164 _ck_epoch_addref(record, section);
165
166 return;
167}
168
169/*
170 * Marks the end of an epoch-protected section. Returns true if no more

Callers 2

_epoch_enter_preemptFunction · 0.85
epoch_enterFunction · 0.85

Calls 1

_ck_epoch_addrefFunction · 0.50

Tested by

no test coverage detected