Sultan Alsawaf 31fb0c9c1b
mm: Replace shrinker rwsem with fine-grained locks
The shrinker rwsem is problematic because the actual shrinking path must
back off when contention appears, causing some or all shrinkers to be
skipped. This can be especially bad when shrinkers are frequently
registered and unregistered. A high frequency of shrinker registrations/
unregistrations can effectively DoS the shrinker mechanism, rendering it
useless.

We can't use SRCU here because it would unilaterally shift the burden
back onto the registration/unregistration paths, which defeats the
purpose of why the back-off mechanism was added in the first place.

Using fine-grained locks and a rwsem at the per-shrinker level to
protect the shrinker list rather than a global rwsem lets us balance the
burden equally, eliminating the issue. Now, shrinking can happen
concurrently with shrinker registrations/unregistrations, without either
side being favored more than the other.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
2022-04-02 13:37:07 +05:30
..
2022-04-02 13:21:37 +05:30