Skip to content

Commit

Permalink
Linux: Make zfs_prune() fair on NUMA systems
Browse files Browse the repository at this point in the history
Previous code evicted nr_to_scan items from each node.  This not
only multiplies the eviction by number of nodes, but may totally
exhaust smaller ones, evicting inodes used by the iacive workload
and requiring their immediate recreation.  This patch spreads the
requested eviction between all NUMA nodes proportionally to their
evictable counts, which should be closer to expected LRU logic.

Signed-off-by:	Alexander Motin <[email protected]>
Sponsored by:	iXsystems, Inc.
  • Loading branch information
amotin committed Jul 29, 2024
1 parent b157899 commit 790b3ce
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions module/os/linux/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,14 +1282,22 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects)
defined(SHRINK_CONTROL_HAS_NID) && \
defined(SHRINKER_NUMA_AWARE)
if (shrinker->flags & SHRINKER_NUMA_AWARE) {
long tc = 1;
for_each_online_node(sc.nid) {
long c = shrinker->count_objects(shrinker, &sc);
if (c == 0 || c == SHRINK_EMPTY)
continue;
tc += c;
}
*objects = 0;
for_each_online_node(sc.nid) {
long c = shrinker->count_objects(shrinker, &sc);
if (c == 0 || c == SHRINK_EMPTY)
continue;
if (c > tc)
tc = c;
sc.nr_to_scan = mult_frac(nr_to_scan, c, tc) + 1;
*objects += (*shrinker->scan_objects)(shrinker, &sc);
/*
* reset sc.nr_to_scan, modified by
* scan_objects == super_cache_scan
*/
sc.nr_to_scan = nr_to_scan;
}
} else {
*objects = (*shrinker->scan_objects)(shrinker, &sc);
Expand Down

0 comments on commit 790b3ce

Please sign in to comment.