Skip to content

Commit 0aa83dc

Browse files
authored
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 <[email protected]> Reviewed-by: Ameer Hamza <[email protected]> Reviewed-by: Pavel Snajdr <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes openzfs#17334
1 parent b55256e commit 0aa83dc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/os/linux/kernel/linux/page_compat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
/*
55
* Create our own accessor functions to follow the Linux API changes
66
*/
7-
#define nr_file_pages() global_node_page_state(NR_FILE_PAGES)
8-
#define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON)
7+
#define nr_file_pages() (global_node_page_state(NR_ACTIVE_FILE) + \
8+
global_node_page_state(NR_INACTIVE_FILE))
99
#define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE)
1010

1111
#endif /* _ZFS_PAGE_COMPAT_H */

man/man4/zfs.4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,9 @@ pressure on the pagecache, yet still allows the ARC to be reclaimed down to
877877
.Sy zfs_arc_min
878878
if necessary.
879879
This value is specified as percent of pagecache size (as measured by
880-
.Sy NR_FILE_PAGES ) ,
880+
.Sy NR_ACTIVE_FILE
881+
+
882+
.Sy NR_INACTIVE_FILE ) ,
881883
where that percent may exceed
882884
.Sy 100 .
883885
This

0 commit comments

Comments
 (0)