Lines 145-185
static int
Link Here
|
145 |
linprocfs_domeminfo(PFS_FILL_ARGS) |
145 |
linprocfs_domeminfo(PFS_FILL_ARGS) |
146 |
{ |
146 |
{ |
147 |
unsigned long memtotal; /* total memory in bytes */ |
147 |
unsigned long memtotal; /* total memory in bytes */ |
148 |
unsigned long memused; /* used memory in bytes */ |
|
|
149 |
unsigned long memfree; /* free memory in bytes */ |
148 |
unsigned long memfree; /* free memory in bytes */ |
150 |
unsigned long buffers, cached; /* buffer / cache memory ??? */ |
149 |
unsigned long cached; /* page cache */ |
|
|
150 |
unsigned long buffers; /* buffer cache */ |
151 |
unsigned long long swaptotal; /* total swap space in bytes */ |
151 |
unsigned long long swaptotal; /* total swap space in bytes */ |
152 |
unsigned long long swapused; /* used swap space in bytes */ |
152 |
unsigned long long swapused; /* used swap space in bytes */ |
153 |
unsigned long long swapfree; /* free swap space in bytes */ |
153 |
unsigned long long swapfree; /* free swap space in bytes */ |
154 |
int i, j; |
154 |
size_t sz; |
|
|
155 |
int error, i, j; |
155 |
|
156 |
|
156 |
memtotal = physmem * PAGE_SIZE; |
157 |
memtotal = physmem * PAGE_SIZE; |
157 |
/* |
158 |
memfree = (unsigned long)vm_free_count() * PAGE_SIZE; |
158 |
* The correct thing here would be: |
|
|
159 |
* |
160 |
memfree = vm_free_count() * PAGE_SIZE; |
161 |
memused = memtotal - memfree; |
162 |
* |
163 |
* but it might mislead linux binaries into thinking there |
164 |
* is very little memory left, so we cheat and tell them that |
165 |
* all memory that isn't wired down is free. |
166 |
*/ |
167 |
memused = vm_wire_count() * PAGE_SIZE; |
168 |
memfree = memtotal - memused; |
169 |
swap_pager_status(&i, &j); |
159 |
swap_pager_status(&i, &j); |
170 |
swaptotal = (unsigned long long)i * PAGE_SIZE; |
160 |
swaptotal = (unsigned long long)i * PAGE_SIZE; |
171 |
swapused = (unsigned long long)j * PAGE_SIZE; |
161 |
swapused = (unsigned long long)j * PAGE_SIZE; |
172 |
swapfree = swaptotal - swapused; |
162 |
swapfree = swaptotal - swapused; |
173 |
/* |
163 |
cached = |
174 |
* We'd love to be able to write: |
164 |
(vm_active_count() + vm_inactive_count() + vm_laundry_count()) * |
175 |
* |
165 |
PAGE_SIZE; |
176 |
buffers = bufspace; |
166 |
|
177 |
* |
167 |
sz = sizeof(buffers); |
178 |
* but bufspace is internal to vfs_bio.c and we don't feel |
168 |
error = kernel_sysctlbyname(curthread, "vfs.bufspace", &buffers, &sz, |
179 |
* like unstaticizing it just for linprocfs's sake. |
169 |
NULL, 0, 0, 0); |
180 |
*/ |
170 |
if (error != 0) |
181 |
buffers = 0; |
171 |
buffers = 0; |
182 |
cached = vm_inactive_count() * PAGE_SIZE; |
|
|
183 |
|
172 |
|
184 |
sbuf_printf(sb, |
173 |
sbuf_printf(sb, |
185 |
"MemTotal: %9lu kB\n" |
174 |
"MemTotal: %9lu kB\n" |