Date: Mon, 22 Dec 2014 09:02:22 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r276056 - head/sys/vm Message-ID: <201412220902.sBM92MXb013127@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon Dec 22 09:02:21 2014 New Revision: 276056 URL: https://svnweb.freebsd.org/changeset/base/276056 Log: Add flag VM_ALLOC_NOWAIT for vm_page_grab() that prevents sleeping and allows the function to fail. Reviewed by: kib, alc Sponsored by: Nginx, Inc. Modified: head/sys/vm/vm_page.c head/sys/vm/vm_page.h Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Mon Dec 22 09:00:47 2014 (r276055) +++ head/sys/vm/vm_page.c Mon Dec 22 09:02:21 2014 (r276056) @@ -2711,6 +2711,8 @@ retrylookup: sleep = (allocflags & VM_ALLOC_IGN_SBUSY) != 0 ? vm_page_xbusied(m) : vm_page_busied(m); if (sleep) { + if ((allocflags & VM_ALLOC_NOWAIT) != 0) + return (NULL); /* * Reference the page before unlocking and * sleeping so that the page daemon is less @@ -2738,6 +2740,8 @@ retrylookup: } m = vm_page_alloc(object, pindex, allocflags); if (m == NULL) { + if ((allocflags & VM_ALLOC_NOWAIT) != 0) + return (NULL); VM_OBJECT_WUNLOCK(object); VM_WAIT; VM_OBJECT_WLOCK(object); Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Mon Dec 22 09:00:47 2014 (r276055) +++ head/sys/vm/vm_page.h Mon Dec 22 09:02:21 2014 (r276056) @@ -405,6 +405,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa) #define VM_ALLOC_IGN_SBUSY 0x1000 /* (g) Ignore shared busy flag */ #define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */ #define VM_ALLOC_SBUSY 0x4000 /* (acg) Shared busy the page */ +#define VM_ALLOC_NOWAIT 0x8000 /* (g) Do not sleep, return NULL */ #define VM_ALLOC_COUNT_SHIFT 16 #define VM_ALLOC_COUNT(count) ((count) << VM_ALLOC_COUNT_SHIFT)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412220902.sBM92MXb013127>