From 0f9f9bcb531db5d98d03e055ac33cfecda97f851 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 24 Oct 2004 06:15:36 +0000 Subject: [PATCH] Introduce VM_ALLOC_NOBUSY, an option to vm_page_alloc() and vm_page_grab() that indicates that the caller does not want a page with its busy flag set. In many places, the global page queues lock is acquired and released just to clear the busy flag on a just allocated page. Both the allocation of the page and the clearing of the busy flag occur while the containing vm object is locked. So, the busy flag might as well never be set. --- sys/vm/vm_page.c | 5 +++-- sys/vm/vm_page.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index d55530905f6..a1f199c6097 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -843,7 +843,7 @@ loop: if (req & VM_ALLOC_ZERO) flags = PG_ZERO | PG_BUSY; } - if (req & VM_ALLOC_NOOBJ) + if (req & (VM_ALLOC_NOBUSY | VM_ALLOC_NOOBJ)) flags &= ~PG_BUSY; m->flags = flags; if (req & VM_ALLOC_WIRED) { @@ -1420,7 +1420,8 @@ retrylookup: } else { if (allocflags & VM_ALLOC_WIRED) vm_page_wire(m); - vm_page_busy(m); + if ((allocflags & VM_ALLOC_NOBUSY) == 0) + vm_page_busy(m); vm_page_unlock_queues(); return (m); } diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index a7f84e8206b..9c9cfba96bd 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -317,6 +317,7 @@ extern struct mtx vm_page_queue_mtx; #define VM_ALLOC_ZERO 0x0040 /* Try to obtain a zeroed page */ #define VM_ALLOC_RETRY 0x0080 /* vm_page_grab() only */ #define VM_ALLOC_NOOBJ 0x0100 /* No associated object */ +#define VM_ALLOC_NOBUSY 0x0200 /* Do not busy the page */ void vm_page_flag_set(vm_page_t m, unsigned short bits); void vm_page_flag_clear(vm_page_t m, unsigned short bits);