version 1.16, 2018/02/08 13:22:25 |
version 1.17, 2018/02/11 09:47:33 |
|
|
struct pool_info *pools = NULL; |
struct pool_info *pools = NULL; |
int num_pool_caches = 0; |
int num_pool_caches = 0; |
struct pool_cache_info *pool_caches = NULL; |
struct pool_cache_info *pool_caches = NULL; |
|
size_t pool_caches_size = 0; |
|
|
int ncpusfound = 0; |
int ncpusfound = 0; |
|
|
|
|
int pool_cache_read(void); |
int pool_cache_read(void); |
void pool_cache_sort(void); |
void pool_cache_sort(void); |
void pool_cache_show(const struct pool_cache_info *); |
void pool_cache_show(const struct pool_cache_info *); |
|
int pool_cache_sort_name_callback(const void *, const void *); |
|
int pool_cache_sort_len_callback(const void *, const void *); |
|
int pool_cache_sort_idle_callback(const void *, const void *); |
|
int pool_cache_sort_ngc_callback(const void *, const void *); |
|
int pool_cache_sort_req_callback(const void *, const void *); |
|
int pool_cache_sort_put_callback(const void *, const void *); |
|
int pool_cache_sort_lreq_callback(const void *, const void *); |
|
int pool_cache_sort_lput_callback(const void *, const void *); |
int pool_cache_kbd_cb(int); |
int pool_cache_kbd_cb(int); |
|
|
field_def pool_cache_fields[] = { |
field_def pool_cache_fields[] = { |
|
|
}; |
}; |
|
|
order_type pool_cache_order_list[] = { |
order_type pool_cache_order_list[] = { |
{"name", "name", 'N', sort_name_callback}, |
{"name", "name", 'N', pool_cache_sort_name_callback}, |
{"requests", "requests", 'G', sort_req_callback}, |
{"len", "len", 'L', pool_cache_sort_len_callback}, |
{"releases", "releases", 'P', sort_req_callback}, |
{"idle", "idle", 'I', pool_cache_sort_idle_callback}, |
|
{"ngc", "ngc", 'G', pool_cache_sort_ngc_callback}, |
|
{"requests", "requests", 'Q', pool_cache_sort_req_callback}, |
|
{"releases", "releases", 'P', pool_cache_sort_put_callback}, |
|
{"listrequests", "listrequests", 'E', pool_cache_sort_req_callback}, |
|
{"listreleases", "listreleases", 'U', pool_cache_sort_put_callback}, |
{NULL, NULL, 0, NULL} |
{NULL, NULL, 0, NULL} |
}; |
}; |
|
|
/* Define view managers */ |
/* Define view managers */ |
struct view_manager pool_cache_mgr = { |
struct view_manager pool_cache_mgr = { |
"PoolCache", |
"PoolCache", |
select_pool, |
NULL, |
pool_cache_read, |
pool_cache_read, |
pool_cache_sort, |
pool_cache_sort, |
print_header, |
print_header, |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
if (np > num_pool_caches) { |
if (np > pool_caches_size) { |
pc = reallocarray(pool_caches, np, sizeof(*pc)); |
pc = reallocarray(pool_caches, np, sizeof(*pc)); |
if (pc == NULL) { |
if (pc == NULL) { |
error("realloc: %s", strerror(errno)); |
error("realloc: %s", strerror(errno)); |
|
|
/* commit to using the new memory */ |
/* commit to using the new memory */ |
pool_caches = pc; |
pool_caches = pc; |
|
|
for (i = num_pool_caches; i < np; i++) { |
for (i = pool_caches_size; i < np; i++) { |
pc = &pool_caches[i]; |
pc = &pool_caches[i]; |
pc->name[0] = '\0'; |
pc->name[0] = '\0'; |
|
|
|
|
} |
} |
|
|
/* commit to using the new cache_infos */ |
/* commit to using the new cache_infos */ |
num_pool_caches = np; |
pool_caches_size = np; |
} |
} |
|
|
for (i = 0; i < num_pool_caches; i++) { |
num_pool_caches = 0; |
pc = &pool_caches[i]; |
for (i = 0; i < pool_caches_size; i++) { |
|
pc = &pool_caches[num_pool_caches]; |
np = i + 1; |
np = i + 1; |
|
|
if (pool_get_cache(np, &pc->cache) < 0 || |
if (pool_get_cache(np, &pc->cache) < 0 || |
|
|
|
|
if (pool_get_name(np, pc->name, sizeof(pc->name)) < 0) |
if (pool_get_name(np, pc->name, sizeof(pc->name)) < 0) |
snprintf(pc->name, sizeof(pc->name), "#%d#", i + 1); |
snprintf(pc->name, sizeof(pc->name), "#%d#", i + 1); |
|
num_pool_caches++; |
} |
} |
|
|
return 0; |
return 0; |
|
|
unalloc: |
unalloc: |
while (i > num_pool_caches) { |
while (i > pool_caches_size) { |
pc = &pool_caches[--i]; |
pc = &pool_caches[--i]; |
free(pc->cache_cpus); |
free(pc->cache_cpus); |
} |
} |
|
|
void |
void |
pool_cache_sort(void) |
pool_cache_sort(void) |
{ |
{ |
/* XXX */ |
|
order_type *ordering; |
order_type *ordering; |
|
|
if (curr_mgr == NULL) |
if (curr_mgr == NULL) |
|
|
return; |
return; |
if (ordering->func == NULL) |
if (ordering->func == NULL) |
return; |
return; |
if (pools == NULL) |
if (pool_caches == NULL) |
return; |
return; |
if (num_pools <= 0) |
if (num_pool_caches <= 0) |
return; |
return; |
|
|
mergesort(pools, num_pools, sizeof(struct pool_info), ordering->func); |
mergesort(pool_caches, num_pool_caches, sizeof(*pool_caches), ordering->func); |
} |
} |
|
|
void |
void |
|
|
print_fld_size(FLD_POOL_CACHE_LPUT, kpcc->pr_nlput); |
print_fld_size(FLD_POOL_CACHE_LPUT, kpcc->pr_nlput); |
end_line(); |
end_line(); |
} |
} |
|
} |
|
|
|
int |
|
pool_cache_sort_name_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
return strcmp(pc1->name, pc2->name) * sortdir; |
} |
} |
|
|
static int |
int |
|
pool_cache_sort_len_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
if (pc1->cache.pr_len < pc2->cache.pr_len) |
|
return sortdir; |
|
if (pc1->cache.pr_len > pc2->cache.pr_len) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
|
pool_cache_sort_idle_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
if (pc1->cache.pr_nitems < pc2->cache.pr_nitems) |
|
return sortdir; |
|
if (pc1->cache.pr_nitems > pc2->cache.pr_nitems) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
|
pool_cache_sort_ngc_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
if (pc1->cache.pr_ngc < pc2->cache.pr_ngc) |
|
return sortdir; |
|
if (pc1->cache.pr_ngc > pc2->cache.pr_ngc) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
|
pool_cache_sort_req_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
uint64_t nget1 = 0, nget2 = 0; |
|
int oflow1 = 0, oflow2 = 0; |
|
int cpu; |
|
|
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
for (cpu = 0; cpu < ncpusfound; cpu++) { |
|
if (nget1 + pc1->cache_cpus->pr_nget < nget1) |
|
oflow1++; |
|
nget1 += pc1->cache_cpus->pr_nget; |
|
if (nget2 + pc2->cache_cpus->pr_nget < nget2) |
|
oflow2++; |
|
nget2 += pc2->cache_cpus->pr_nget; |
|
} |
|
|
|
if (oflow1 < oflow2) |
|
return sortdir; |
|
if (oflow1 > oflow2) |
|
return -sortdir; |
|
if (nget1 < nget2) |
|
return sortdir; |
|
if (nget1 > nget2) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
|
pool_cache_sort_put_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
uint64_t nput1 = 0, nput2 = 0; |
|
int oflow1 = 0, oflow2 = 0; |
|
int cpu; |
|
|
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
for (cpu = 0; cpu < ncpusfound; cpu++) { |
|
if (nput1 + pc1->cache_cpus->pr_nput < nput1) |
|
oflow1++; |
|
nput1 += pc1->cache_cpus->pr_nput; |
|
if (nput2 + pc2->cache_cpus->pr_nput < nput2) |
|
oflow2++; |
|
nput2 += pc2->cache_cpus->pr_nput; |
|
} |
|
|
|
if (oflow1 < oflow2) |
|
return sortdir; |
|
if (oflow1 > oflow2) |
|
return -sortdir; |
|
if (nput1 < nput2) |
|
return sortdir; |
|
if (nput1 > nput2) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
|
pool_cache_sort_lreq_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
uint64_t nlget1 = 0, nlget2 = 0; |
|
int oflow1 = 0, oflow2 = 0; |
|
int cpu; |
|
|
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
for (cpu = 0; cpu < ncpusfound; cpu++) { |
|
if (nlget1 + pc1->cache_cpus->pr_nlget < nlget1) |
|
oflow1++; |
|
nlget1 += pc1->cache_cpus->pr_nlget; |
|
if (nlget2 + pc2->cache_cpus->pr_nlget < nlget2) |
|
oflow2++; |
|
nlget2 += pc2->cache_cpus->pr_nlget; |
|
} |
|
|
|
if (oflow1 < oflow2) |
|
return sortdir; |
|
if (oflow1 > oflow2) |
|
return -sortdir; |
|
if (nlget1 < nlget2) |
|
return sortdir; |
|
if (nlget1 > nlget2) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
|
pool_cache_sort_lput_callback(const void *s1, const void *s2) |
|
{ |
|
struct pool_cache_info *pc1, *pc2; |
|
uint64_t nlput1 = 0, nlput2 = 0; |
|
int oflow1 = 0, oflow2 = 0; |
|
int cpu; |
|
|
|
pc1 = (struct pool_cache_info *)s1; |
|
pc2 = (struct pool_cache_info *)s2; |
|
|
|
for (cpu = 0; cpu < ncpusfound; cpu++) { |
|
if (nlput1 + pc1->cache_cpus->pr_nlput < nlput1) |
|
oflow1++; |
|
nlput1 += pc1->cache_cpus->pr_nlput; |
|
if (nlput2 + pc2->cache_cpus->pr_nlput < nlput2) |
|
oflow2++; |
|
nlput2 += pc2->cache_cpus->pr_nlput; |
|
} |
|
|
|
if (oflow1 < oflow2) |
|
return sortdir; |
|
if (oflow1 > oflow2) |
|
return -sortdir; |
|
if (nlput1 < nlput2) |
|
return sortdir; |
|
if (nlput1 > nlput2) |
|
return -sortdir; |
|
|
|
return pool_cache_sort_name_callback(s1, s2); |
|
} |
|
|
|
int |
pool_get_npools(void) |
pool_get_npools(void) |
{ |
{ |
int mib[] = { CTL_KERN, KERN_POOL, KERN_POOL_NPOOLS }; |
int mib[] = { CTL_KERN, KERN_POOL, KERN_POOL_NPOOLS }; |