Changeset 18b6a88 in mainline for kernel/generic/src/synch/rcu.c
- Timestamp:
- 2018-04-15T09:35:04Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1f44ca
- Parents:
- 8ebe212
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/rcu.c
r8ebe212 r18b6a88 253 253 static void synch_complete(rcu_item_t *rcu_item); 254 254 static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item, 255 255 rcu_func_t func); 256 256 static void add_barrier_cb(void *arg); 257 257 static void barrier_complete(rcu_item_t *barrier_item); … … 440 440 { 441 441 for (unsigned int cpu_id = 0; cpu_id < config.cpu_count; ++cpu_id) { 442 char name[THREAD_NAME_BUFLEN] = { 0};442 char name[THREAD_NAME_BUFLEN] = { 0 }; 443 443 444 444 snprintf(name, THREAD_NAME_BUFLEN - 1, "rcu-rec/%u", cpu_id); 445 445 446 446 cpus[cpu_id].rcu.reclaimer_thr = 447 447 thread_create(reclaimer, NULL, TASK, THREAD_FLAG_NONE, name); 448 448 449 449 if (!cpus[cpu_id].rcu.reclaimer_thr) … … 461 461 { 462 462 rcu.detector_thr = 463 463 thread_create(detector, NULL, TASK, THREAD_FLAG_NONE, "rcu-det"); 464 464 465 465 if (!rcu.detector_thr) … … 656 656 /** rcu_call() inline-able implementation. See rcu_call() for comments. */ 657 657 static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item, 658 658 rcu_func_t func) 659 659 { 660 660 assert(rcu_item); … … 667 667 rcu_cpu_data_t *r = &CPU->rcu; 668 668 669 rcu_item_t **prev_tail 670 =local_atomic_exchange(&r->parriving_cbs_tail, &rcu_item->next);669 rcu_item_t **prev_tail = 670 local_atomic_exchange(&r->parriving_cbs_tail, &rcu_item->next); 671 671 *prev_tail = rcu_item; 672 672 … … 829 829 if (0 < arriving_cnt) { 830 830 CPU->rcu.stat_avg_cbs = 831 831 (99 * CPU->rcu.stat_avg_cbs + 1 * arriving_cnt) / 100; 832 832 } 833 833 } … … 853 853 * or risk exhausting all system memory. 854 854 */ 855 bool expedite = (EXPEDITE_THRESHOLD < CPU->rcu.next_cbs_cnt) 856 ||CPU->rcu.expedite_arriving;855 bool expedite = (EXPEDITE_THRESHOLD < CPU->rcu.next_cbs_cnt) || 856 CPU->rcu.expedite_arriving; 857 857 CPU->rcu.expedite_arriving = false; 858 858 … … 958 958 /* Wait for the GP to complete. */ 959 959 errno_t ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock, 960 960 SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE); 961 961 962 962 if (ret == EINTR) { … … 984 984 while (!cpu_mask_is_none(reader_cpus)) { 985 985 /* Give cpus a chance to context switch (a QS) and batch callbacks. */ 986 if (!gp_sleep(&expedite))986 if (!gp_sleep(&expedite)) 987 987 return false; 988 988 … … 1015 1015 errno_t ret = 0; 1016 1016 ret = _condvar_wait_timeout_spinlock(&rcu.expedite_now, &rcu.gp_lock, 1017 1017 DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE); 1018 1018 1019 1019 /* rcu.expedite_now was signaled. */ … … 1145 1145 1146 1146 printf("Bug: thread (id %" PRIu64 " \"%s\") exited while in RCU read" 1147 1147 " section.\n", THREAD->tid, THREAD->name); 1148 1148 } 1149 1149 } … … 1207 1207 */ 1208 1208 rcu_gp_t compl_gp = ACCESS_ONCE(rcu.completed_gp); 1209 if (CPU->rcu.cur_cbs_gp <= compl_gp 1210 &&compl_gp <= CPU->rcu.cur_cbs_gp + UINT32_MAX_HALF) {1209 if (CPU->rcu.cur_cbs_gp <= compl_gp && 1210 compl_gp <= CPU->rcu.cur_cbs_gp + UINT32_MAX_HALF) { 1211 1211 *completed_gp = compl_gp; 1212 1212 return true; … … 1237 1237 */ 1238 1238 if (expedite) { 1239 if (0 == rcu.req_expedited_cnt)1239 if (0 == rcu.req_expedited_cnt) 1240 1240 condvar_signal(&rcu.expedite_now); 1241 1241 … … 1270 1270 while (rcu.completed_gp < wait_on_gp && !interrupted) { 1271 1271 int ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock, 1272 1272 SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE); 1273 1273 interrupted = (ret == EINTR); 1274 1274 } … … 1330 1330 while (0 == rcu.req_gp_end_cnt && !interrupted) { 1331 1331 int ret = _condvar_wait_timeout_spinlock(&rcu.req_gp_changed, 1332 1332 &rcu.gp_lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE); 1333 1333 1334 1334 interrupted = (ret == EINTR); … … 1395 1395 /* minor bug: sleeps for the same duration if woken up spuriously. */ 1396 1396 ret = _condvar_wait_timeout_spinlock(&rcu.expedite_now, &rcu.gp_lock, 1397 1397 DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE); 1398 1398 } 1399 1399 … … 1479 1479 int delaying_cpu_cnt = atomic_get(&rcu.delaying_cpu_cnt); 1480 1480 1481 for (int i = 0; i < delaying_cpu_cnt; ++i) {1481 for (int i = 0; i < delaying_cpu_cnt; ++i) { 1482 1482 if (!semaphore_down_interruptable(&rcu.remaining_readers)) 1483 1483 return false; … … 1549 1549 if (THREAD == rcu.detector_thr) { 1550 1550 THREAD->priority = -1; 1551 } 1552 else if (THREAD == CPU->rcu.reclaimer_thr) { 1551 } else if (THREAD == CPU->rcu.reclaimer_thr) { 1553 1552 THREAD->priority = -1; 1554 1553 } … … 1606 1605 1607 1606 printf("Bug: thread (id %" PRIu64 " \"%s\") exited while in RCU read" 1608 1607 " section.\n", THREAD->tid, THREAD->name); 1609 1608 } 1610 1609 } … … 1834 1833 1835 1834 printf("Config: expedite_threshold=%d, critical_threshold=%d," 1836 1837 1835 " detect_sleep=%dms, %s\n", 1836 EXPEDITE_THRESHOLD, CRITICAL_THRESHOLD, DETECT_SLEEP_MS, algo); 1838 1837 printf("Completed GPs: %" PRIu64 "\n", rcu.completed_gp); 1839 1838 printf("Expedited GPs: %zu\n", rcu.stat_expedited_cnt); 1840 1839 printf("Delayed GPs: %zu (cpus w/ still running readers after gp sleep)\n", 1841 1840 rcu.stat_delayed_cnt); 1842 1841 printf("Preempt blocked GPs: %zu (waited for preempted readers; " 1843 1842 "running or not)\n", rcu.stat_preempt_blocking_cnt); 1844 1843 printf("Smp calls: %zu\n", rcu.stat_smp_call_cnt); 1845 1844
Note:
See TracChangeset
for help on using the changeset viewer.