Changeset 18b6a88 in mainline for kernel/generic/src/synch/rcu.c


Ignore:
Timestamp:
2018-04-15T09:35:04Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1f44ca
Parents:
8ebe212
Message:

More ccheck fixes, sometimes with manual intervention.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/rcu.c

    r8ebe212 r18b6a88  
    253253static void synch_complete(rcu_item_t *rcu_item);
    254254static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item,
    255         rcu_func_t func);
     255    rcu_func_t func);
    256256static void add_barrier_cb(void *arg);
    257257static void barrier_complete(rcu_item_t *barrier_item);
     
    440440{
    441441        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 };
    443443
    444444                snprintf(name, THREAD_NAME_BUFLEN - 1, "rcu-rec/%u", cpu_id);
    445445
    446446                cpus[cpu_id].rcu.reclaimer_thr =
    447                         thread_create(reclaimer, NULL, TASK, THREAD_FLAG_NONE, name);
     447                    thread_create(reclaimer, NULL, TASK, THREAD_FLAG_NONE, name);
    448448
    449449                if (!cpus[cpu_id].rcu.reclaimer_thr)
     
    461461{
    462462        rcu.detector_thr =
    463                 thread_create(detector, NULL, TASK, THREAD_FLAG_NONE, "rcu-det");
     463            thread_create(detector, NULL, TASK, THREAD_FLAG_NONE, "rcu-det");
    464464
    465465        if (!rcu.detector_thr)
     
    656656/** rcu_call() inline-able implementation. See rcu_call() for comments. */
    657657static inline void rcu_call_impl(bool expedite, rcu_item_t *rcu_item,
    658         rcu_func_t func)
     658    rcu_func_t func)
    659659{
    660660        assert(rcu_item);
     
    667667        rcu_cpu_data_t *r = &CPU->rcu;
    668668
    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);
    671671        *prev_tail = rcu_item;
    672672
     
    829829        if (0 < arriving_cnt) {
    830830                CPU->rcu.stat_avg_cbs =
    831                         (99 * CPU->rcu.stat_avg_cbs + 1 * arriving_cnt) / 100;
     831                    (99 * CPU->rcu.stat_avg_cbs + 1 * arriving_cnt) / 100;
    832832        }
    833833}
     
    853853         * or risk exhausting all system memory.
    854854         */
    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;
    857857        CPU->rcu.expedite_arriving = false;
    858858
     
    958958                        /* Wait for the GP to complete. */
    959959                        errno_t ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock,
    960                                 SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
     960                            SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
    961961
    962962                        if (ret == EINTR) {
     
    984984        while (!cpu_mask_is_none(reader_cpus)) {
    985985                /* Give cpus a chance to context switch (a QS) and batch callbacks. */
    986                 if(!gp_sleep(&expedite))
     986                if (!gp_sleep(&expedite))
    987987                        return false;
    988988
     
    10151015                errno_t ret = 0;
    10161016                ret = _condvar_wait_timeout_spinlock(&rcu.expedite_now, &rcu.gp_lock,
    1017                         DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE);
     1017                    DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE);
    10181018
    10191019                /* rcu.expedite_now was signaled. */
     
    11451145
    11461146                printf("Bug: thread (id %" PRIu64 " \"%s\") exited while in RCU read"
    1147                         " section.\n", THREAD->tid, THREAD->name);
     1147                    " section.\n", THREAD->tid, THREAD->name);
    11481148        }
    11491149}
     
    12071207         */
    12081208        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) {
    12111211                *completed_gp = compl_gp;
    12121212                return true;
     
    12371237         */
    12381238        if (expedite) {
    1239                 if(0 == rcu.req_expedited_cnt)
     1239                if (0 == rcu.req_expedited_cnt)
    12401240                        condvar_signal(&rcu.expedite_now);
    12411241
     
    12701270        while (rcu.completed_gp < wait_on_gp && !interrupted) {
    12711271                int ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock,
    1272                         SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
     1272                    SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
    12731273                interrupted = (ret == EINTR);
    12741274        }
     
    13301330        while (0 == rcu.req_gp_end_cnt && !interrupted) {
    13311331                int ret = _condvar_wait_timeout_spinlock(&rcu.req_gp_changed,
    1332                         &rcu.gp_lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
     1332                    &rcu.gp_lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
    13331333
    13341334                interrupted = (ret == EINTR);
     
    13951395                /* minor bug: sleeps for the same duration if woken up spuriously. */
    13961396                ret = _condvar_wait_timeout_spinlock(&rcu.expedite_now, &rcu.gp_lock,
    1397                         DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE);
     1397                    DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE);
    13981398        }
    13991399
     
    14791479        int delaying_cpu_cnt = atomic_get(&rcu.delaying_cpu_cnt);
    14801480
    1481         for (int i = 0; i < delaying_cpu_cnt; ++i){
     1481        for (int i = 0; i < delaying_cpu_cnt; ++i) {
    14821482                if (!semaphore_down_interruptable(&rcu.remaining_readers))
    14831483                        return false;
     
    15491549        if (THREAD == rcu.detector_thr) {
    15501550                THREAD->priority = -1;
    1551         }
    1552         else if (THREAD == CPU->rcu.reclaimer_thr) {
     1551        } else if (THREAD == CPU->rcu.reclaimer_thr) {
    15531552                THREAD->priority = -1;
    15541553        }
     
    16061605
    16071606                printf("Bug: thread (id %" PRIu64 " \"%s\") exited while in RCU read"
    1608                         " section.\n", THREAD->tid, THREAD->name);
     1607                    " section.\n", THREAD->tid, THREAD->name);
    16091608        }
    16101609}
     
    18341833
    18351834        printf("Config: expedite_threshold=%d, critical_threshold=%d,"
    1836                 " detect_sleep=%dms, %s\n",
    1837                 EXPEDITE_THRESHOLD, CRITICAL_THRESHOLD, DETECT_SLEEP_MS, algo);
     1835            " detect_sleep=%dms, %s\n",
     1836            EXPEDITE_THRESHOLD, CRITICAL_THRESHOLD, DETECT_SLEEP_MS, algo);
    18381837        printf("Completed GPs: %" PRIu64 "\n", rcu.completed_gp);
    18391838        printf("Expedited GPs: %zu\n", rcu.stat_expedited_cnt);
    18401839        printf("Delayed GPs:   %zu (cpus w/ still running readers after gp sleep)\n",
    1841                 rcu.stat_delayed_cnt);
     1840            rcu.stat_delayed_cnt);
    18421841        printf("Preempt blocked GPs: %zu (waited for preempted readers; "
    1843                 "running or not)\n", rcu.stat_preempt_blocking_cnt);
     1842            "running or not)\n", rcu.stat_preempt_blocking_cnt);
    18441843        printf("Smp calls:     %zu\n", rcu.stat_smp_call_cnt);
    18451844
Note: See TracChangeset for help on using the changeset viewer.