freebsd-dev/include
Mark Johnston 6e2a59181e
Avoid memory allocations in the ARC eviction thread
When the eviction thread goes to shrink an ARC state, it allocates a set
of marker buffers used to hold its place in the state's sublists.

This can be problematic in low memory conditions, since
1) the allocation can be substantial, as we allocate NCPU markers;
2) on at least FreeBSD, page reclamation can block in
   arc_wait_for_eviction()

In particular, in stress tests it's possible to hit a deadlock on
FreeBSD when the number of free pages is very low, wherein the system is
waiting for the page daemon to reclaim memory, the page daemon is
waiting for the ARC eviction thread to finish, and the ARC eviction
thread is blocked waiting for more memory.

Try to reduce the likelihood of such deadlocks by pre-allocating markers
for the eviction thread at ARC initialization time.  When evicting
buffers from an ARC state, check to see if the current thread is the ARC
eviction thread, and use the pre-allocated markers for that purpose
rather than dynamically allocating them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #12985
2022-01-21 10:28:13 -08:00
..
os libspl: ASSERT*: !! for sizeof 2022-01-21 10:20:11 -08:00
sys Avoid memory allocations in the ARC eviction thread 2022-01-21 10:28:13 -08:00
.gitignore OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
cityhash.h libzfs: convert to -fvisibility=hidden 2021-06-03 13:17:55 -07:00
libnvpair.h lib{efi,avl,share,tpool,zfs_core,zfsbootenv,zutil}: -fvisibility=hidden 2021-06-09 17:04:32 -07:00
libuutil_common.h Support custom build directories and move includes 2010-09-08 12:38:56 -07:00
libuutil_impl.h Replace /*PRINTFLIKEn*/ with attribute(printf) 2021-07-26 12:07:15 -07:00
libuutil.h Replace /*PRINTFLIKEn*/ with attribute(printf) 2021-07-26 12:07:15 -07:00
libzfs_core.h Vdev Properties Feature 2021-11-30 07:46:25 -07:00
libzfs.h module/*.ko: prune .data, global .rodata 2022-01-14 15:37:55 -08:00
libzfsbootenv.h lib{efi,avl,share,tpool,zfs_core,zfsbootenv,zutil}: -fvisibility=hidden 2021-06-09 17:04:32 -07:00
libzutil.h Simplify and document OpenZFS library dependencies 2021-10-07 11:31:26 -06:00
Makefile.am libzfs: don't distribute libzfs_impl.h 2021-06-03 13:17:35 -07:00
thread_pool.h lib{efi,avl,share,tpool,zfs_core,zfsbootenv,zutil}: -fvisibility=hidden 2021-06-09 17:04:32 -07:00
zfeature_common.h libzfs: convert to -fvisibility=hidden 2021-06-03 13:17:55 -07:00
zfs_comutil.h module/*.ko: prune .data, global .rodata 2022-01-14 15:37:55 -08:00
zfs_deleg.h module/*.ko: prune .data, global .rodata 2022-01-14 15:37:55 -08:00
zfs_fletcher.h libzfs: convert to -fvisibility=hidden 2021-06-03 13:17:55 -07:00
zfs_namecheck.h libzfs: convert to -fvisibility=hidden 2021-06-03 13:17:55 -07:00
zfs_prop.h zcommon: pre-iterate over sysfs instead of statting every feature 2021-12-16 16:43:10 -08:00