aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-09-26 02:32:41 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:48:58 -0400
commit3a4f7577c9ef393ca80c783f02ffbc125de771c7 (patch)
tree9b55b98309d0ac13e35db05379792d52b29a2345 /kernel
parent930631edd4b1fe2781d9fe90edbe35d89dfc94cc (diff)
[PATCH] swsusp: add write-speed instrumentation
Add some instrumentation to the swsusp writeout code to show what bandwidth we're achieving. Cc: Pavel Machek <pavel@ucw.cz> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/power/swap.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index f1dd146bd64d..79b66e734bdb 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -146,6 +146,26 @@ static void release_swap_writer(struct swap_map_handle *handle)
146 handle->bitmap = NULL; 146 handle->bitmap = NULL;
147} 147}
148 148
149static void show_speed(struct timeval *start, struct timeval *stop,
150 unsigned nr_pages, char *msg)
151{
152 s64 elapsed_centisecs64;
153 int centisecs;
154 int k;
155 int kps;
156
157 elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
158 do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
159 centisecs = elapsed_centisecs64;
160 if (centisecs == 0)
161 centisecs = 1; /* avoid div-by-zero */
162 k = nr_pages * (PAGE_SIZE / 1024);
163 kps = (k * 100) / centisecs;
164 printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
165 centisecs / 100, centisecs % 100,
166 kps / 1000, (kps % 1000) / 10);
167}
168
149static int get_swap_writer(struct swap_map_handle *handle) 169static int get_swap_writer(struct swap_map_handle *handle)
150{ 170{
151 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL); 171 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
@@ -206,17 +226,21 @@ static int flush_swap_writer(struct swap_map_handle *handle)
206 226
207static int save_image(struct swap_map_handle *handle, 227static int save_image(struct swap_map_handle *handle,
208 struct snapshot_handle *snapshot, 228 struct snapshot_handle *snapshot,
209 unsigned int nr_pages) 229 unsigned int nr_to_write)
210{ 230{
211 unsigned int m; 231 unsigned int m;
212 int ret; 232 int ret;
213 int error = 0; 233 int error = 0;
234 int nr_pages;
235 struct timeval start;
236 struct timeval stop;
214 237
215 printk("Saving image data pages (%u pages) ... ", nr_pages); 238 printk("Saving image data pages (%u pages) ... ", nr_to_write);
216 m = nr_pages / 100; 239 m = nr_to_write / 100;
217 if (!m) 240 if (!m)
218 m = 1; 241 m = 1;
219 nr_pages = 0; 242 nr_pages = 0;
243 do_gettimeofday(&start);
220 do { 244 do {
221 ret = snapshot_read_next(snapshot, PAGE_SIZE); 245 ret = snapshot_read_next(snapshot, PAGE_SIZE);
222 if (ret > 0) { 246 if (ret > 0) {
@@ -228,8 +252,10 @@ static int save_image(struct swap_map_handle *handle,
228 nr_pages++; 252 nr_pages++;
229 } 253 }
230 } while (ret > 0); 254 } while (ret > 0);
255 do_gettimeofday(&stop);
231 if (!error) 256 if (!error)
232 printk("\b\b\b\bdone\n"); 257 printk("\b\b\b\bdone\n");
258 show_speed(&start, &stop, nr_to_write, "Wrote");
233 return error; 259 return error;
234} 260}
235 261