-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
6065 page hash: use a static inline instead of a macro
Reviewed by: Dan McDonald <[email protected]> Approved by: Robert Mustacchi <[email protected]>
- Loading branch information
Showing
1 changed file
with
31 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
*/ | ||
/* | ||
* Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2015, Josef 'Jeff' Sipek <[email protected]> | ||
*/ | ||
|
||
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ | ||
|
@@ -267,39 +268,29 @@ uint_t alloc_pages[9]; | |
uint_t page_exphcontg[19]; | ||
uint_t page_create_large_cnt[10]; | ||
|
||
/* | ||
* Collects statistics. | ||
*/ | ||
#define PAGE_HASH_SEARCH(index, pp, vp, off) { \ | ||
uint_t mylen = 0; \ | ||
\ | ||
for ((pp) = page_hash[(index)]; (pp); (pp) = (pp)->p_hash, mylen++) { \ | ||
if ((pp)->p_vnode == (vp) && (pp)->p_offset == (off)) \ | ||
break; \ | ||
} \ | ||
if ((pp) != NULL) \ | ||
pagecnt.pc_find_hit++; \ | ||
else \ | ||
pagecnt.pc_find_miss++; \ | ||
if (mylen > PC_HASH_CNT) \ | ||
mylen = PC_HASH_CNT; \ | ||
pagecnt.pc_find_hashlen[mylen]++; \ | ||
} | ||
#endif | ||
|
||
#else /* VM_STATS */ | ||
static inline page_t * | ||
page_hash_search(ulong_t index, vnode_t *vnode, u_offset_t off) | ||
{ | ||
uint_t mylen = 0; | ||
page_t *page; | ||
|
||
/* | ||
* Don't collect statistics | ||
*/ | ||
#define PAGE_HASH_SEARCH(index, pp, vp, off) { \ | ||
for ((pp) = page_hash[(index)]; (pp); (pp) = (pp)->p_hash) { \ | ||
if ((pp)->p_vnode == (vp) && (pp)->p_offset == (off)) \ | ||
break; \ | ||
} \ | ||
} | ||
for (page = page_hash[index]; page; page = page->p_hash, mylen++) | ||
if (page->p_vnode == vnode && page->p_offset == off) | ||
break; | ||
|
||
#endif /* VM_STATS */ | ||
#ifdef VM_STATS | ||
if (page != NULL) | ||
pagecnt.pc_find_hit++; | ||
else | ||
pagecnt.pc_find_miss++; | ||
|
||
pagecnt.pc_find_hashlen[MIN(mylen, PC_HASH_CNT)]++; | ||
#endif | ||
|
||
return (page); | ||
} | ||
|
||
|
||
#ifdef DEBUG | ||
|
@@ -750,7 +741,7 @@ page_lookup_create( | |
index = PAGE_HASH_FUNC(vp, off); | ||
phm = NULL; | ||
top: | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
if (pp != NULL) { | ||
VM_STAT_ADD(page_lookup_cnt[1]); | ||
es = (newpp != NULL) ? 1 : 0; | ||
|
@@ -784,8 +775,8 @@ page_lookup_create( | |
* Reconfirm we locked the correct page. | ||
* | ||
* Both the p_vnode and p_offset *must* be cast volatile | ||
* to force a reload of their values: The PAGE_HASH_SEARCH | ||
* macro will have stuffed p_vnode and p_offset into | ||
* to force a reload of their values: The page_hash_search | ||
* function will have stuffed p_vnode and p_offset into | ||
* registers before calling page_trylock(); another thread, | ||
* actually holding the hash lock, could have changed the | ||
* page's identity in memory, but our registers would not | ||
|
@@ -948,15 +939,15 @@ page_lookup_nowait(vnode_t *vp, u_offset_t off, se_t se) | |
VM_STAT_ADD(page_lookup_nowait_cnt[0]); | ||
|
||
index = PAGE_HASH_FUNC(vp, off); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
locked = 0; | ||
if (pp == NULL) { | ||
top: | ||
VM_STAT_ADD(page_lookup_nowait_cnt[1]); | ||
locked = 1; | ||
phm = PAGE_HASH_MUTEX(index); | ||
mutex_enter(phm); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
} | ||
|
||
if (pp == NULL || PP_ISFREE(pp)) { | ||
|
@@ -1018,7 +1009,7 @@ page_find(vnode_t *vp, u_offset_t off) | |
phm = PAGE_HASH_MUTEX(index); | ||
|
||
mutex_enter(phm); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
mutex_exit(phm); | ||
|
||
ASSERT(pp == NULL || PAGE_LOCKED(pp) || panicstr); | ||
|
@@ -1036,16 +1027,14 @@ page_find(vnode_t *vp, u_offset_t off) | |
page_t * | ||
page_exists(vnode_t *vp, u_offset_t off) | ||
{ | ||
page_t *pp; | ||
ulong_t index; | ||
|
||
ASSERT(MUTEX_NOT_HELD(page_vnode_mutex(vp))); | ||
VM_STAT_ADD(page_exists_cnt); | ||
|
||
index = PAGE_HASH_FUNC(vp, off); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
|
||
return (pp); | ||
return (page_hash_search(index, vp, off)); | ||
} | ||
|
||
/* | ||
|
@@ -1092,7 +1081,7 @@ page_exists_physcontig(vnode_t *vp, u_offset_t off, uint_t szc, page_t *ppa[]) | |
phm = PAGE_HASH_MUTEX(index); | ||
|
||
mutex_enter(phm); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
mutex_exit(phm); | ||
|
||
VM_STAT_ADD(page_exphcontg[1]); | ||
|
@@ -1319,7 +1308,7 @@ page_exists_forreal(vnode_t *vp, u_offset_t off, uint_t *szc) | |
phm = PAGE_HASH_MUTEX(index); | ||
|
||
mutex_enter(phm); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
if (pp != NULL) { | ||
*szc = pp->p_szc; | ||
rc = 1; | ||
|
@@ -2447,7 +2436,7 @@ page_create_va(vnode_t *vp, u_offset_t off, size_t bytes, uint_t flags, | |
*/ | ||
phm = PAGE_HASH_MUTEX(index); | ||
mutex_enter(phm); | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
if (pp == NULL) { | ||
VM_STAT_ADD(page_create_new); | ||
pp = npp; | ||
|
@@ -3277,7 +3266,7 @@ page_rename(page_t *opp, vnode_t *vp, u_offset_t off) | |
* lock, again preventing another page from being created with | ||
* this identity. | ||
*/ | ||
PAGE_HASH_SEARCH(index, pp, vp, off); | ||
pp = page_hash_search(index, vp, off); | ||
if (pp != NULL) { | ||
VM_STAT_ADD(page_rename_exists); | ||
|
||
|