author | Niveditha Rau <Niveditha.Rau@Oracle.COM> |
Tue, 31 May 2016 12:38:42 -0700 | |
changeset 6118 | f0288987e55a |
permissions | -rw-r--r-- |
6118
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
1 |
Existing patch from desktop for building on Solaris - Needs reworking and cleanup so this can be contributed upstream. |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
2 |
|
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
3 |
XXX file upstream enhancement |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
4 |
|
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
5 |
--- libgtop-2.28.0/sysdeps/solaris/mem.c 2009-04-19 04:59:49.000000000 +0530 |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
6 |
+++ libgtop-2.28.0/sysdeps/solaris/mem.c.new 2009-11-24 14:42:33.575155966 +0530 |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
7 |
@@ -26,8 +26,42 @@ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
8 |
#include <assert.h> |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
9 |
#include <unistd.h> |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
10 |
|
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
11 |
+#include <sys/vm_usage.h> |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
12 |
+#include <sys/systeminfo.h> |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
13 |
+#include <sys/types.h> |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
14 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
15 |
#include <glibtop_private.h> |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
16 |
|
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
17 |
+unsigned int nrec; /* This is used in getvmusage to get the no of result structures */ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
18 |
+char arch[10]; /* This is used in sysinfo to get kernel bitness */ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
19 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
20 |
+typedef struct vmusage32 { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
21 |
+ id_t vmu_zoneid; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
22 |
+ uint_t vmu_type; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
23 |
+ id_t vmu_id; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
24 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
25 |
+ uint32_t vmu_rss_all; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
26 |
+ uint32_t vmu_rss_private; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
27 |
+ uint32_t vmu_rss_shared; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
28 |
+ uint32_t vmu_swap_all; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
29 |
+ uint32_t vmu_swap_private; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
30 |
+ uint32_t vmu_swap_shared; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
31 |
+} vmusage32_t; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
32 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
33 |
+typedef struct vmusage64 { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
34 |
+ id_t vmu_zoneid; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
35 |
+ uint_t vmu_type; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
36 |
+ id_t vmu_id; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
37 |
+ int vmu_align_next_members_on_8_bytes; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
38 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
39 |
+ uint64_t vmu_rss_all; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
40 |
+ uint64_t vmu_rss_private; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
41 |
+ uint64_t vmu_rss_shared; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
42 |
+ uint64_t vmu_swap_all; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
43 |
+ uint64_t vmu_swap_private; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
44 |
+ uint64_t vmu_swap_shared; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
45 |
+} vmusage64_t; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
46 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
47 |
/* Init function. */ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
48 |
|
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
49 |
void |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
50 |
@@ -97,37 +131,28 @@ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
51 |
} |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
52 |
} |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
53 |
|
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
54 |
- /* Bunyip module provides data in multiples of system page size */ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
55 |
- |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
56 |
- if((ksp = server->machine.bunyip) && kstat_read(kc, ksp, NULL) >= 0) |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
57 |
- { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
58 |
- kn = kstat_data_lookup(ksp, "pages_exec"); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
59 |
- if(kn) |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
60 |
- { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
61 |
- buf->shared = (KN_VALUE << PAGESHIFT); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
62 |
- buf->flags |= (1 << GLIBTOP_MEM_SHARED); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
63 |
- } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
64 |
- |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
65 |
- kn = kstat_data_lookup(ksp, "pages_vnode"); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
66 |
- if(kn) |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
67 |
- { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
68 |
- buf->buffer = (KN_VALUE << PAGESHIFT); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
69 |
- buf->flags |= (1 << GLIBTOP_MEM_BUFFER); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
70 |
- } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
71 |
- |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
72 |
- kn = kstat_data_lookup(ksp, "pages_anon"); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
73 |
- if(kn) |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
74 |
- { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
75 |
- buf->user = (KN_VALUE << PAGESHIFT); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
76 |
- buf->flags |= (1 << GLIBTOP_MEM_USER); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
77 |
- } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
78 |
- else |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
79 |
- goto user_old_way; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
80 |
- } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
81 |
- else /* Bunyip is not available, let's compute buf->user the old way */ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
82 |
+ vmusage64_t *result = (vmusage64_t*) malloc(sizeof(vmusage64_t)); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
83 |
+ vmusage32_t *vmu32; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
84 |
+ vmusage64_t *vmu64; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
85 |
+ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
86 |
+ if(getvmusage(VMUSAGE_SYSTEM, 5, result, &nrec) != 0) |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
87 |
{ |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
88 |
- user_old_way: |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
89 |
- buf->user = buf->total - buf->free - buf->cached - buf->buffer; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
90 |
- buf->flags |= (1 << GLIBTOP_MEM_USER); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
91 |
+ buf->user = buf->total - buf->free - buf->cached - buf->buffer; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
92 |
+ buf->flags |= (1 << GLIBTOP_MEM_USER); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
93 |
+ free(result); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
94 |
+ return; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
95 |
} |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
96 |
+ else { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
97 |
+ if(sysinfo(SI_ARCHITECTURE_64, arch, sizeof(arch)) < 0) |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
98 |
+ { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
99 |
+ vmu32 = (vmusage32_t*) result; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
100 |
+ buf->user = vmu32->vmu_rss_all; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
101 |
+ } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
102 |
+ else { |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
103 |
+ vmu64 = (vmusage64_t*) result; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
104 |
+ buf->user = vmu64->vmu_rss_all; |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
105 |
+ } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
106 |
+ buf->flags |= (1 << GLIBTOP_MEM_USER); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
107 |
+ free(result); |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
108 |
+ } |
f0288987e55a
23245333 Move libgtop to Userland and update to 2.32.0
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents:
diff
changeset
|
109 |
} |