• Paul E. McKenney's avatar
    srcu: Prevent expedited GPs and blocking readers from consuming CPU · 282d8998
    Paul E. McKenney authored
    
    
    If an SRCU reader blocks while a synchronize_srcu_expedited() waits for
    that same reader, then that grace period will spawn an endless series of
    workqueue handlers, consuming a full CPU.  This quickly gets pointless
    because consuming more CPU isn't going to make that reader get done
    faster, especially if it is blocked waiting for an external event.
    
    This commit therefore spawns at most one pair of back-to-back workqueue
    handlers per expedited grace period phase, instead inserting increasing
    delays as that grace period phase grows older, but capped at 10 jiffies.
    In any case, if there have been at least 100 back-to-back workqueue
    handlers within a single jiffy, regardless of grace period or grace-period
    phase, then a one-jiffy delay is inserted.
    
    [ paulmck:  Apply feedback from kernel test robot. ]
    
    Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
    Reported-by: default avatarSong Liu <song@kernel.org>
    Tested-by: default avatarkernel test robot <oliver.sang@intel.com>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    282d8998
srcutree.c 57.7 KB