diff options
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_page.c | 23 | ||||
-rw-r--r-- | sys/vm/vm_page.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index c1817d5..dc391cb 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1304,6 +1304,29 @@ vm_page_try_to_cache(vm_page_t m) } /* + * vm_page_try_to_free() + * + * Attempt to free the page. If we cannot free it, we do nothing. + * 1 is returned on success, 0 on failure. + */ +int +vm_page_try_to_free(m) + vm_page_t m; +{ + if (m->dirty || m->hold_count || m->busy || m->wire_count || + (m->flags & (PG_BUSY|PG_UNMANAGED))) { + return(0); + } + vm_page_test_dirty(m); + if (m->dirty) + return(0); + vm_page_busy(m); + vm_page_protect(m, VM_PROT_NONE); + vm_page_free(m); + return(1); +} + +/* * vm_page_cache * * Put the specified page onto the page cache queue (if appropriate). diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index e1c1cc4..6bc7266 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -421,6 +421,7 @@ vm_page_t vm_page_alloc __P((vm_object_t, vm_pindex_t, int)); vm_page_t vm_page_grab __P((vm_object_t, vm_pindex_t, int)); void vm_page_cache __P((register vm_page_t)); int vm_page_try_to_cache __P((vm_page_t)); +int vm_page_try_to_free __P((vm_page_t)); void vm_page_dontneed __P((register vm_page_t)); static __inline void vm_page_copy __P((vm_page_t, vm_page_t)); static __inline void vm_page_free __P((vm_page_t)); |