cache: make negative shrinker round robin on all lists every time
Previously it would check 4, 3, 2, 1 lists. In practice by the time it is getting called all lists have some elements and consequently this does not result in new evictions. Nonetheless, the code is clearer. Tested by: pho
This commit is contained in:
parent
a110fa2ee1
commit
29f3e5ea41
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363202
@ -262,7 +262,6 @@ static u_int __read_mostly ncsize; /* the size as computed on creation or resizi
|
|||||||
struct nchstats nchstats; /* cache effectiveness statistics */
|
struct nchstats nchstats; /* cache effectiveness statistics */
|
||||||
|
|
||||||
static struct mtx __exclusive_cache_line ncneg_shrink_lock;
|
static struct mtx __exclusive_cache_line ncneg_shrink_lock;
|
||||||
static int shrink_list_turn;
|
|
||||||
|
|
||||||
struct neglist {
|
struct neglist {
|
||||||
struct mtx nl_lock;
|
struct mtx nl_lock;
|
||||||
@ -815,18 +814,18 @@ cache_negative_remove(struct namecache *ncp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cache_negative_shrink_select(int start, struct namecache **ncpp,
|
cache_negative_shrink_select(struct namecache **ncpp,
|
||||||
struct neglist **neglistpp)
|
struct neglist **neglistpp)
|
||||||
{
|
{
|
||||||
struct neglist *neglist;
|
struct neglist *neglist;
|
||||||
struct namecache *ncp;
|
struct namecache *ncp;
|
||||||
int i;
|
static u_int cycle;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
*ncpp = ncp = NULL;
|
*ncpp = ncp = NULL;
|
||||||
neglist = NULL;
|
|
||||||
|
|
||||||
for (i = start; i < numneglists; i++) {
|
for (i = 0; i < numneglists; i++) {
|
||||||
neglist = &neglists[i];
|
neglist = &neglists[(cycle + i) % numneglists];
|
||||||
if (TAILQ_FIRST(&neglist->nl_list) == NULL)
|
if (TAILQ_FIRST(&neglist->nl_list) == NULL)
|
||||||
continue;
|
continue;
|
||||||
mtx_lock(&neglist->nl_lock);
|
mtx_lock(&neglist->nl_lock);
|
||||||
@ -838,6 +837,7 @@ cache_negative_shrink_select(int start, struct namecache **ncpp,
|
|||||||
|
|
||||||
*neglistpp = neglist;
|
*neglistpp = neglist;
|
||||||
*ncpp = ncp;
|
*ncpp = ncp;
|
||||||
|
cycle++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -870,12 +870,8 @@ cache_negative_zap_one(void)
|
|||||||
}
|
}
|
||||||
mtx_unlock(&ncneg_hot.nl_lock);
|
mtx_unlock(&ncneg_hot.nl_lock);
|
||||||
|
|
||||||
cache_negative_shrink_select(shrink_list_turn, &ncp, &neglist);
|
cache_negative_shrink_select(&ncp, &neglist);
|
||||||
shrink_list_turn++;
|
|
||||||
if (shrink_list_turn == numneglists)
|
|
||||||
shrink_list_turn = 0;
|
|
||||||
if (ncp == NULL && shrink_list_turn == 0)
|
|
||||||
cache_negative_shrink_select(shrink_list_turn, &ncp, &neglist);
|
|
||||||
mtx_unlock(&ncneg_shrink_lock);
|
mtx_unlock(&ncneg_shrink_lock);
|
||||||
if (ncp == NULL)
|
if (ncp == NULL)
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user