Lines 1-78
Link Here
|
1 |
Fix memory display in the header 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 |
@@ -28,8 +28,9 @@ in the source distribution for its full text. |
8 |
#include <sys/resource.h> |
9 |
|
10 |
#define JAIL_ERRMSGLEN 1024 |
11 |
+*/ |
12 |
char jail_errmsg[JAIL_ERRMSGLEN]; |
13 |
- |
14 |
+/* |
15 |
typedef struct CPUData_ { |
16 |
|
17 |
double userPercent; |
18 |
@@ -296,31 +297,46 @@ static inline void FreeBSDProcessList_scanMemoryInfo(P |
19 |
// |
20 |
// htop_used = active + (wired - arc) |
21 |
// htop_cache = buffers + cache + arc |
22 |
- size_t len = sizeof(pl->totalMem); |
23 |
+ u_long totalMem; |
24 |
+ u_int memActive, memWire, cachedMem; |
25 |
+ long buffersMem; |
26 |
+ uint64_t memZfsArc; |
27 |
+ size_t len; |
28 |
|
29 |
//disabled for now, as it is always smaller than phycal amount of memory... |
30 |
//...to avoid "where is my memory?" questions |
31 |
//sysctl(MIB_vm_stats_vm_v_page_count, 4, &(pl->totalMem), &len, NULL, 0); |
32 |
//pl->totalMem *= pageSizeKb; |
33 |
- sysctl(MIB_hw_physmem, 2, &(pl->totalMem), &len, NULL, 0); |
34 |
- pl->totalMem /= 1024; |
35 |
+ len = sizeof(totalMem); |
36 |
+ sysctl(MIB_hw_physmem, 2, &(totalMem), &len, NULL, 0); |
37 |
+ totalMem /= 1024; |
38 |
+ pl->totalMem = totalMem; |
39 |
|
40 |
- sysctl(MIB_vm_stats_vm_v_active_count, 4, &(fpl->memActive), &len, NULL, 0); |
41 |
- fpl->memActive *= pageSizeKb; |
42 |
+ len = sizeof(memActive); |
43 |
+ sysctl(MIB_vm_stats_vm_v_active_count, 4, &(memActive), &len, NULL, 0); |
44 |
+ memActive *= pageSizeKb; |
45 |
+ fpl->memActive = memActive; |
46 |
|
47 |
- sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(fpl->memWire), &len, NULL, 0); |
48 |
- fpl->memWire *= pageSizeKb; |
49 |
+ len = sizeof(memWire); |
50 |
+ sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(memWire), &len, NULL, 0); |
51 |
+ memWire *= pageSizeKb; |
52 |
+ fpl->memWire = memWire; |
53 |
|
54 |
- sysctl(MIB_vfs_bufspace, 2, &(pl->buffersMem), &len, NULL, 0); |
55 |
- pl->buffersMem /= 1024; |
56 |
+ len = sizeof(buffersMem); |
57 |
+ sysctl(MIB_vfs_bufspace, 2, &(buffersMem), &len, NULL, 0); |
58 |
+ buffersMem /= 1024; |
59 |
+ pl->buffersMem = buffersMem; |
60 |
|
61 |
- sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0); |
62 |
- pl->cachedMem *= pageSizeKb; |
63 |
+ len = sizeof(cachedMem); |
64 |
+ sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(cachedMem), &len, NULL, 0); |
65 |
+ cachedMem *= pageSizeKb; |
66 |
+ pl->cachedMem = cachedMem; |
67 |
|
68 |
if (fpl->zfsArcEnabled) { |
69 |
- len = sizeof(fpl->memZfsArc); |
70 |
- sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(fpl->memZfsArc), &len , NULL, 0); |
71 |
- fpl->memZfsArc /= 1024; |
72 |
+ len = sizeof(memZfsArc); |
73 |
+ sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(memZfsArc), &len , NULL, 0); |
74 |
+ memZfsArc /= 1024; |
75 |
+ fpl->memZfsArc = memZfsArc; |
76 |
fpl->memWire -= fpl->memZfsArc; |
77 |
pl->cachedMem += fpl->memZfsArc; |
78 |
// maybe when we learn how to make custom memory meter |