]> git.proxmox.com Git - mirror_zfs.git/commit
Fix ARC ghost states eviction accounting
authorAlexander Motin <mav@FreeBSD.org>
Tue, 13 Jul 2021 15:41:59 +0000 (11:41 -0400)
committerGitHub <noreply@github.com>
Tue, 13 Jul 2021 15:41:59 +0000 (09:41 -0600)
commitf7de776da2ee4b703529035975fd3216b4bacc7a
treedf330b087b4e08f40a4e94c79dfb61e1f8aea6f1
parent07a4c76e9016fad22f1ce2613ab5abc4b2652114
Fix ARC ghost states eviction accounting

arc_evict_hdr() returns number of evicted bytes in scope of specific
state.  For ghost states it does not mean the amount of really freed
memory, but the logical buffer size.  It is correct for the eviction
process, but not for waking up threads waiting for ARC size reduction,
as added in "Revise ARC shrinker algorithm" commit, causing premature
wakeups while ARC is still overflowed, allowing even bigger overflow,
plus processing overhead when next allocation will also get blocked,
probably also for too short time.

To fix that make arc_evict_hdr() also return the amount of really
freed memory, which for the ghost states is only the header, and use
it to update arc_evict_count instead.  Originally I was thinking to
not return it at all, since arc_get_data_impl() does not account for
the headers, but decided that some slow allocation progress is better
than long waits, reaching on my tests up to 100ms.

To reduce negative latency effects of long time periods when reclaim
thread can free little real memory, start reclamation process earlier,
before we actually reached the overflow threshold, when we have to
throttle new allocations.  We can also do it without taking global
arc_evict_lock, reducing the contention.

Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #12279
include/sys/arc_impl.h
man/man4/zfs.4
module/os/freebsd/zfs/arc_os.c
module/zfs/arc.c