Date: Fri, 9 Jul 2010 19:38:30 +0000 (UTC) From: Alan Cox <alc@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r209861 - in head/sys: kern vm Message-ID: <201007091938.o69JcUII029190@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: alc Date: Fri Jul 9 19:38:30 2010 New Revision: 209861 URL: http://svn.freebsd.org/changeset/base/209861 Log: Add support for the VM_ALLOC_COUNT() hint to vm_page_alloc(). Consequently, the maintenance of vm_pageout_deficit can be localized to just two places: vm_page_alloc() and vm_pageout_scan(). This change also corrects an off-by-one error in the maintenance of vm_pageout_deficit. Historically, the buffer cache functions, allocbuf() and vm_hold_load_pages(), have not taken into account that vm_page_alloc() already increments vm_pageout_deficit by one. Reviewed by: kib Modified: head/sys/kern/vfs_bio.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Fri Jul 9 17:38:15 2010 (r209860) +++ head/sys/kern/vfs_bio.c Fri Jul 9 19:38:30 2010 (r209861) @@ -3752,10 +3752,9 @@ tryagain: * process we are. */ p = vm_page_alloc(NULL, pg >> PAGE_SHIFT, VM_ALLOC_NOOBJ | - VM_ALLOC_SYSTEM | VM_ALLOC_WIRED); + VM_ALLOC_SYSTEM | VM_ALLOC_WIRED | + VM_ALLOC_COUNT((to - pg) >> PAGE_SHIFT)); if (!p) { - atomic_add_int(&vm_pageout_deficit, - (to - pg) >> PAGE_SHIFT); VM_WAIT; goto tryagain; } Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Fri Jul 9 17:38:15 2010 (r209860) +++ head/sys/vm/vm_page.c Fri Jul 9 19:38:30 2010 (r209861) @@ -1264,7 +1264,8 @@ vm_page_alloc(vm_object_t object, vm_pin * Not allocatable, give up. */ mtx_unlock(&vm_page_queue_free_mtx); - atomic_add_int(&vm_pageout_deficit, 1); + atomic_add_int(&vm_pageout_deficit, + MAX((u_int)req >> VM_ALLOC_COUNT_SHIFT, 1)); pagedaemon_wakeup(); return (NULL); } @@ -2041,7 +2042,6 @@ vm_page_t vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags) { vm_page_t m; - u_int count; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); KASSERT((allocflags & VM_ALLOC_RETRY) != 0, @@ -2071,12 +2071,9 @@ retrylookup: } } m = vm_page_alloc(object, pindex, allocflags & ~(VM_ALLOC_RETRY | - VM_ALLOC_IGN_SBUSY | VM_ALLOC_COUNT_MASK)); + VM_ALLOC_IGN_SBUSY)); if (m == NULL) { VM_OBJECT_UNLOCK(object); - count = (u_int)allocflags >> VM_ALLOC_COUNT_SHIFT; - if (count > 0) - atomic_add_int(&vm_pageout_deficit, count); VM_WAIT; VM_OBJECT_LOCK(object); goto retrylookup; Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Fri Jul 9 17:38:15 2010 (r209860) +++ head/sys/vm/vm_page.h Fri Jul 9 19:38:30 2010 (r209861) @@ -321,7 +321,6 @@ extern struct vpglocks vm_page_queue_loc #define VM_ALLOC_COUNT_SHIFT 16 #define VM_ALLOC_COUNT(count) ((count) << VM_ALLOC_COUNT_SHIFT) -#define VM_ALLOC_COUNT_MASK VM_ALLOC_COUNT(0xffff) void vm_page_flag_set(vm_page_t m, unsigned short bits); void vm_page_flag_clear(vm_page_t m, unsigned short bits);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007091938.o69JcUII029190>