Add a new function swap_pager_status() which reports the total size of the
paging space and how much of it is in use (in pages). Use this interface from the Linuxolator instead of groping around in the internals of the swap_pager.
This commit is contained in:
parent
e9c0cc157b
commit
567104a148
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117723
@ -121,6 +121,7 @@ linprocfs_domeminfo(PFS_FILL_ARGS)
|
||||
unsigned long long swapused; /* used swap space in bytes */
|
||||
unsigned long long swapfree; /* free swap space in bytes */
|
||||
vm_object_t object;
|
||||
int i, j;
|
||||
|
||||
memtotal = physmem * PAGE_SIZE;
|
||||
/*
|
||||
@ -135,14 +136,10 @@ linprocfs_domeminfo(PFS_FILL_ARGS)
|
||||
*/
|
||||
memused = cnt.v_wire_count * PAGE_SIZE;
|
||||
memfree = memtotal - memused;
|
||||
if (swapblist == NULL) {
|
||||
swaptotal = 0;
|
||||
swapfree = 0;
|
||||
} else {
|
||||
swaptotal = (u_quad_t)swapblist->bl_blocks * 1024; /* XXX why 1024? */
|
||||
swapfree = (u_quad_t)swapblist->bl_root->u.bmu_avail * PAGE_SIZE;
|
||||
}
|
||||
swapused = swaptotal - swapfree;
|
||||
swap_pager_status(&i, &j);
|
||||
swaptotal = i * PAGE_SIZE;
|
||||
swapused = j * PAGE_SIZE;
|
||||
swapfree = swaptotal - swapused;
|
||||
memshared = 0;
|
||||
TAILQ_FOREACH(object, &vm_object_list, object_list)
|
||||
if (object->shadow_count > 1)
|
||||
|
@ -108,7 +108,7 @@ linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
|
||||
{
|
||||
struct l_sysinfo sysinfo;
|
||||
vm_object_t object;
|
||||
int i;
|
||||
int i, j;
|
||||
struct timespec ts;
|
||||
|
||||
/* Uptime is copied out of print_uptime() in kern_shutdown.c */
|
||||
@ -144,13 +144,9 @@ linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
|
||||
sysinfo.sharedram *= PAGE_SIZE;
|
||||
sysinfo.bufferram = 0;
|
||||
|
||||
if (swapblist == NULL) {
|
||||
sysinfo.totalswap= 0;
|
||||
sysinfo.freeswap = 0;
|
||||
} else {
|
||||
sysinfo.totalswap = swapblist->bl_blocks * 1024;
|
||||
sysinfo.freeswap = swapblist->bl_root->u.bmu_avail * PAGE_SIZE;
|
||||
}
|
||||
swap_pager_status(&i, &j);
|
||||
sysinfo.totalswap= i * PAGE_SIZE;
|
||||
sysinfo.freeswap = (i - j) * PAGE_SIZE;
|
||||
|
||||
sysinfo.procs = 20; /* Hack */
|
||||
|
||||
|
@ -142,7 +142,7 @@ static int nsw_wcount_async; /* limit write buffers / asynchronous */
|
||||
static int nsw_wcount_async_max;/* assigned maximum */
|
||||
static int nsw_cluster_max; /* maximum VOP I/O allowed */
|
||||
|
||||
struct blist *swapblist;
|
||||
static struct blist *swapblist;
|
||||
static struct swblock **swhash;
|
||||
static int swhash_mask;
|
||||
static int swap_async_max = 4; /* maximum in-progress async I/O's */
|
||||
@ -2666,6 +2666,22 @@ swapoff(td, uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
swap_pager_status(int *total, int *used)
|
||||
{
|
||||
struct swdevt *sp;
|
||||
int i;
|
||||
|
||||
*total = 0;
|
||||
*used = 0;
|
||||
for (sp = swdevt, i = 0; i < nswdev; i++, sp++) {
|
||||
if (sp->sw_vp == NULL)
|
||||
continue;
|
||||
*total += sp->sw_nblks;
|
||||
*used += sp->sw_used;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
|
@ -93,7 +93,6 @@ struct swdevt {
|
||||
#define SWAP_META_MASK (SWAP_META_PAGES - 1)
|
||||
|
||||
extern int swap_pager_full;
|
||||
extern struct blist *swapblist;
|
||||
extern int vm_swap_size;
|
||||
|
||||
void swap_pager_putpages(vm_object_t, vm_page_t *, int, boolean_t, int *);
|
||||
@ -102,6 +101,7 @@ void swap_pager_freespace(vm_object_t, vm_pindex_t, vm_size_t);
|
||||
void swap_pager_swap_init(void);
|
||||
int swap_pager_isswapped(vm_object_t, int);
|
||||
int swap_pager_reserve(vm_object_t, vm_pindex_t, vm_size_t);
|
||||
void swap_pager_status(int *total, int *used);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* _VM_SWAP_PAGER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user