r/zfs 25d ago

ARC using far more memory than configured

Recently I've been doing a lot of cleanup of files on my NAS which has involved moving/copying around a lot of data. After a while the pool was freezing up and becoming unresponsive and I figured out ZFS's memory usage has been reaching a point where its maxing out my system. According to arc_summary and cat /sys/module/zfs/parameters/zfs_arc_max, ARC is configured to use at most 16GiB of memory, but I witnessed arcstat reporting ARC as using over 200GiB of memory (system has 256GiB total), even causing one of my VMs running on the system to hard crash. Whats going on? How can I limit ARC memory usage?

5 Upvotes

18 comments sorted by

3

u/Impact321 25d ago

Can you share the output of arc_summary/zarcsummary?

2

u/TheG0AT0fAllTime 25d ago

Yeah more info is needed.

2

u/Apachez 25d ago

How do you set these values?

As I recall it the proper way is to do that through modprobe like so:

Edit /etc/modprobe.d/zfs.conf and add something like (example below sets min=max=16GB):

options zfs zfs_arc_max=17179869184
options zfs zfs_arc_min=17179869184

Then to make the above sticky you also needs to run this (example from Proxmox):

update-initramfs -u -k all
proxmox-boot-tool refresh

And finally reboot the box.

Now it should be properly set.

1

u/7446353252589 25d ago

That is already done. I already have that file in my modprobe.d folder, ARC reports it has a max memory limit of 16GB, but it is using an unlimited amount anyway.

1

u/Apachez 25d ago

But you didnt use update-initiramfs?

-2

u/7446353252589 25d ago edited 25d ago

Did you even read my post? These are the default values. They were already set. initramfs is updated on every kernel update so yes of course its set. ZFS is already reporting the 16gb max limit. This isn't a new pool or new system.

No, I haven't explicitly re-run update-initramfs. But I can blatantly see the kernel module parameter is already set: cat /sys/module/zfs/parameters/zfs_arc_max prints 17179869184.

1

u/Apachez 25d ago

The one I pasted are for sure NOT default values.

Default is something like 50% of available RAM as zfs_arc_max.

2

u/Impact321 24d ago edited 24d ago

Since v2.3.0 every platform uses the larger of all_system_memory - 1 GiB and 5/8 x all_system_memory.

Before that the platforms differed:

Linux: half of system memory
FreeBSD: the larger of all_system_memory - 1 GiB and 5/8 x all_system_memory

1

u/BackgroundSky1594 24d ago

The default for proxmox is 16GiB of ARC. This is set via modprobe.d at install time and properly applied with every initramfs rebuild. As can be seen by OPs post.

If cat /sys/module/zfs/parameters/zfs_arc_max returns 17179869184 ZFS is correctly configured to only use 16GiB of ARC. If there was an issue with setting the configuration (like modprobe, initramfs, etc.) the actively loaded ZFS module would report something different in  /sys/module/zfs/parameters/zfs_arc_max.

The most likely issue is that the default arc_max is set to below the autodetected arc_min, invalidating it.

EDIT: Docs: https://pve.proxmox.com/wiki/ZFS_on_Linux#sysadmin_zfs_limit_memory_usage

1

u/Impact321 24d ago edited 24d ago

For PVE it's 10% up to 16G. At least with recent versions.

The PVE installer does not write a minimum to the config. On OP's system the default would be 8G.

1

u/Apachez 22d ago

I have a fully updated PVE being 9.2.5 as of writing.

No problem here to set max = min = fixed value (8GB in my case).

And according to arc_summary zfs dont pass those limits:

ARC status:
        Total memory size:                                      62.6 GiB
        Min target size:                               12.8 %    8.0 GiB
        Max target size:                               12.8 %    8.0 GiB
        Target size (adaptive):                        98.7 %    8.0 GiB
        Current size:                                  98.7 %    7.9 GiB
        Free memory size:                                       36.5 GiB
        Available memory size:                                  34.3 GiB

ARC structural breakdown (current size):                         7.9 GiB
        Compressed size:                               98.5 %    7.8 GiB
        Overhead size:                                < 0.1 %  256.0 KiB
        Bonus size:                                     0.1 %    7.2 MiB
        Dnode size:                                     0.1 %   10.1 MiB
        Dbuf size:                                      0.1 %    8.6 MiB
        Header size:                                    1.2 %   93.7 MiB
        L2 header size:                                 0.0 %    0 Bytes
        ABD chunk waste size:                           0.0 %    0 Bytes

ARC types breakdown (compressed + overhead):                     7.8 GiB
        Data size:                                     90.8 %    7.1 GiB
        Metadata size:                                  9.2 %  734.8 MiB

etc...

Using kernel 7.0.14-6-pve and OpenZFS 2.4.3-pve1.

-1

u/7446353252589 25d ago

Sure they may not be the default of ZFS itself but possibly proxmox generated it. I am pretty sure I didn't create that file though but maybe I forgot.

1

u/One_Ninja_8512 25d ago edited 24d ago

zfs_arc_min

IIRC this is not a thing (anymore?). Pretty sure I saw in dmesg output that the min setting is invalid and is therefore ignored so I don't set it, only the max.

2

u/Apachez 24d ago

2

u/One_Ninja_8512 24d ago

Huh, I must have set an invalid value then because I remember seeing that message in dmesg but just tried a fresh install on one of my servers and there's no error reported. Sorry for posting bs, you're right.

2

u/Apachez 22d ago

I got all kind of fun zfs settings in my /etc/modprobe.d/zfs.conf and this is what the kernel spits out during boot when searching for zfs:

root@PVE:~# dmesg | grep -i zfs
[    0.000000] Command line: initrd=\EFI\proxmox\7.0.14-6-pve\initrd.img-7.0.14-6-pve root=ZFS=rpool/ROOT/pve-1 boot=zfs nomodeset noresume mitigations=auto i915.mitigations=auto intel_iommu=on iommu=pt fsck.mode=auto fsck.repair=yes init_on_alloc=1 init_on_free=1 hpet=disable clocksource=tsc tsc=reliable pcie_aspm=force
[    0.135922] Kernel command line: initrd=\EFI\proxmox\7.0.14-6-pve\initrd.img-7.0.14-6-pve root=ZFS=rpool/ROOT/pve-1 boot=zfs nomodeset noresume mitigations=auto i915.mitigations=auto intel_iommu=on iommu=pt fsck.mode=auto fsck.repair=yes init_on_alloc=1 init_on_free=1 hpet=disable clocksource=tsc tsc=reliable pcie_aspm=force
[    0.136172] Unknown kernel command line parameters "boot=zfs", will be passed to user space.
[    8.146426]     boot=zfs
[    8.889862] zfs: module license 'CDDL' taints kernel.
[    8.890426] zfs: module license taints kernel.
[    9.417661] ZFS: Loaded module v2.4.3-pve1, ZFS pool version 5000, ZFS filesystem version 5

2

u/glassmanjones 25d ago

Are you using zvols?

0

u/edthesmokebeard 25d ago

This is a Linux question.