From 0aa83dce99e47ccd533be24b82332268766b68db Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 14 May 2025 09:29:02 -0400 Subject: [PATCH] Linux: Stop using NR_FILE_PAGES for ARC scaling I've found that QEMU/KVM guest memory accounted as shared also included into NR_FILE_PAGES. But it is actually a non-evictable anonymous memory. Using it as a base for zfs_arc_pc_percent parameter makes ARC to ignore shrinker requests while page cache does not really have anything to evict, ending up in OOM killer killing the QEMU process. Instead use of NR_ACTIVE_FILE + NR_INACTIVE_FILE should represent the part of a page cache that is actually evictable, which should be safer to use as a reference for ARC scaling. Reviewed-by: Brian Behlendorf Reviewed-by: Ameer Hamza Reviewed-by: Pavel Snajdr Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #17334 --- include/os/linux/kernel/linux/page_compat.h | 4 ++-- man/man4/zfs.4 | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/os/linux/kernel/linux/page_compat.h b/include/os/linux/kernel/linux/page_compat.h index 963b96ba6..7dcf53bbe 100644 --- a/include/os/linux/kernel/linux/page_compat.h +++ b/include/os/linux/kernel/linux/page_compat.h @@ -4,8 +4,8 @@ /* * Create our own accessor functions to follow the Linux API changes */ -#define nr_file_pages() global_node_page_state(NR_FILE_PAGES) -#define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON) +#define nr_file_pages() (global_node_page_state(NR_ACTIVE_FILE) + \ + global_node_page_state(NR_INACTIVE_FILE)) #define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE) #endif /* _ZFS_PAGE_COMPAT_H */ diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 index b1a1bbc6a..bdbb468d9 100644 --- a/man/man4/zfs.4 +++ b/man/man4/zfs.4 @@ -877,7 +877,9 @@ pressure on the pagecache, yet still allows the ARC to be reclaimed down to .Sy zfs_arc_min if necessary. This value is specified as percent of pagecache size (as measured by -.Sy NR_FILE_PAGES ) , +.Sy NR_ACTIVE_FILE ++ +.Sy NR_INACTIVE_FILE ) , where that percent may exceed .Sy 100 . This