• Andrew Morton's avatar
    [PATCH] rcu lock update: Use a sequence lock for starting batches · 720e8a63
    Andrew Morton authored
    From: Manfred Spraul <manfred@colorfullife.com>
    
    Step two for reducing cacheline trashing within rcupdate.c:
    
    rcu_process_callbacks always acquires rcu_ctrlblk.state.mutex and calls
    rcu_start_batch, even if the batch is already running or already scheduled to
    run.
    
    This can be avoided with a sequence lock: A sequence lock allows to read the
    current batch number and next_pending atomically.  If next_pending is already
    set, then there is no need to acquire the global mutex.
    
    This means that for each grace period, there will be
    
    - one write access to the rcu_ctrlblk.batch cacheline
    
    - lots of read accesses to rcu_ctrlblk.batch (3-10*cpus_online()).  Behavior
      similar to the jiffies cacheline, shouldn't be a problem.
    
    - cpus_online()+1 write accesses to rcu_ctrlblk.state, all of them starting
      with spin_lock(&rcu_ctrlblk.state.mutex).
    
      For large enough cpus_online() this will be a problem, but all except two
      of the spin_lock calls only protect the rcu_cpu_mask bitmap, thus a
      hierarchical bitmap would allow to split the write accesses to multiple
      cachelines.
    
    Tested on an 8-way with reaim.  Unfortunately it probably won't help with Jack
    Steiner's 'ls' test since in this test only one cpu generates rcu entries.
    Signed-off-by: default avatarManfred Spraul <manfred@colorfullife.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    720e8a63
rcupdate.c 10.8 KB