diff options
author | alc <alc@FreeBSD.org> | 2013-06-03 01:22:54 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2013-06-03 01:22:54 +0000 |
commit | 17993ced1b8bde5d02a6fa8fe966058a330ba5b2 (patch) | |
tree | c27fe59254b72779ab022da2ffc0aa1237f02da8 /sys/vm | |
parent | 65a84eb69172562654a06edf22d47a0a80d57b4f (diff) | |
download | FreeBSD-src-17993ced1b8bde5d02a6fa8fe966058a330ba5b2.zip FreeBSD-src-17993ced1b8bde5d02a6fa8fe966058a330ba5b2.tar.gz |
Require that the page lock is held, instead of the object lock, when
clearing the page's PGA_REFERENCED flag. Since we are typically
manipulating the page's act_count field when we are clearing its
PGA_REFERENCED flag, the page lock is already held everywhere that we clear
the PGA_REFERENCED flag. So, in fact, this revision only changes some
comments and an assertion. Nonetheless, it will enable later changes to
object locking in the pageout code.
Introduce vm_page_assert_locked(), which completely hides the implementation
details of the page lock from the caller, and use it in
vm_page_aflag_clear(). (The existing vm_page_lock_assert() could not be
used in vm_page_aflag_clear().) Over the coming weeks, I expect that we'll
either eliminate or replace the various uses of vm_page_lock_assert() with
vm_page_assert_locked().
Reviewed by: attilio
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_page.c | 7 | ||||
-rw-r--r-- | sys/vm/vm_page.h | 16 |
2 files changed, 16 insertions, 7 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 5a1c055..b6fbb93 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2725,6 +2725,13 @@ vm_page_trylock_KBI(vm_page_t m, const char *file, int line) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) void +vm_page_assert_locked_KBI(vm_page_t m, const char *file, int line) +{ + + vm_page_lock_assert_KBI(m, MA_OWNED, file, line); +} + +void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line) { diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 6179a6d..c1d4b2a 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -229,9 +229,12 @@ extern struct mtx_padalign pa_lock[]; #define vm_page_trylock(m) mtx_trylock(vm_page_lockptr((m))) #endif #if defined(INVARIANTS) +#define vm_page_assert_locked(m) \ + vm_page_assert_locked_KBI((m), __FILE__, __LINE__) #define vm_page_lock_assert(m, a) \ vm_page_lock_assert_KBI((m), (a), __FILE__, __LINE__) #else +#define vm_page_assert_locked(m) #define vm_page_lock_assert(m, a) #endif @@ -240,10 +243,9 @@ extern struct mtx_padalign pa_lock[]; * these flags, the functions vm_page_aflag_set() and vm_page_aflag_clear() * must be used. Neither these flags nor these functions are part of the KBI. * - * PGA_REFERENCED may be cleared only if the object containing the page is - * locked. It is set by both the MI and MD VM layers. However, kernel - * loadable modules should not directly set this flag. They should call - * vm_page_reference() instead. + * PGA_REFERENCED may be cleared only if the page is locked. It is set by + * both the MI and MD VM layers. However, kernel loadable modules should not + * directly set this flag. They should call vm_page_reference() instead. * * PGA_WRITEABLE is set exclusively on managed pages by pmap_enter(). When it * does so, the page must be VPO_BUSY. The MI VM layer must never access this @@ -424,6 +426,7 @@ void vm_page_lock_KBI(vm_page_t m, const char *file, int line); void vm_page_unlock_KBI(vm_page_t m, const char *file, int line); int vm_page_trylock_KBI(vm_page_t m, const char *file, int line); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) +void vm_page_assert_locked_KBI(vm_page_t m, const char *file, int line); void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line); #endif @@ -451,11 +454,10 @@ vm_page_aflag_clear(vm_page_t m, uint8_t bits) uint32_t *addr, val; /* - * The PGA_REFERENCED flag can only be cleared if the object - * containing the page is locked. + * The PGA_REFERENCED flag can only be cleared if the page is locked. */ if ((bits & PGA_REFERENCED) != 0) - VM_PAGE_OBJECT_LOCK_ASSERT(m); + vm_page_assert_locked(m); /* * Access the whole 32-bit word containing the aflags field with an |