Changeset 5b03a72 in mainline


Ignore:
Timestamp:
2012-07-29T17:53:48Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f0fcb04
Parents:
8e3ed06
Message:

rcu: Switched from using THREAD→nesting_cnt to CPU→nesting_cnt as the main nesting count variable. RCU no longer has to mess with pointers to the corrent nesting_cnt (and gets rid of one level of indirection when accessing the nesting count in reader sections).

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/rcu.h

    r8e3ed06 r5b03a72  
    181181
    182182        /* Record a QS if not in a reader critical section. */
    183         if (0 == *CPU->rcu.pnesting_cnt)
     183        if (0 == CPU->rcu.nesting_cnt)
    184184                _rcu_record_qs();
    185185
    186         ++(*CPU->rcu.pnesting_cnt);
     186        ++CPU->rcu.nesting_cnt;
    187187
    188188        preemption_enable();
     
    195195        preemption_disable();
    196196       
    197         if (0 == --(*CPU->rcu.pnesting_cnt)) {
     197        if (0 == --CPU->rcu.nesting_cnt) {
    198198                _rcu_record_qs();
    199199               
  • kernel/generic/include/synch/rcu_types.h

    r8e3ed06 r5b03a72  
    6161        rcu_gp_t last_seen_gp;
    6262       
    63         /** Pointer to the currently used nesting count (THREAD's or CPU's). */
    64         size_t *pnesting_cnt;
    65         /** Temporary nesting count if THREAD is NULL, eg in scheduler(). */
    66         size_t tmp_nesting_cnt;
     63        /** The number of times an RCU reader section is nested on this cpu.
     64         *
     65         * If positive, it is definitely executing reader code. If zero,
     66         * the thread might already be executing reader code thanks to
     67         * cpu instruction reordering.
     68         */
     69        size_t nesting_cnt;
    6770
    6871        /** Callbacks to invoke once the current grace period ends, ie cur_cbs_gp.
     
    128131/** RCU related per-thread data. */
    129132typedef struct rcu_thread_data {
    130         /** The number of times an RCU reader section is nested.
    131          *
    132          * If positive, it is definitely executing reader code. If zero,
    133          * the thread might already be executing reader code thanks to
    134          * cpu instruction reordering.
     133        /**
     134         * Nesting count of the thread's RCU read sections when the thread
     135         * is not running.
    135136         */
    136137        size_t nesting_cnt;
  • kernel/generic/src/synch/rcu.c

    r8e3ed06 r5b03a72  
    225225        CPU->rcu.last_seen_gp = 0;
    226226       
    227         CPU->rcu.pnesting_cnt = &CPU->rcu.tmp_nesting_cnt;
    228         CPU->rcu.tmp_nesting_cnt = 0;
     227        CPU->rcu.nesting_cnt = 0;
    229228       
    230229        CPU->rcu.cur_cbs = 0;
     
    286285         * reader section nesting count while we examine/process it.
    287286         */
    288         ASSERT(&CPU->rcu.tmp_nesting_cnt == CPU->rcu.pnesting_cnt);
    289        
    290         /*
    291          * The thread forgot to exit its reader critical secion.
     287       
     288        /*
     289         * The thread forgot to exit its reader critical section.
    292290         * It is a bug, but rather than letting the entire system lock up
    293291         * forcefully leave the reader section. The thread is not holding
     
    373371{
    374372        preemption_disable();
    375         bool locked = 0 < *CPU->rcu.pnesting_cnt;
     373        bool locked = 0 < CPU->rcu.nesting_cnt;
    376374        preemption_enable();
    377375       
     
    483481{
    484482        /* Calling from a reader section will deadlock. */
    485         ASSERT(THREAD == 0 || 0 == THREAD->rcu.nesting_cnt);
     483        ASSERT(0 == CPU->rcu.nesting_cnt);
    486484       
    487485        synch_item_t completion;
     
    11991197        if (CPU->rcu.last_seen_gp != _rcu_cur_gp) {
    12001198                /* Interrupted a reader in a reader critical section. */
    1201                 if (0 < (*CPU->rcu.pnesting_cnt)) {
     1199                if (0 < CPU->rcu.nesting_cnt) {
    12021200                        ASSERT(!CPU->idle);
    12031201                        /* Note to notify the detector from rcu_read_unlock(). */
     
    12761274{
    12771275        ASSERT(interrupts_disabled());
    1278         ASSERT(CPU->rcu.pnesting_cnt == &THREAD->rcu.nesting_cnt);
     1276       
     1277        /* Save the thread's nesting count when its not running. */
     1278        THREAD->rcu.nesting_cnt = CPU->rcu.nesting_cnt;
     1279        /* Interrupt handlers might use RCU while idle in scheduler(). */
     1280        CPU->rcu.nesting_cnt = 0;
    12791281       
    12801282        /* Preempted a reader critical section for the first time. */
     
    13171319       
    13181320        /*
    1319          * After this point THREAD is 0 and stays 0 until the scheduler()
    1320          * switches to a new thread. Use a temporary nesting counter for readers
    1321          * in handlers of interrupts that are raised while idle in the scheduler.
    1322          */
    1323         CPU->rcu.pnesting_cnt = &CPU->rcu.tmp_nesting_cnt;
    1324 
    1325         /*
    13261321         * Forcefully associate the detector with the highest priority
    13271322         * even if preempted due to its time slice running out.
     
    13551350{
    13561351        ASSERT(PREEMPTION_DISABLED || interrupts_disabled());
    1357         ASSERT(&CPU->rcu.tmp_nesting_cnt == CPU->rcu.pnesting_cnt);
    1358        
    1359         CPU->rcu.pnesting_cnt = &THREAD->rcu.nesting_cnt;
     1352        ASSERT(0 == CPU->rcu.nesting_cnt);
     1353       
     1354        /* Load the thread's saved nesting count from before it was preempted. */
     1355        CPU->rcu.nesting_cnt = THREAD->rcu.nesting_cnt;
    13601356}
    13611357
Note: See TracChangeset for help on using the changeset viewer.