Skip to content

Commit

Permalink
Ignore zfs_arc_shrinker_limit in direct reclaim mode
Browse files Browse the repository at this point in the history
zfs_arc_shrinker_limit (default: 10000) avoids ARC collapse
due to excessive memory reclaim. However, when the kernel is
in direct reclaim mode (ie: low on memory), limiting ARC reclaim
increases OOM risk. This is especially true on system without
(or with inadequate) swap.

This patch ignores zfs_arc_shrinker_limit when the kernel is in
direct reclaim mode, avoiding most OOM. It also restores
"echo 3 > /proc/sys/vm/drop_caches" ability to correctly drop
(almost) all ARC.

Signed-off-by: Gionatan Danti <[email protected]>
  • Loading branch information
shodanshok committed Jun 29, 2024
1 parent fd51786 commit 3f6c9d6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions module/os/linux/zfs/arc_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ arc_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
*
* See also the comment above zfs_arc_shrinker_limit.
*/
int64_t limit = zfs_arc_shrinker_limit != 0 ?
zfs_arc_shrinker_limit : INT64_MAX;
int64_t limit = INT64_MAX;
if (current_is_kswapd()) {
limit = zfs_arc_shrinker_limit != 0 ?
zfs_arc_shrinker_limit : INT64_MAX;
}
return (MIN(limit, btop((int64_t)arc_evictable_memory())));
}

Expand Down

0 comments on commit 3f6c9d6

Please sign in to comment.