]> git.baikalelectronics.ru Git - kernel.git/commit
srcu: Prevent expedited GPs and blocking readers from consuming CPU
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 8 Mar 2022 23:45:33 +0000 (15:45 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 3 May 2022 17:20:57 +0000 (10:20 -0700)
commit89ab6c3af1599209b084bbc8fcb812eb40f91205
treea89b3241fcd01074c023062015e24de1440f5066
parent8f99373918e4517738ff904366c351a7892a96d4
srcu: Prevent expedited GPs and blocking readers from consuming CPU

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: Song Liu <song@kernel.org>
Tested-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
include/linux/srcutree.h
kernel/rcu/srcutree.c