• Roman Gushchin's avatar
    percpu: optimize locking in pcpu_balance_workfn() · e4d77700
    Roman Gushchin authored
    
    
    pcpu_balance_workfn() unconditionally calls pcpu_balance_free(),
    pcpu_reclaim_populated(), pcpu_balance_populated() and
    pcpu_balance_free() again.
    
    Each call to pcpu_balance_free() and pcpu_reclaim_populated() will
    cause at least one acquisition of the pcpu_lock. So even if the
    balancing was scheduled because of a failed atomic allocation,
    pcpu_lock will be acquired at least 4 times. This obviously
    increases the contention on the pcpu_lock.
    
    To optimize the scheme let's grab the pcpu_lock on the upper level
    (in pcpu_balance_workfn()) and keep it generally locked for the whole
    duration of the scheduled work, but release conditionally to perform
    any slow operations like chunk (de)population and creation of new
    chunks.
    Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
    Signed-off-by: default avatarDennis Zhou <dennis@kernel.org>
    e4d77700
percpu.c 100 KB