Changeset 99022de in mainline


Ignore:
Timestamp:
2012-11-23T01:23:17Z (11 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a2f42e5
Parents:
0a597d7
Message:

urcu: Added early exit for rcu_synchronize() if it was stuck waiting for rcu fibril mutex for too long.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/urcu/rcu.c

    r0a597d7 r99022de  
    9494typedef struct rcu_data {
    9595        fibril_mutex_t mtx;
     96        size_t cur_gp;
    9697        size_t reader_group;
    9798        futex_t list_futex;
     
    106107static rcu_data_t rcu = {
    107108        .mtx = FIBRIL_MUTEX_INITIALIZER(rcu.mtx),
     109        .cur_gp = 0,
    108110        .reader_group = RCU_GROUP_A,
    109111        .list_futex = FUTEX_INITIALIZER,
     
    183185void rcu_synchronize(void)
    184186{
     187        /* Contain load of rcu.cur_gp. */
     188        memory_barrier();
     189
     190        /* Approximately the number of the GP in progress. */
     191        size_t gp_in_progress = ACCESS_ONCE(rcu.cur_gp);
     192       
     193        /* todo: early exit for batched sync()s */
     194        fibril_mutex_lock(&rcu.mtx);
     195       
     196        /*
     197         * Exit early if we were stuck waiting for the mutex for a full grace
     198         * period. Started waiting during gp_in_progress (or gp_in_progress + 1
     199         * if the value propagated to this cpu too late) so wait for the next
     200         * full GP, gp_in_progress + 1, to finish. Ie don't wait if the GP
     201         * after that, gp_in_progress + 2, already started.
     202         */
     203        if (rcu.cur_gp + 2 >= gp_in_progress) {
     204                fibril_mutex_unlock(&rcu.mtx);
     205                return;
     206        }
     207       
     208        ++ACCESS_ONCE(rcu.cur_gp);
     209       
    185210        /*
    186211         * Pairs up with MB_FORCE_L (ie CC_BAR_L). Makes changes prior
     
    188213         */
    189214        memory_barrier(); /* MB_A */
    190        
    191         /* todo: early exit for batched sync()s */
    192         fibril_mutex_lock(&rcu.mtx);
    193215       
    194216        /*
Note: See TracChangeset for help on using the changeset viewer.