mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-01 10:43:32 +00:00
Changed object hash list to be a list rather than a tailq. This saves
space for the hash list buckets and is a little faster. The features of tailq aren't needed. Increased the size of the object hash table to improve performance. In the future, this will be changed so that the table is sized dynamically.
This commit is contained in:
parent
0023507d9f
commit
f325917a65
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8216
@ -61,7 +61,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_object.c,v 1.43 1995/04/16 12:56:19 davidg Exp $
|
||||
* $Id: vm_object.c,v 1.44 1995/04/21 02:48:40 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -119,9 +119,10 @@ struct vm_object kmem_object_store;
|
||||
|
||||
int vm_object_cache_max;
|
||||
|
||||
#define VM_OBJECT_HASH_COUNT 509
|
||||
#define VM_OBJECT_HASH_COUNT 1021
|
||||
|
||||
struct vm_object_hash_head vm_object_hashtable[VM_OBJECT_HASH_COUNT];
|
||||
#define OBJECT_HASH(pager) ((unsigned long)(pager) % VM_OBJECT_HASH_COUNT)
|
||||
|
||||
long object_collapses;
|
||||
long object_bypasses;
|
||||
@ -176,7 +177,7 @@ vm_object_init(vm_offset_t nothing)
|
||||
vm_object_cache_max += (cnt.v_page_count - 1000) / 4;
|
||||
|
||||
for (i = 0; i < VM_OBJECT_HASH_COUNT; i++)
|
||||
TAILQ_INIT(&vm_object_hashtable[i]);
|
||||
LIST_INIT(&vm_object_hashtable[i]);
|
||||
|
||||
kernel_object = &kernel_object_store;
|
||||
_vm_object_allocate(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
|
||||
@ -1005,12 +1006,6 @@ vm_object_shadow(object, offset, length)
|
||||
*object = result;
|
||||
}
|
||||
|
||||
/*
|
||||
* vm_object_hash hashes the pager/id pair.
|
||||
*/
|
||||
|
||||
#define vm_object_hash(pager) \
|
||||
(((unsigned)pager >> 5)%VM_OBJECT_HASH_COUNT)
|
||||
|
||||
/*
|
||||
* vm_object_lookup looks in the object cache for an object with the
|
||||
@ -1026,9 +1021,8 @@ vm_object_lookup(pager)
|
||||
|
||||
vm_object_cache_lock();
|
||||
|
||||
for (entry = vm_object_hashtable[vm_object_hash(pager)].tqh_first;
|
||||
entry != NULL;
|
||||
entry = entry->hash_links.tqe_next) {
|
||||
for (entry = vm_object_hashtable[OBJECT_HASH(pager)].lh_first;
|
||||
entry != NULL; entry = entry->hash_links.le_next) {
|
||||
object = entry->object;
|
||||
if (object->pager == pager) {
|
||||
vm_object_lock(object);
|
||||
@ -1071,13 +1065,13 @@ vm_object_enter(object, pager)
|
||||
if (pager == NULL)
|
||||
return;
|
||||
|
||||
bucket = &vm_object_hashtable[vm_object_hash(pager)];
|
||||
bucket = &vm_object_hashtable[OBJECT_HASH(pager)];
|
||||
entry = (vm_object_hash_entry_t)
|
||||
malloc((u_long) sizeof *entry, M_VMOBJHASH, M_WAITOK);
|
||||
entry->object = object;
|
||||
|
||||
vm_object_cache_lock();
|
||||
TAILQ_INSERT_TAIL(bucket, entry, hash_links);
|
||||
LIST_INSERT_HEAD(bucket, entry, hash_links);
|
||||
vm_object_cache_unlock();
|
||||
}
|
||||
|
||||
@ -1097,14 +1091,13 @@ vm_object_remove(pager)
|
||||
register vm_object_hash_entry_t entry;
|
||||
register vm_object_t object;
|
||||
|
||||
bucket = &vm_object_hashtable[vm_object_hash(pager)];
|
||||
bucket = &vm_object_hashtable[OBJECT_HASH(pager)];
|
||||
|
||||
for (entry = bucket->tqh_first;
|
||||
entry != NULL;
|
||||
entry = entry->hash_links.tqe_next) {
|
||||
for (entry = bucket->lh_first;
|
||||
entry != NULL; entry = entry->hash_links.le_next) {
|
||||
object = entry->object;
|
||||
if (object->pager == pager) {
|
||||
TAILQ_REMOVE(bucket, entry, hash_links);
|
||||
LIST_REMOVE(entry, hash_links);
|
||||
free((caddr_t) entry, M_VMOBJHASH);
|
||||
break;
|
||||
}
|
||||
@ -1761,9 +1754,8 @@ vm_object_check() {
|
||||
*/
|
||||
for (i=0; i<VM_OBJECT_HASH_COUNT;i++) {
|
||||
int lsize = 0;
|
||||
for (entry = vm_object_hashtable[i].tqh_first;
|
||||
entry != NULL;
|
||||
entry = entry->hash_links.tqe_next) {
|
||||
for (entry = vm_object_hashtable[i].lh_first;
|
||||
entry != NULL; entry = entry->hash_links.le_next) {
|
||||
if( entry->object->flags & OBJ_INTERNAL) {
|
||||
printf("vmochk: internal obj on hash: size: %d\n", entry->object->size);
|
||||
}
|
||||
@ -1788,7 +1780,8 @@ vm_object_check() {
|
||||
object->size);
|
||||
}
|
||||
if (!vm_object_in_map(object)) {
|
||||
printf("vmochk: internal obj is not in a map: ref: %d, size: %d, pager: 0x%x, shadow: 0x%x\n", object->ref_count, object->size, object->pager, object->shadow);
|
||||
printf("vmochk: internal obj is not in a map: ref: %d, size: %d, pager: 0x%x, shadow: 0x%x\n",
|
||||
object->ref_count, object->size, object->pager, object->shadow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_object.h,v 1.16 1995/03/22 12:24:11 davidg Exp $
|
||||
* $Id: vm_object.h,v 1.17 1995/04/09 06:03:51 davidg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -115,10 +115,10 @@ struct vm_object {
|
||||
#define OBJ_PIPWNT 0x0040 /* paging in progress wanted */
|
||||
#define OBJ_WRITEABLE 0x0080 /* object has been made writeable */
|
||||
|
||||
TAILQ_HEAD(vm_object_hash_head, vm_object_hash_entry);
|
||||
LIST_HEAD(vm_object_hash_head, vm_object_hash_entry);
|
||||
|
||||
struct vm_object_hash_entry {
|
||||
TAILQ_ENTRY(vm_object_hash_entry) hash_links; /* hash chain links */
|
||||
LIST_ENTRY(vm_object_hash_entry) hash_links; /* hash chain links */
|
||||
vm_object_t object; /* object represened */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user