diff options
author | Mark Johnston <markj@FreeBSD.org> | 2020-02-28 16:05:18 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2020-02-28 16:05:18 +0000 |
commit | c99d0c5801ce22a9976e491d04ce7e1b8996dfdd (patch) | |
tree | a7e90d5c78ec00f8619edaaeabf706ab037b1c9c /sys/vm/vm_object.h | |
parent | f37cc7137dc832aec317f0ba0bccde9436b5d9fb (diff) | |
download | src-c99d0c5801ce22a9976e491d04ce7e1b8996dfdd.tar.gz src-c99d0c5801ce22a9976e491d04ce7e1b8996dfdd.zip |
Add a blocking counter KPI.
refcount(9) was recently extended to support waiting on a refcount to
drop to zero, as this was needed for a lockless VM object
paging-in-progress counter. However, this adds overhead to all uses of
refcount(9) and doesn't really match traditional refcounting semantics:
once a counter has dropped to zero, the protected object may be freed at
any point and it is not safe to dereference the counter.
This change removes that extension and instead adds a new set of KPIs,
blockcount_*, for use by VM object PIP and busy.
Reviewed by: jeff, kib, mjg
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23723
Notes
Notes:
svn path=/head/; revision=358432
Diffstat (limited to 'sys/vm/vm_object.h')
-rw-r--r-- | sys/vm/vm_object.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 71ddbe85bf3d..007e945daa77 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -70,6 +70,7 @@ #define _VM_OBJECT_ #include <sys/queue.h> +#include <sys/_blockcount.h> #include <sys/_lock.h> #include <sys/_mutex.h> #include <sys/_pctrie.h> @@ -113,8 +114,8 @@ struct vm_object { objtype_t type; /* type of pager */ u_short flags; /* see below */ u_short pg_color; /* (c) color of first page in obj */ - volatile u_int paging_in_progress; /* Paging (in or out) so don't collapse or destroy */ - volatile u_int busy; /* (a) object is busy, disallow page busy. */ + blockcount_t paging_in_progress; /* (a) Paging (in or out) so don't collapse or destroy */ + blockcount_t busy; /* (a) object is busy, disallow page busy. */ int resident_page_count; /* number of resident pages */ struct vm_object *backing_object; /* object that I'm a shadow of */ vm_ooffset_t backing_object_offset;/* Offset in backing object */ @@ -265,7 +266,7 @@ extern struct vm_object kernel_object_store; lock_class_rw.lc_lock(&(object)->lock.lock_object, (state)) #define VM_OBJECT_ASSERT_PAGING(object) \ - KASSERT((object)->paging_in_progress != 0, \ + KASSERT(blockcount_read(&(object)->paging_in_progress) != 0, \ ("vm_object %p is not paging", object)) #define VM_OBJECT_ASSERT_REFERENCE(object) \ KASSERT((object)->reference_count != 0, \ @@ -348,7 +349,7 @@ static inline bool vm_object_busied(vm_object_t object) { - return (object->busy != 0); + return (blockcount_read(&object->busy) != 0); } #define VM_OBJECT_ASSERT_BUSY(object) MPASS(vm_object_busied((object))) |