From 70b81b05ba7b1f669e5197887c4b1ef02e6c6ab8 Mon Sep 17 00:00:00 2001 From: ednadolski-ix <137826107+ednadolski-ix@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:13:01 -0600 Subject: [PATCH] arc_default_max on Linux should match FreeBSD Commits 518b487 and 23bdb07 changed the default ARC size limit on Linux systems to 1/2 of physical memory, which has become too strict for modern systems with large amounts of RAM. This patch changes the default limit to match that of FreeBSD, so ZFS may have a unified value on both platforms. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Edmund Nadolski Closes #15437 --- man/man4/zfs.4 | 5 +---- module/os/linux/zfs/arc_os.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 index 3843419731b8..c5e9dd46fe15 100644 --- a/man/man4/zfs.4 +++ b/man/man4/zfs.4 @@ -638,10 +638,7 @@ Max size of ARC in bytes. If .Sy 0 , then the max size of ARC is determined by the amount of system memory installed. -Under Linux, half of system memory will be used as the limit. -Under -.Fx , -the larger of +The larger of .Sy all_system_memory No \- Sy 1 GiB and .Sy 5/8 No \(mu Sy all_system_memory diff --git a/module/os/linux/zfs/arc_os.c b/module/os/linux/zfs/arc_os.c index 29a8802b8367..381563476daf 100644 --- a/module/os/linux/zfs/arc_os.c +++ b/module/os/linux/zfs/arc_os.c @@ -80,12 +80,18 @@ static struct notifier_block arc_hotplug_callback_mem_nb; /* * Return a default max arc size based on the amount of physical memory. + * This may be overridden by tuning the zfs_arc_max module parameter. */ uint64_t arc_default_max(uint64_t min, uint64_t allmem) { - /* Default to 1/2 of all memory. */ - return (MAX(allmem / 2, min)); + uint64_t size; + + if (allmem >= 1 << 30) + size = allmem - (1 << 30); + else + size = min; + return (MAX(allmem * 5 / 8, size)); } #ifdef _KERNEL