diff options
author | alc <alc@FreeBSD.org> | 2002-05-04 20:23:48 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2002-05-04 20:23:48 +0000 |
commit | c281c83bd5bf4d6045f082692f107fd7781140a3 (patch) | |
tree | 7846226132e03d6288f141434b92a11b8050e604 /sys | |
parent | 8ffbddb82f212c7ce9a879dd1387cb7e60f22692 (diff) | |
download | FreeBSD-src-c281c83bd5bf4d6045f082692f107fd7781140a3.zip FreeBSD-src-c281c83bd5bf4d6045f082692f107fd7781140a3.tar.gz |
o Make _vm_object_allocate() and vm_object_allocate() callable
without holding Giant.
o Begin documenting the trivial cases of the locking protocol
on vm_object.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vm/vm_object.c | 36 | ||||
-rw-r--r-- | sys/vm/vm_object.h | 7 |
2 files changed, 21 insertions, 22 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 5d13cac..1c47fa7 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -146,8 +146,6 @@ extern int vm_pageout_page_count; static long object_collapses; static long object_bypasses; -static int next_index; -static int object_hash_rand; static uma_zone_t obj_zone; #define VM_OBJECTS_INIT 256 @@ -190,9 +188,9 @@ vm_object_zinit(void *mem, int size) void _vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object) { - int incr; - - GIANT_REQUIRED; + static int next_index; + static int object_hash_rand; + int exp, incr; TAILQ_INIT(&object->memq); TAILQ_INIT(&object->shadow_head); @@ -203,12 +201,14 @@ _vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object) object->flags = 0; if ((object->type == OBJT_DEFAULT) || (object->type == OBJT_SWAP)) vm_object_set_flag(object, OBJ_ONEMAPPING); - object->pg_color = next_index; - if (size > (PQ_L2_SIZE / 3 + PQ_PRIME1)) - incr = PQ_L2_SIZE / 3 + PQ_PRIME1; - else - incr = size; - next_index = (next_index + incr) & PQ_L2_MASK; + do { + object->pg_color = next_index; + if (size > (PQ_L2_SIZE / 3 + PQ_PRIME1)) + incr = PQ_L2_SIZE / 3 + PQ_PRIME1; + else + incr = size; + } while (!atomic_cmpset_int(&next_index, object->pg_color, + (object->pg_color + incr) & PQ_L2_MASK)); object->handle = NULL; object->backing_object = NULL; object->backing_object_offset = (vm_ooffset_t) 0; @@ -218,15 +218,16 @@ _vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object) * increments plus 1 more to offset it a little more by the time * it wraps around. */ - object->hash_rand = object_hash_rand - 129; + do { + exp = object_hash_rand; + object->hash_rand = exp - 129; + } while (!atomic_cmpset_int(&object_hash_rand, exp, object->hash_rand)); - object->generation++; + object->generation++; /* atomicity needed? XXX */ mtx_lock(&vm_object_list_mtx); TAILQ_INSERT_TAIL(&vm_object_list, object, object_list); mtx_unlock(&vm_object_list_mtx); - - object_hash_rand = object->hash_rand; } /* @@ -237,8 +238,6 @@ _vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object) void vm_object_init(void) { - GIANT_REQUIRED; - TAILQ_INIT(&vm_object_list); mtx_init(&vm_object_list_mtx, "vm object_list", NULL, MTX_DEF); @@ -267,7 +266,6 @@ vm_object_init2(void) void vm_object_set_flag(vm_object_t object, u_short bits) { - GIANT_REQUIRED; object->flags |= bits; } @@ -347,8 +345,6 @@ vm_object_allocate(objtype_t type, vm_size_t size) { vm_object_t result; - GIANT_REQUIRED; - result = (vm_object_t) uma_zalloc(obj_zone, M_WAITOK); _vm_object_allocate(type, size, result); diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 62244a9..97f12de 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -82,6 +82,9 @@ typedef u_char objtype_t; * * vm_object_t Virtual memory object. * + * List of locks + * (c) const until freed + * */ struct vm_object { @@ -93,10 +96,10 @@ struct vm_object { vm_size_t size; /* Object size */ int ref_count; /* How many refs?? */ int shadow_count; /* how many objects that this is a shadow for */ - int hash_rand; /* vm hash table randomizer */ + int hash_rand; /* (c) hash table randomizer */ objtype_t type; /* type of pager */ u_short flags; /* see below */ - u_short pg_color; /* color of first page in obj */ + u_short pg_color; /* (c) color of first page in obj */ u_short paging_in_progress; /* Paging (in or out) so don't collapse or destroy */ int resident_page_count; /* number of resident pages */ struct vm_object *backing_object; /* object that I'm a shadow of */ |