NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/57558: pgdaemon 100% busy - no scanning (ZFS case)



The following reply was made to PR kern/57558; it has been noted by GNATS.

From: Frank Kardel <kardel%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/57558: pgdaemon 100% busy - no scanning (ZFS case)
Date: Thu, 2 May 2024 10:49:17 +0200

 This is a multi-part message in MIME format.
 --------------AA25A9A6F0B7E95C7A6B2F0F
 Content-Type: text/plain; charset=utf-8; format=flowed
 Content-Transfer-Encoding: 7bit
 
 In order to prevent the pagedaemon looping and kva space being exhausted
 ZFS not only needs to ensure that uvmexp.freetarg pages are free but 
 also that
 the at least 10% free kva is obeyed for the sake of the pagedaemon/kva 
 free space.
 
 Thus arc..c needs an additional check to determine needfree if the kva 
 free space falls below
 10%.
 
 This was tested with the db load scenario on a Xen DOMU with GENERIC 
 kernel and
 360GB memory. The system stayed responsive an used around 270-319GB pool 
 space, ZFS cut back on pool memory when needed.
 In another test a runaway memory consumer got the pool space used to cut 
 back
 from 319 GB to 51GB before hitting "out of swap space".
 
 
 
 
 
 
 
 
 --------------AA25A9A6F0B7E95C7A6B2F0F
 Content-Type: text/x-patch;
  name="arc.c.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="arc.c.diff"
 
 Index: arc.c
 ===================================================================
 RCS file: /cvsroot/src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c,v
 retrieving revision 1.22
 diff -u -r1.22 arc.c
 --- arc.c	3 Aug 2022 01:53:06 -0000	1.22
 +++ arc.c	2 May 2024 08:38:40 -0000
 @@ -3903,6 +3903,31 @@
  	free_memory_reason_t r = FMR_UNKNOWN;
  
  #ifdef _KERNEL
 +#ifdef __NetBSD__
 +	vmem_size_t totalpercent;
 +	vmem_size_t free;
 +
 +	/*
 +	 * PR kern/57558:
 +	 *
 +	 * do not let pdaemon get stuck in the uvm_km_va_starved_p()
 +	 * state. it starts a tight loop when in uvm_km_va_starved state
 +	 * and ZFS is not freeing any pool pages as it started freeing
 +	 * only when falling below uvmexp.freetarg.
 +	 * now we start freeing when falling below 10% kva free or
 +	 * uvmexp.freetarg.
 +	 * the 10% magic is shamelessly copied from uvm_km_va_starved_p()
 +	 * The interface to the pagedaemon has room for improvement.
 +	 */
 +
 +	totalpercent = vmem_size(heap_arena, VMEM_ALLOC|VMEM_FREE) / 10;
 +	free = vmem_size(heap_arena, VMEM_FREE);
 +
 +	if (free < totalpercent) {
 +		needfree = btop(totalpercent - free);
 +	}
 +#endif
 +
  	if (needfree > 0) {
  		n = PAGESIZE * (-needfree);
  		if (n < lowest) {
 
 --------------AA25A9A6F0B7E95C7A6B2F0F--
 


Home | Main Index | Thread Index | Old Index