Track current and peak sfbuf usage, export the values via sysctl.
This commit is contained in:
parent
30b48d7f6d
commit
5eda9873e9
@ -116,6 +116,7 @@ static struct {
|
|||||||
} sf_freelist;
|
} sf_freelist;
|
||||||
|
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finish a fork operation, with process p2 nearly set up.
|
* Finish a fork operation, with process p2 nearly set up.
|
||||||
@ -428,6 +429,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf != NULL) {
|
if (sf != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
return (sf);
|
return (sf);
|
||||||
@ -457,6 +460,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
sf->m = NULL;
|
sf->m = NULL;
|
||||||
mtx_lock(&sf_freelist.sf_lock);
|
mtx_lock(&sf_freelist.sf_lock);
|
||||||
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
||||||
|
nsfbufsused--;
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_freelist);
|
wakeup_one(&sf_freelist);
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
|
@ -99,6 +99,7 @@ static struct {
|
|||||||
} sf_freelist;
|
} sf_freelist;
|
||||||
|
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finish a fork operation, with process p2 nearly set up.
|
* Finish a fork operation, with process p2 nearly set up.
|
||||||
@ -473,6 +474,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf != NULL) {
|
if (sf != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
return (sf);
|
return (sf);
|
||||||
@ -502,6 +505,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
sf->m = NULL;
|
sf->m = NULL;
|
||||||
mtx_lock(&sf_freelist.sf_lock);
|
mtx_lock(&sf_freelist.sf_lock);
|
||||||
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
||||||
|
nsfbufsused--;
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_freelist);
|
wakeup_one(&sf_freelist);
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
|
@ -112,6 +112,7 @@ static u_long sf_buf_hashmask;
|
|||||||
|
|
||||||
static TAILQ_HEAD(, sf_buf) sf_buf_freelist;
|
static TAILQ_HEAD(, sf_buf) sf_buf_freelist;
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A lock used to synchronize access to the hash table and free list
|
* A lock used to synchronize access to the hash table and free list
|
||||||
@ -612,6 +613,10 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf->ref_count == 0)
|
if (sf->ref_count == 0)
|
||||||
TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
|
TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
|
||||||
sf->ref_count++;
|
sf->ref_count++;
|
||||||
|
if (sf->ref_count == 1) {
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -633,6 +638,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
LIST_INSERT_HEAD(hash_list, sf, list_entry);
|
LIST_INSERT_HEAD(hash_list, sf, list_entry);
|
||||||
sf->ref_count = 1;
|
sf->ref_count = 1;
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
pmap_qenter(sf->kva, &sf->m, 1);
|
pmap_qenter(sf->kva, &sf->m, 1);
|
||||||
done:
|
done:
|
||||||
mtx_unlock(&sf_buf_lock);
|
mtx_unlock(&sf_buf_lock);
|
||||||
@ -653,6 +660,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
m = sf->m;
|
m = sf->m;
|
||||||
sf->ref_count--;
|
sf->ref_count--;
|
||||||
if (sf->ref_count == 0) {
|
if (sf->ref_count == 0) {
|
||||||
|
nsfbufsused--;
|
||||||
TAILQ_INSERT_TAIL(&sf_buf_freelist, sf, free_entry);
|
TAILQ_INSERT_TAIL(&sf_buf_freelist, sf, free_entry);
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_buf_freelist);
|
wakeup_one(&sf_buf_freelist);
|
||||||
|
@ -113,6 +113,7 @@ static struct {
|
|||||||
} sf_freelist;
|
} sf_freelist;
|
||||||
|
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
void
|
void
|
||||||
cpu_thread_exit(struct thread *td)
|
cpu_thread_exit(struct thread *td)
|
||||||
@ -365,6 +366,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf != NULL) {
|
if (sf != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
return (sf);
|
return (sf);
|
||||||
@ -394,6 +397,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
sf->m = NULL;
|
sf->m = NULL;
|
||||||
mtx_lock(&sf_freelist.sf_lock);
|
mtx_lock(&sf_freelist.sf_lock);
|
||||||
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
||||||
|
nsfbufsused--;
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_freelist);
|
wakeup_one(&sf_freelist);
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
|
@ -173,6 +173,8 @@ int nmbufs;
|
|||||||
int nmbclusters;
|
int nmbclusters;
|
||||||
int nmbcnt;
|
int nmbcnt;
|
||||||
int nsfbufs;
|
int nsfbufs;
|
||||||
|
int nsfbufspeak;
|
||||||
|
int nsfbufsused;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sizes of objects per bucket. There are this size's worth of mbufs
|
* Sizes of objects per bucket. There are this size's worth of mbufs
|
||||||
@ -318,6 +320,10 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, nmbcnt, CTLFLAG_RDTUN, &nmbcnt, 0,
|
|||||||
"Number used to scale kmem_map to ensure sufficient space for counters");
|
"Number used to scale kmem_map to ensure sufficient space for counters");
|
||||||
SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufs, CTLFLAG_RDTUN, &nsfbufs, 0,
|
SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufs, CTLFLAG_RDTUN, &nsfbufs, 0,
|
||||||
"Maximum number of sendfile(2) sf_bufs available");
|
"Maximum number of sendfile(2) sf_bufs available");
|
||||||
|
SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufspeak, CTLFLAG_RD, &nsfbufspeak, 0,
|
||||||
|
"Number of sendfile(2) sf_bufs at peak usage");
|
||||||
|
SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsused, CTLFLAG_RD, &nsfbufsused, 0,
|
||||||
|
"Number of sendfile(2) sf_bufs in use");
|
||||||
SYSCTL_INT(_kern_ipc, OID_AUTO, mbuf_wait, CTLFLAG_RW, &mbuf_wait, 0,
|
SYSCTL_INT(_kern_ipc, OID_AUTO, mbuf_wait, CTLFLAG_RW, &mbuf_wait, 0,
|
||||||
"Sleep time of mbuf subsystem wait allocations during exhaustion");
|
"Sleep time of mbuf subsystem wait allocations during exhaustion");
|
||||||
SYSCTL_UINT(_kern_ipc, OID_AUTO, mbuf_hiwm, CTLFLAG_RW, &mbuf_hiwm, 0,
|
SYSCTL_UINT(_kern_ipc, OID_AUTO, mbuf_hiwm, CTLFLAG_RW, &mbuf_hiwm, 0,
|
||||||
|
@ -116,6 +116,7 @@ static struct {
|
|||||||
} sf_freelist;
|
} sf_freelist;
|
||||||
|
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finish a fork operation, with process p2 nearly set up.
|
* Finish a fork operation, with process p2 nearly set up.
|
||||||
@ -282,6 +283,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf != NULL) {
|
if (sf != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
pmap_qenter(sf->kva, &sf->m, 1);
|
pmap_qenter(sf->kva, &sf->m, 1);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
@ -313,6 +316,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
sf->m = NULL;
|
sf->m = NULL;
|
||||||
mtx_lock(&sf_freelist.sf_lock);
|
mtx_lock(&sf_freelist.sf_lock);
|
||||||
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
||||||
|
nsfbufsused--;
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_freelist);
|
wakeup_one(&sf_freelist);
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
|
@ -116,6 +116,7 @@ static struct {
|
|||||||
} sf_freelist;
|
} sf_freelist;
|
||||||
|
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finish a fork operation, with process p2 nearly set up.
|
* Finish a fork operation, with process p2 nearly set up.
|
||||||
@ -282,6 +283,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf != NULL) {
|
if (sf != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
pmap_qenter(sf->kva, &sf->m, 1);
|
pmap_qenter(sf->kva, &sf->m, 1);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
@ -313,6 +316,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
sf->m = NULL;
|
sf->m = NULL;
|
||||||
mtx_lock(&sf_freelist.sf_lock);
|
mtx_lock(&sf_freelist.sf_lock);
|
||||||
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
||||||
|
nsfbufsused--;
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_freelist);
|
wakeup_one(&sf_freelist);
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
|
@ -100,6 +100,7 @@ static struct {
|
|||||||
} sf_freelist;
|
} sf_freelist;
|
||||||
|
|
||||||
static u_int sf_buf_alloc_want;
|
static u_int sf_buf_alloc_want;
|
||||||
|
extern int nsfbufspeak, nsfbufsused;
|
||||||
|
|
||||||
PMAP_STATS_VAR(uma_nsmall_alloc);
|
PMAP_STATS_VAR(uma_nsmall_alloc);
|
||||||
PMAP_STATS_VAR(uma_nsmall_alloc_oc);
|
PMAP_STATS_VAR(uma_nsmall_alloc_oc);
|
||||||
@ -409,6 +410,8 @@ sf_buf_alloc(struct vm_page *m)
|
|||||||
if (sf != NULL) {
|
if (sf != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||||
sf->m = m;
|
sf->m = m;
|
||||||
|
nsfbufsused++;
|
||||||
|
nsfbufspeak = max(nsfbufspeak, nsfbufsused);
|
||||||
pmap_qenter(sf->kva, &sf->m, 1);
|
pmap_qenter(sf->kva, &sf->m, 1);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
@ -440,6 +443,7 @@ sf_buf_free(void *addr, void *args)
|
|||||||
sf->m = NULL;
|
sf->m = NULL;
|
||||||
mtx_lock(&sf_freelist.sf_lock);
|
mtx_lock(&sf_freelist.sf_lock);
|
||||||
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
|
||||||
|
nsfbufsused--;
|
||||||
if (sf_buf_alloc_want > 0)
|
if (sf_buf_alloc_want > 0)
|
||||||
wakeup_one(&sf_freelist);
|
wakeup_one(&sf_freelist);
|
||||||
mtx_unlock(&sf_freelist.sf_lock);
|
mtx_unlock(&sf_freelist.sf_lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user