Line 0
Link Here
|
|
|
1 |
Fix memory statistics display on FreeBSD/powerpc |
2 |
|
3 |
https://github.com/hishamhm/htop/pull/871 |
4 |
|
5 |
--- freebsd/FreeBSDProcessList.c.orig 2018-04-10 13:42:59 UTC |
6 |
+++ freebsd/FreeBSDProcessList.c |
7 |
@@ -296,31 +296,46 @@ static inline void FreeBSDProcessList_scanMemoryInfo(P |
8 |
// |
9 |
// htop_used = active + (wired - arc) |
10 |
// htop_cache = buffers + cache + arc |
11 |
- size_t len = sizeof(pl->totalMem); |
12 |
+ u_long totalMem; |
13 |
+ u_int memActive, memWire, cachedMem; |
14 |
+ long buffersMem; |
15 |
+ uint64_t memZfsArc; |
16 |
+ size_t len; |
17 |
|
18 |
//disabled for now, as it is always smaller than phycal amount of memory... |
19 |
//...to avoid "where is my memory?" questions |
20 |
//sysctl(MIB_vm_stats_vm_v_page_count, 4, &(pl->totalMem), &len, NULL, 0); |
21 |
//pl->totalMem *= pageSizeKb; |
22 |
- sysctl(MIB_hw_physmem, 2, &(pl->totalMem), &len, NULL, 0); |
23 |
- pl->totalMem /= 1024; |
24 |
+ len = sizeof(totalMem); |
25 |
+ sysctl(MIB_hw_physmem, 2, &(totalMem), &len, NULL, 0); |
26 |
+ totalMem /= 1024; |
27 |
+ pl->totalMem = totalMem; |
28 |
|
29 |
- sysctl(MIB_vm_stats_vm_v_active_count, 4, &(fpl->memActive), &len, NULL, 0); |
30 |
- fpl->memActive *= pageSizeKb; |
31 |
+ len = sizeof(memActive); |
32 |
+ sysctl(MIB_vm_stats_vm_v_active_count, 4, &(memActive), &len, NULL, 0); |
33 |
+ memActive *= pageSizeKb; |
34 |
+ fpl->memActive = memActive; |
35 |
|
36 |
- sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(fpl->memWire), &len, NULL, 0); |
37 |
- fpl->memWire *= pageSizeKb; |
38 |
+ len = sizeof(memWire); |
39 |
+ sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(memWire), &len, NULL, 0); |
40 |
+ memWire *= pageSizeKb; |
41 |
+ fpl->memWire = memWire; |
42 |
|
43 |
- sysctl(MIB_vfs_bufspace, 2, &(pl->buffersMem), &len, NULL, 0); |
44 |
- pl->buffersMem /= 1024; |
45 |
+ len = sizeof(buffersMem); |
46 |
+ sysctl(MIB_vfs_bufspace, 2, &(buffersMem), &len, NULL, 0); |
47 |
+ buffersMem /= 1024; |
48 |
+ pl->buffersMem = buffersMem; |
49 |
|
50 |
- sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0); |
51 |
- pl->cachedMem *= pageSizeKb; |
52 |
+ len = sizeof(cachedMem); |
53 |
+ sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(cachedMem), &len, NULL, 0); |
54 |
+ cachedMem *= pageSizeKb; |
55 |
+ pl->cachedMem = cachedMem; |
56 |
|
57 |
if (fpl->zfsArcEnabled) { |
58 |
- len = sizeof(fpl->memZfsArc); |
59 |
- sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(fpl->memZfsArc), &len , NULL, 0); |
60 |
- fpl->memZfsArc /= 1024; |
61 |
+ len = sizeof(memZfsArc); |
62 |
+ sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(memZfsArc), &len , NULL, 0); |
63 |
+ memZfsArc /= 1024; |
64 |
+ fpl->memZfsArc = memZfsArc; |
65 |
fpl->memWire -= fpl->memZfsArc; |
66 |
pl->cachedMem += fpl->memZfsArc; |
67 |
// maybe when we learn how to make custom memory meter |