Skip to content

Commit c534f7c

Browse files
Qi Zhengakpm00
authored andcommitted
Revert "mm: vmscan: hold write lock to reparent shrinker nr_deferred"
This reverts commit b3cabea. Kernel test robot reports -88.8% regression in stress-ng.ramfs.ops_per_sec test case [1], which is caused by commit f95bdb7 ("mm: vmscan: make global slab shrink lockless"). The root cause is that SRCU has to be careful to not frequently check for SRCU read-side critical section exits. Therefore, even if no one is currently in the SRCU read-side critical section, synchronize_srcu() cannot return quickly. That's why unregister_shrinker() has become slower. We will try to use the refcount+RCU method [2] proposed by Dave Chinner to continue to re-implement the lockless slab shrink. Because there will be other readers after reverting the shrinker_srcu related changes, so it is better to restore to hold read lock to reparent shrinker nr_deferred. [1]. https://lore.kernel.org/lkml/[email protected]/ [2]. https://lore.kernel.org/lkml/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Qi Zheng <[email protected]> Cc: Dave Chinner <[email protected]> Cc: Kirill Tkhai <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 07252b0 commit c534f7c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/vmscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg)
433433
parent = root_mem_cgroup;
434434

435435
/* Prevent from concurrent shrinker_info expand */
436-
down_write(&shrinker_rwsem);
436+
down_read(&shrinker_rwsem);
437437
for_each_node(nid) {
438438
child_info = shrinker_info_protected(memcg, nid);
439439
parent_info = shrinker_info_protected(parent, nid);
@@ -442,7 +442,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg)
442442
atomic_long_add(nr, &parent_info->nr_deferred[i]);
443443
}
444444
}
445-
up_write(&shrinker_rwsem);
445+
up_read(&shrinker_rwsem);
446446
}
447447

448448
static bool cgroup_reclaim(struct scan_control *sc)

0 commit comments

Comments
 (0)