diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/s390/appldata/appldata_mem.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/s390/appldata/appldata_mem.c')
-rw-r--r-- | arch/s390/appldata/appldata_mem.c | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/arch/s390/appldata/appldata_mem.c b/arch/s390/appldata/appldata_mem.c new file mode 100644 index 000000000000..462ee9a84e76 --- /dev/null +++ b/arch/s390/appldata/appldata_mem.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * arch/s390/appldata/appldata_mem.c | ||
3 | * | ||
4 | * Data gathering module for Linux-VM Monitor Stream, Stage 1. | ||
5 | * Collects data related to memory management. | ||
6 | * | ||
7 | * Copyright (C) 2003 IBM Corporation, IBM Deutschland Entwicklung GmbH. | ||
8 | * | ||
9 | * Author: Gerald Schaefer <geraldsc@de.ibm.com> | ||
10 | */ | ||
11 | |||
12 | #include <linux/config.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/kernel_stat.h> | ||
18 | #include <asm/io.h> | ||
19 | #include <linux/pagemap.h> | ||
20 | #include <linux/swap.h> | ||
21 | |||
22 | #include "appldata.h" | ||
23 | |||
24 | |||
25 | #define MY_PRINT_NAME "appldata_mem" /* for debug messages, etc. */ | ||
26 | #define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* Converts #Pages to KB */ | ||
27 | |||
28 | /* | ||
29 | * Memory data | ||
30 | * | ||
31 | * This is accessed as binary data by z/VM. If changes to it can't be avoided, | ||
32 | * the structure version (product ID, see appldata_base.c) needs to be changed | ||
33 | * as well and all documentation and z/VM applications using it must be | ||
34 | * updated. | ||
35 | * | ||
36 | * The record layout is documented in the Linux for zSeries Device Drivers | ||
37 | * book: | ||
38 | * http://oss.software.ibm.com/developerworks/opensource/linux390/index.shtml | ||
39 | */ | ||
40 | struct appldata_mem_data { | ||
41 | u64 timestamp; | ||
42 | u32 sync_count_1; /* after VM collected the record data, */ | ||
43 | u32 sync_count_2; /* sync_count_1 and sync_count_2 should be the | ||
44 | same. If not, the record has been updated on | ||
45 | the Linux side while VM was collecting the | ||
46 | (possibly corrupt) data */ | ||
47 | |||
48 | u64 pgpgin; /* data read from disk */ | ||
49 | u64 pgpgout; /* data written to disk */ | ||
50 | u64 pswpin; /* pages swapped in */ | ||
51 | u64 pswpout; /* pages swapped out */ | ||
52 | |||
53 | u64 sharedram; /* sharedram is currently set to 0 */ | ||
54 | |||
55 | u64 totalram; /* total main memory size */ | ||
56 | u64 freeram; /* free main memory size */ | ||
57 | u64 totalhigh; /* total high memory size */ | ||
58 | u64 freehigh; /* free high memory size */ | ||
59 | |||
60 | u64 bufferram; /* memory reserved for buffers, free cache */ | ||
61 | u64 cached; /* size of (used) cache, w/o buffers */ | ||
62 | u64 totalswap; /* total swap space size */ | ||
63 | u64 freeswap; /* free swap space */ | ||
64 | |||
65 | // New in 2.6 --> | ||
66 | u64 pgalloc; /* page allocations */ | ||
67 | u64 pgfault; /* page faults (major+minor) */ | ||
68 | u64 pgmajfault; /* page faults (major only) */ | ||
69 | // <-- New in 2.6 | ||
70 | |||
71 | } appldata_mem_data; | ||
72 | |||
73 | |||
74 | static inline void appldata_debug_print(struct appldata_mem_data *mem_data) | ||
75 | { | ||
76 | P_DEBUG("--- MEM - RECORD ---\n"); | ||
77 | P_DEBUG("pgpgin = %8lu KB\n", mem_data->pgpgin); | ||
78 | P_DEBUG("pgpgout = %8lu KB\n", mem_data->pgpgout); | ||
79 | P_DEBUG("pswpin = %8lu Pages\n", mem_data->pswpin); | ||
80 | P_DEBUG("pswpout = %8lu Pages\n", mem_data->pswpout); | ||
81 | P_DEBUG("pgalloc = %8lu \n", mem_data->pgalloc); | ||
82 | P_DEBUG("pgfault = %8lu \n", mem_data->pgfault); | ||
83 | P_DEBUG("pgmajfault = %8lu \n", mem_data->pgmajfault); | ||
84 | P_DEBUG("sharedram = %8lu KB\n", mem_data->sharedram); | ||
85 | P_DEBUG("totalram = %8lu KB\n", mem_data->totalram); | ||
86 | P_DEBUG("freeram = %8lu KB\n", mem_data->freeram); | ||
87 | P_DEBUG("totalhigh = %8lu KB\n", mem_data->totalhigh); | ||
88 | P_DEBUG("freehigh = %8lu KB\n", mem_data->freehigh); | ||
89 | P_DEBUG("bufferram = %8lu KB\n", mem_data->bufferram); | ||
90 | P_DEBUG("cached = %8lu KB\n", mem_data->cached); | ||
91 | P_DEBUG("totalswap = %8lu KB\n", mem_data->totalswap); | ||
92 | P_DEBUG("freeswap = %8lu KB\n", mem_data->freeswap); | ||
93 | P_DEBUG("sync_count_1 = %u\n", mem_data->sync_count_1); | ||
94 | P_DEBUG("sync_count_2 = %u\n", mem_data->sync_count_2); | ||
95 | P_DEBUG("timestamp = %lX\n", mem_data->timestamp); | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * appldata_get_mem_data() | ||
100 | * | ||
101 | * gather memory data | ||
102 | */ | ||
103 | static void appldata_get_mem_data(void *data) | ||
104 | { | ||
105 | /* | ||
106 | * don't put large structures on the stack, we are | ||
107 | * serialized through the appldata_ops_lock and can use static | ||
108 | */ | ||
109 | static struct sysinfo val; | ||
110 | static struct page_state ps; | ||
111 | struct appldata_mem_data *mem_data; | ||
112 | |||
113 | mem_data = data; | ||
114 | mem_data->sync_count_1++; | ||
115 | |||
116 | get_full_page_state(&ps); | ||
117 | mem_data->pgpgin = ps.pgpgin >> 1; | ||
118 | mem_data->pgpgout = ps.pgpgout >> 1; | ||
119 | mem_data->pswpin = ps.pswpin; | ||
120 | mem_data->pswpout = ps.pswpout; | ||
121 | mem_data->pgalloc = ps.pgalloc_high + ps.pgalloc_normal + | ||
122 | ps.pgalloc_dma; | ||
123 | mem_data->pgfault = ps.pgfault; | ||
124 | mem_data->pgmajfault = ps.pgmajfault; | ||
125 | |||
126 | si_meminfo(&val); | ||
127 | mem_data->sharedram = val.sharedram; | ||
128 | mem_data->totalram = P2K(val.totalram); | ||
129 | mem_data->freeram = P2K(val.freeram); | ||
130 | mem_data->totalhigh = P2K(val.totalhigh); | ||
131 | mem_data->freehigh = P2K(val.freehigh); | ||
132 | mem_data->bufferram = P2K(val.bufferram); | ||
133 | mem_data->cached = P2K(atomic_read(&nr_pagecache) - val.bufferram); | ||
134 | |||
135 | si_swapinfo(&val); | ||
136 | mem_data->totalswap = P2K(val.totalswap); | ||
137 | mem_data->freeswap = P2K(val.freeswap); | ||
138 | |||
139 | mem_data->timestamp = get_clock(); | ||
140 | mem_data->sync_count_2++; | ||
141 | #ifdef APPLDATA_DEBUG | ||
142 | appldata_debug_print(mem_data); | ||
143 | #endif | ||
144 | } | ||
145 | |||
146 | |||
147 | static struct appldata_ops ops = { | ||
148 | .ctl_nr = CTL_APPLDATA_MEM, | ||
149 | .name = "mem", | ||
150 | .record_nr = APPLDATA_RECORD_MEM_ID, | ||
151 | .size = sizeof(struct appldata_mem_data), | ||
152 | .callback = &appldata_get_mem_data, | ||
153 | .data = &appldata_mem_data, | ||
154 | .owner = THIS_MODULE, | ||
155 | }; | ||
156 | |||
157 | |||
158 | /* | ||
159 | * appldata_mem_init() | ||
160 | * | ||
161 | * init_data, register ops | ||
162 | */ | ||
163 | static int __init appldata_mem_init(void) | ||
164 | { | ||
165 | int rc; | ||
166 | |||
167 | P_DEBUG("sizeof(mem) = %lu\n", sizeof(struct appldata_mem_data)); | ||
168 | |||
169 | rc = appldata_register_ops(&ops); | ||
170 | if (rc != 0) { | ||
171 | P_ERROR("Error registering ops, rc = %i\n", rc); | ||
172 | } else { | ||
173 | P_DEBUG("%s-ops registered!\n", ops.name); | ||
174 | } | ||
175 | return rc; | ||
176 | } | ||
177 | |||
178 | /* | ||
179 | * appldata_mem_exit() | ||
180 | * | ||
181 | * unregister ops | ||
182 | */ | ||
183 | static void __exit appldata_mem_exit(void) | ||
184 | { | ||
185 | appldata_unregister_ops(&ops); | ||
186 | P_DEBUG("%s-ops unregistered!\n", ops.name); | ||
187 | } | ||
188 | |||
189 | |||
190 | module_init(appldata_mem_init); | ||
191 | module_exit(appldata_mem_exit); | ||
192 | |||
193 | MODULE_LICENSE("GPL"); | ||
194 | MODULE_AUTHOR("Gerald Schaefer"); | ||
195 | MODULE_DESCRIPTION("Linux-VM Monitor Stream, MEMORY statistics"); | ||