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
This commit is contained in:
parent
6a3193a773
commit
b417181250
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251280
@ -2724,6 +2724,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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user