linprocfs: garbage collect meminfo fields not present in linux

In particular memshared not only does not exist in linux, it was
extremely expensive to calculate.
This commit is contained in:
Mateusz Guzik 2016-09-16 03:36:43 +00:00
parent cb1cb6a2a8
commit dbfe4b2673
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=305856

View File

@ -144,12 +144,10 @@ linprocfs_domeminfo(PFS_FILL_ARGS)
unsigned long memtotal; /* total memory in bytes */
unsigned long memused; /* used memory in bytes */
unsigned long memfree; /* free memory in bytes */
unsigned long memshared; /* shared memory ??? */
unsigned long buffers, cached; /* buffer / cache memory ??? */
unsigned long long swaptotal; /* total swap space in bytes */
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;
@ -169,13 +167,6 @@ linprocfs_domeminfo(PFS_FILL_ARGS)
swaptotal = (unsigned long long)i * PAGE_SIZE;
swapused = (unsigned long long)j * PAGE_SIZE;
swapfree = swaptotal - swapused;
memshared = 0;
mtx_lock(&vm_object_list_mtx);
TAILQ_FOREACH(object, &vm_object_list, object_list)
if (object->shadow_count > 1)
memshared += object->resident_page_count;
mtx_unlock(&vm_object_list_mtx);
memshared *= PAGE_SIZE;
/*
* We'd love to be able to write:
*
@ -188,21 +179,14 @@ linprocfs_domeminfo(PFS_FILL_ARGS)
cached = vm_cnt.v_cache_count * PAGE_SIZE;
sbuf_printf(sb,
" total: used: free: shared: buffers: cached:\n"
"Mem: %lu %lu %lu %lu %lu %lu\n"
"Swap: %llu %llu %llu\n"
"MemTotal: %9lu kB\n"
"MemFree: %9lu kB\n"
"MemShared:%9lu kB\n"
"Buffers: %9lu kB\n"
"Cached: %9lu kB\n"
"SwapTotal:%9llu kB\n"
"SwapFree: %9llu kB\n",
memtotal, memused, memfree, memshared, buffers, cached,
swaptotal, swapused, swapfree,
B2K(memtotal), B2K(memfree),
B2K(memshared), B2K(buffers), B2K(cached),
B2K(swaptotal), B2K(swapfree));
B2K(memtotal), B2K(memfree), B2K(buffers),
B2K(cached), B2K(swaptotal), B2K(swapfree));
return (0);
}