1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Defer setting either PG_CACHED or PG_FREE until after the free page

queues lock is acquired.  Otherwise, the state of a reservation's
pages' flags and its population count can be inconsistent.  That could
result in a page being freed twice.

Reported by:	kris
This commit is contained in:
Alan Cox 2008-01-02 04:43:47 +00:00
parent b028141f0a
commit 273bf93c8d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175055

View File

@ -1332,8 +1332,8 @@ vm_page_free_toq(vm_page_t m)
m->flags &= ~PG_ZERO;
vm_pageq_enqueue(PQ_HOLD, m);
} else {
m->flags |= PG_FREE;
mtx_lock(&vm_page_queue_free_mtx);
m->flags |= PG_FREE;
cnt.v_free_count++;
#if VM_NRESERVLEVEL > 0
if (!vm_reserv_free_page(m))
@ -1584,9 +1584,9 @@ vm_page_cache(vm_page_t m)
* Insert the page into the object's collection of cached pages
* and the physical memory allocator's cache/free page queues.
*/
vm_page_flag_set(m, PG_CACHED);
vm_page_flag_clear(m, PG_ZERO);
mtx_lock(&vm_page_queue_free_mtx);
m->flags |= PG_CACHED;
cnt.v_cache_count++;
root = object->cache;
if (root == NULL) {