svn commit: r290481 - head/sys/kern

Gleb Smirnoff glebius at FreeBSD.org
Fri Nov 13 22:44:36 UTC 2015


On Sat, Nov 07, 2015 at 04:04:00AM +0000, Adrian Chadd wrote:
A> Author: adrian
A> Date: Sat Nov  7 04:04:00 2015
A> New Revision: 290481
A> URL: https://svnweb.freebsd.org/changeset/base/290481
A> 
A> Log:
A>   Add a sched_yield() to work around low memory conditions in the current code.
A>   
A>   Things seem to get stuck in low memory conditions where no bufs are available,
A>   the reclamation path is called to wakeup the daemon, but no sleeping is done.
A>   Because of this, we are stuck in a tight loop in the current process and
A>   never run said reclamation path.
A>   
A>   This was introduced in r289279 . This is only a temporary workaround
A>   to restore system usefulness until the more permanent solutions can be
A>   found.
A>   
A>   Tested:
A>   
A>   * Carambola2, 64MB (and 32MB by manual config.)
A> 
A> Modified:
A>   head/sys/kern/vfs_bio.c
A> 
A> Modified: head/sys/kern/vfs_bio.c
A> ==============================================================================
A> --- head/sys/kern/vfs_bio.c	Sat Nov  7 02:18:19 2015	(r290480)
A> +++ head/sys/kern/vfs_bio.c	Sat Nov  7 04:04:00 2015	(r290481)
A> @@ -3622,6 +3622,23 @@ loop:
A>  		if (bp == NULL) {
A>  			if (slpflag || slptimeo)
A>  				return NULL;
A> +			/*
A> +			 * XXX This is here until the sleep path is diagnosed
A> +			 * enough to work under very low memory conditions.
A> +			 *
A> +			 * There's an issue on low memory, 4BSD+non-preempt
A> +			 * systems (eg MIPS routers with 32MB RAM) where buffer
A> +			 * exhaustion occurs without sleeping for buffer
A> +			 * reclaimation.  This just sticks in a loop and
A> +			 * constantly attempts to allocate a buffer, which
A> +			 * hits exhaustion and tries to wakeup bufdaemon.
A> +			 * This never happens because we never yield.
A> +			 *
A> +			 * The real solution is to identify and fix these cases
A> +			 * so we aren't effectively busy-waiting in a loop
A> +			 * until the reclaimation path has cycles to run.
A> +			 */
A> +			kern_yield(PRI_USER);
A>  			goto loop;
A>  		}

It'll be nice if such crutches have a test case in src/tests, and a
reference to it in the comment above. So that in future, someone
considering that the crutch is no longer needed, can quickly check that
assumption.

-- 
Totus tuus, Glebius.


More information about the svn-src-head mailing list