Changeset 1b20da0 in mainline for uspace/lib/c/generic/rcu.c


Ignore:
Timestamp:
2018-02-28T17:52:03Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3061bc1
Parents:
df6ded8
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
Message:

style: Remove trailing whitespace on non-empty lines, in certain file types.

Command used: tools/srepl '\([^[:space:]]\)\s\+$' '\1' -- *.c *.h *.py *.sh *.s *.S *.ag

File:
1 edited

Legend:

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

    rdf6ded8 r1b20da0  
    3232/**
    3333 * @file
    34  * 
    35  * User space RCU is based on URCU utilizing signals [1]. This 
    36  * implementation does not however signal each thread of the process 
     34 *
     35 * User space RCU is based on URCU utilizing signals [1]. This
     36 * implementation does not however signal each thread of the process
    3737 * to issue a memory barrier. Instead, we introduced a syscall that
    3838 * issues memory barriers (via IPIs) on cpus that are running threads
    3939 * of the current process. First, it does not require us to schedule
    40  * and run every thread of the process. Second, IPIs are less intrusive 
     40 * and run every thread of the process. Second, IPIs are less intrusive
    4141 * than switching contexts and entering user space.
    42  * 
     42 *
    4343 * This algorithm is further modified to require a single instead of
    4444 * two reader group changes per grace period. Signal-URCU flips
    45  * the reader group and waits for readers of the previous group 
     45 * the reader group and waits for readers of the previous group
    4646 * twice in succession in order to wait for new readers that were
    47  * delayed and mistakenly associated with the previous reader group. 
     47 * delayed and mistakenly associated with the previous reader group.
    4848 * The modified algorithm ensures that the new reader group is
    4949 * always empty (by explicitly waiting for it to become empty).
    5050 * Only then does it flip the reader group and wait for preexisting
    5151 * readers of the old reader group (invariant of SRCU [2, 3]).
    52  * 
    53  * 
     52 *
     53 *
    5454 * [1] User-level implementations of read-copy update,
    5555 *     2012, appendix
    5656 *     http://www.rdrop.com/users/paulmck/RCU/urcu-supp-accepted.2011.08.30a.pdf
    57  * 
     57 *
    5858 * [2] linux/kernel/srcu.c in Linux 3.5-rc2,
    5959 *     2012
    6060 *     http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/kernel/srcu.c?v=linux-3.5-rc2-ccs-1.8.3
    6161 *
    62  * [3] [RFC PATCH 5/5 single-thread-version] implement 
     62 * [3] [RFC PATCH 5/5 single-thread-version] implement
    6363 *     per-domain single-thread state machine,
    6464 *     2012, Lai
     
    162162
    163163/** Registers a fibril so it may start using RCU read sections.
    164  * 
     164 *
    165165 * A fibril must be registered with rcu before it can enter RCU critical
    166166 * sections delineated by rcu_read_lock() and rcu_read_unlock().
     
    178178
    179179/** Deregisters a fibril that had been using RCU read sections.
    180  * 
     180 *
    181181 * A fibril must be deregistered before it exits if it had
    182182 * been registered with rcu via rcu_register_fibril().
     
    186186        assert(fibril_rcu.registered);
    187187       
    188         /* 
     188        /*
    189189         * Forcefully unlock any reader sections. The fibril is exiting
    190190         * so it is not holding any references to data protected by the
    191          * rcu section. Therefore, it is safe to unlock. Otherwise, 
     191         * rcu section. Therefore, it is safe to unlock. Otherwise,
    192192         * rcu_synchronize() would wait indefinitely.
    193193         */
     
    202202}
    203203
    204 /** Delimits the start of an RCU reader critical section. 
    205  * 
    206  * RCU reader sections may be nested. 
     204/** Delimits the start of an RCU reader critical section.
     205 *
     206 * RCU reader sections may be nested.
    207207 */
    208208void rcu_read_lock(void)
     
    252252        lock_sync(blocking_mode);
    253253       
    254         /* 
    255          * Exit early if we were stuck waiting for the mutex for a full grace 
     254        /*
     255         * Exit early if we were stuck waiting for the mutex for a full grace
    256256         * period. Started waiting during gp_in_progress (or gp_in_progress + 1
    257257         * if the value propagated to this cpu too late) so wait for the next
     
    267267        ++ACCESS_ONCE(rcu.cur_gp);
    268268       
    269         /* 
    270          * Pairs up with MB_FORCE_L (ie CC_BAR_L). Makes changes prior 
    271          * to rcu_synchronize() visible to new readers. 
     269        /*
     270         * Pairs up with MB_FORCE_L (ie CC_BAR_L). Makes changes prior
     271         * to rcu_synchronize() visible to new readers.
    272272         */
    273273        memory_barrier(); /* MB_A */
    274274       
    275         /* 
    276          * Pairs up with MB_A. 
    277          * 
     275        /*
     276         * Pairs up with MB_A.
     277         *
    278278         * If the memory barrier is issued before CC_BAR_L in the target
    279279         * thread, it pairs up with MB_A and the thread sees all changes
    280280         * prior to rcu_synchronize(). Ie any reader sections are new
    281          * rcu readers. 
    282          * 
     281         * rcu readers.
     282         *
    283283         * If the memory barrier is issued after CC_BAR_L, it pairs up
    284284         * with MB_B and it will make the most recent nesting_cnt visible
    285285         * in this thread. Since the reader may have already accessed
    286286         * memory protected by RCU (it ran instructions passed CC_BAR_L),
    287          * it is a preexisting reader. Seeing the most recent nesting_cnt 
     287         * it is a preexisting reader. Seeing the most recent nesting_cnt
    288288         * ensures the thread will be identified as a preexisting reader
    289289         * and we will wait for it in wait_for_readers(old_reader_group).
     
    291291        force_mb_in_all_threads(); /* MB_FORCE_L */
    292292       
    293         /* 
     293        /*
    294294         * Pairs with MB_FORCE_L (ie CC_BAR_L, CC_BAR_U) and makes the most
    295295         * current fibril.nesting_cnt visible to this cpu.
     
    321321static void force_mb_in_all_threads(void)
    322322{
    323         /* 
    324          * Only issue barriers in running threads. The scheduler will 
     323        /*
     324         * Only issue barriers in running threads. The scheduler will
    325325         * execute additional memory barriers when switching to threads
    326326         * of the process that are currently not running.
     
    339339        while (!list_empty(&rcu.fibrils_list)) {
    340340                list_foreach_safe(rcu.fibrils_list, fibril_it, next_fibril) {
    341                         fibril_rcu_data_t *fib = member_to_inst(fibril_it, 
     341                        fibril_rcu_data_t *fib = member_to_inst(fibril_it,
    342342                                fibril_rcu_data_t, link);
    343343                       
     
    393393        assert(rcu.sync_lock.locked);
    394394       
    395         /* 
     395        /*
    396396         * Blocked threads have a priority over fibrils when accessing sync().
    397397         * Pass the lock onto a waiting thread.
     
    421421{
    422422        assert(rcu.sync_lock.locked);
    423         /* 
    424          * Release the futex to avoid deadlocks in singlethreaded apps 
    425          * but keep sync locked. 
     423        /*
     424         * Release the futex to avoid deadlocks in singlethreaded apps
     425         * but keep sync locked.
    426426         */
    427427        futex_up(&rcu.sync_lock.futex);
     
    446446static size_t get_other_group(size_t group)
    447447{
    448         if (group == RCU_GROUP_A) 
     448        if (group == RCU_GROUP_A)
    449449                return RCU_GROUP_B;
    450450        else
Note: See TracChangeset for help on using the changeset viewer.