* Marks the beginning of an epoch-protected section. */
| 123 | * Marks the beginning of an epoch-protected section. |
| 124 | */ |
| 125 | CK_CC_FORCE_INLINE static void |
| 126 | ck_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 |
no test coverage detected