diff options
-rw-r--r-- | kernel/power/hibernate.c | 14 | ||||
-rw-r--r-- | kernel/power/power.h | 3 | ||||
-rw-r--r-- | kernel/power/snapshot.c | 9 | ||||
-rw-r--r-- | kernel/power/swap.c | 41 |
4 files changed, 33 insertions, 34 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 1f35a3478f3c..2329daae5255 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/syscore_ops.h> | 28 | #include <linux/syscore_ops.h> |
29 | #include <linux/ctype.h> | 29 | #include <linux/ctype.h> |
30 | #include <linux/genhd.h> | 30 | #include <linux/genhd.h> |
31 | #include <linux/ktime.h> | ||
31 | #include <trace/events/power.h> | 32 | #include <trace/events/power.h> |
32 | 33 | ||
33 | #include "power.h" | 34 | #include "power.h" |
@@ -232,20 +233,17 @@ static void platform_recover(int platform_mode) | |||
232 | * @nr_pages: Number of memory pages processed between @start and @stop. | 233 | * @nr_pages: Number of memory pages processed between @start and @stop. |
233 | * @msg: Additional diagnostic message to print. | 234 | * @msg: Additional diagnostic message to print. |
234 | */ | 235 | */ |
235 | void swsusp_show_speed(struct timeval *start, struct timeval *stop, | 236 | void swsusp_show_speed(ktime_t start, ktime_t stop, |
236 | unsigned nr_pages, char *msg) | 237 | unsigned nr_pages, char *msg) |
237 | { | 238 | { |
239 | ktime_t diff; | ||
238 | u64 elapsed_centisecs64; | 240 | u64 elapsed_centisecs64; |
239 | unsigned int centisecs; | 241 | unsigned int centisecs; |
240 | unsigned int k; | 242 | unsigned int k; |
241 | unsigned int kps; | 243 | unsigned int kps; |
242 | 244 | ||
243 | elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start); | 245 | diff = ktime_sub(stop, start); |
244 | /* | 246 | elapsed_centisecs64 = ktime_divns(diff, 10*NSEC_PER_MSEC); |
245 | * If "(s64)elapsed_centisecs64 < 0", it will print long elapsed time, | ||
246 | * it is obvious enough for what went wrong. | ||
247 | */ | ||
248 | do_div(elapsed_centisecs64, NSEC_PER_SEC / 100); | ||
249 | centisecs = elapsed_centisecs64; | 247 | centisecs = elapsed_centisecs64; |
250 | if (centisecs == 0) | 248 | if (centisecs == 0) |
251 | centisecs = 1; /* avoid div-by-zero */ | 249 | centisecs = 1; /* avoid div-by-zero */ |
diff --git a/kernel/power/power.h b/kernel/power/power.h index 2df883a9d3cb..ce9b8328a689 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -174,8 +174,7 @@ extern int hib_wait_on_bio_chain(struct bio **bio_chain); | |||
174 | 174 | ||
175 | struct timeval; | 175 | struct timeval; |
176 | /* kernel/power/swsusp.c */ | 176 | /* kernel/power/swsusp.c */ |
177 | extern void swsusp_show_speed(struct timeval *, struct timeval *, | 177 | extern void swsusp_show_speed(ktime_t, ktime_t, unsigned int, char *); |
178 | unsigned int, char *); | ||
179 | 178 | ||
180 | #ifdef CONFIG_SUSPEND | 179 | #ifdef CONFIG_SUSPEND |
181 | /* kernel/power/suspend.c */ | 180 | /* kernel/power/suspend.c */ |
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 791a61892bb5..0c40c16174b4 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/list.h> | 28 | #include <linux/list.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/compiler.h> | 30 | #include <linux/compiler.h> |
31 | #include <linux/ktime.h> | ||
31 | 32 | ||
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
33 | #include <asm/mmu_context.h> | 34 | #include <asm/mmu_context.h> |
@@ -1576,11 +1577,11 @@ int hibernate_preallocate_memory(void) | |||
1576 | struct zone *zone; | 1577 | struct zone *zone; |
1577 | unsigned long saveable, size, max_size, count, highmem, pages = 0; | 1578 | unsigned long saveable, size, max_size, count, highmem, pages = 0; |
1578 | unsigned long alloc, save_highmem, pages_highmem, avail_normal; | 1579 | unsigned long alloc, save_highmem, pages_highmem, avail_normal; |
1579 | struct timeval start, stop; | 1580 | ktime_t start, stop; |
1580 | int error; | 1581 | int error; |
1581 | 1582 | ||
1582 | printk(KERN_INFO "PM: Preallocating image memory... "); | 1583 | printk(KERN_INFO "PM: Preallocating image memory... "); |
1583 | do_gettimeofday(&start); | 1584 | start = ktime_get(); |
1584 | 1585 | ||
1585 | error = memory_bm_create(&orig_bm, GFP_IMAGE, PG_ANY); | 1586 | error = memory_bm_create(&orig_bm, GFP_IMAGE, PG_ANY); |
1586 | if (error) | 1587 | if (error) |
@@ -1709,9 +1710,9 @@ int hibernate_preallocate_memory(void) | |||
1709 | free_unnecessary_pages(); | 1710 | free_unnecessary_pages(); |
1710 | 1711 | ||
1711 | out: | 1712 | out: |
1712 | do_gettimeofday(&stop); | 1713 | stop = ktime_get(); |
1713 | printk(KERN_CONT "done (allocated %lu pages)\n", pages); | 1714 | printk(KERN_CONT "done (allocated %lu pages)\n", pages); |
1714 | swsusp_show_speed(&start, &stop, pages, "Allocated"); | 1715 | swsusp_show_speed(start, stop, pages, "Allocated"); |
1715 | 1716 | ||
1716 | return 0; | 1717 | return 0; |
1717 | 1718 | ||
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index aaa3261dea5d..2c9d6d50a816 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/atomic.h> | 30 | #include <linux/atomic.h> |
31 | #include <linux/kthread.h> | 31 | #include <linux/kthread.h> |
32 | #include <linux/crc32.h> | 32 | #include <linux/crc32.h> |
33 | #include <linux/ktime.h> | ||
33 | 34 | ||
34 | #include "power.h" | 35 | #include "power.h" |
35 | 36 | ||
@@ -445,8 +446,8 @@ static int save_image(struct swap_map_handle *handle, | |||
445 | int nr_pages; | 446 | int nr_pages; |
446 | int err2; | 447 | int err2; |
447 | struct bio *bio; | 448 | struct bio *bio; |
448 | struct timeval start; | 449 | ktime_t start; |
449 | struct timeval stop; | 450 | ktime_t stop; |
450 | 451 | ||
451 | printk(KERN_INFO "PM: Saving image data pages (%u pages)...\n", | 452 | printk(KERN_INFO "PM: Saving image data pages (%u pages)...\n", |
452 | nr_to_write); | 453 | nr_to_write); |
@@ -455,7 +456,7 @@ static int save_image(struct swap_map_handle *handle, | |||
455 | m = 1; | 456 | m = 1; |
456 | nr_pages = 0; | 457 | nr_pages = 0; |
457 | bio = NULL; | 458 | bio = NULL; |
458 | do_gettimeofday(&start); | 459 | start = ktime_get(); |
459 | while (1) { | 460 | while (1) { |
460 | ret = snapshot_read_next(snapshot); | 461 | ret = snapshot_read_next(snapshot); |
461 | if (ret <= 0) | 462 | if (ret <= 0) |
@@ -469,12 +470,12 @@ static int save_image(struct swap_map_handle *handle, | |||
469 | nr_pages++; | 470 | nr_pages++; |
470 | } | 471 | } |
471 | err2 = hib_wait_on_bio_chain(&bio); | 472 | err2 = hib_wait_on_bio_chain(&bio); |
472 | do_gettimeofday(&stop); | 473 | stop = ktime_get(); |
473 | if (!ret) | 474 | if (!ret) |
474 | ret = err2; | 475 | ret = err2; |
475 | if (!ret) | 476 | if (!ret) |
476 | printk(KERN_INFO "PM: Image saving done.\n"); | 477 | printk(KERN_INFO "PM: Image saving done.\n"); |
477 | swsusp_show_speed(&start, &stop, nr_to_write, "Wrote"); | 478 | swsusp_show_speed(start, stop, nr_to_write, "Wrote"); |
478 | return ret; | 479 | return ret; |
479 | } | 480 | } |
480 | 481 | ||
@@ -580,8 +581,8 @@ static int save_image_lzo(struct swap_map_handle *handle, | |||
580 | int nr_pages; | 581 | int nr_pages; |
581 | int err2; | 582 | int err2; |
582 | struct bio *bio; | 583 | struct bio *bio; |
583 | struct timeval start; | 584 | ktime_t start; |
584 | struct timeval stop; | 585 | ktime_t stop; |
585 | size_t off; | 586 | size_t off; |
586 | unsigned thr, run_threads, nr_threads; | 587 | unsigned thr, run_threads, nr_threads; |
587 | unsigned char *page = NULL; | 588 | unsigned char *page = NULL; |
@@ -674,7 +675,7 @@ static int save_image_lzo(struct swap_map_handle *handle, | |||
674 | m = 1; | 675 | m = 1; |
675 | nr_pages = 0; | 676 | nr_pages = 0; |
676 | bio = NULL; | 677 | bio = NULL; |
677 | do_gettimeofday(&start); | 678 | start = ktime_get(); |
678 | for (;;) { | 679 | for (;;) { |
679 | for (thr = 0; thr < nr_threads; thr++) { | 680 | for (thr = 0; thr < nr_threads; thr++) { |
680 | for (off = 0; off < LZO_UNC_SIZE; off += PAGE_SIZE) { | 681 | for (off = 0; off < LZO_UNC_SIZE; off += PAGE_SIZE) { |
@@ -759,12 +760,12 @@ static int save_image_lzo(struct swap_map_handle *handle, | |||
759 | 760 | ||
760 | out_finish: | 761 | out_finish: |
761 | err2 = hib_wait_on_bio_chain(&bio); | 762 | err2 = hib_wait_on_bio_chain(&bio); |
762 | do_gettimeofday(&stop); | 763 | stop = ktime_get(); |
763 | if (!ret) | 764 | if (!ret) |
764 | ret = err2; | 765 | ret = err2; |
765 | if (!ret) | 766 | if (!ret) |
766 | printk(KERN_INFO "PM: Image saving done.\n"); | 767 | printk(KERN_INFO "PM: Image saving done.\n"); |
767 | swsusp_show_speed(&start, &stop, nr_to_write, "Wrote"); | 768 | swsusp_show_speed(start, stop, nr_to_write, "Wrote"); |
768 | out_clean: | 769 | out_clean: |
769 | if (crc) { | 770 | if (crc) { |
770 | if (crc->thr) | 771 | if (crc->thr) |
@@ -965,8 +966,8 @@ static int load_image(struct swap_map_handle *handle, | |||
965 | { | 966 | { |
966 | unsigned int m; | 967 | unsigned int m; |
967 | int ret = 0; | 968 | int ret = 0; |
968 | struct timeval start; | 969 | ktime_t start; |
969 | struct timeval stop; | 970 | ktime_t stop; |
970 | struct bio *bio; | 971 | struct bio *bio; |
971 | int err2; | 972 | int err2; |
972 | unsigned nr_pages; | 973 | unsigned nr_pages; |
@@ -978,7 +979,7 @@ static int load_image(struct swap_map_handle *handle, | |||
978 | m = 1; | 979 | m = 1; |
979 | nr_pages = 0; | 980 | nr_pages = 0; |
980 | bio = NULL; | 981 | bio = NULL; |
981 | do_gettimeofday(&start); | 982 | start = ktime_get(); |
982 | for ( ; ; ) { | 983 | for ( ; ; ) { |
983 | ret = snapshot_write_next(snapshot); | 984 | ret = snapshot_write_next(snapshot); |
984 | if (ret <= 0) | 985 | if (ret <= 0) |
@@ -996,7 +997,7 @@ static int load_image(struct swap_map_handle *handle, | |||
996 | nr_pages++; | 997 | nr_pages++; |
997 | } | 998 | } |
998 | err2 = hib_wait_on_bio_chain(&bio); | 999 | err2 = hib_wait_on_bio_chain(&bio); |
999 | do_gettimeofday(&stop); | 1000 | stop = ktime_get(); |
1000 | if (!ret) | 1001 | if (!ret) |
1001 | ret = err2; | 1002 | ret = err2; |
1002 | if (!ret) { | 1003 | if (!ret) { |
@@ -1005,7 +1006,7 @@ static int load_image(struct swap_map_handle *handle, | |||
1005 | if (!snapshot_image_loaded(snapshot)) | 1006 | if (!snapshot_image_loaded(snapshot)) |
1006 | ret = -ENODATA; | 1007 | ret = -ENODATA; |
1007 | } | 1008 | } |
1008 | swsusp_show_speed(&start, &stop, nr_to_read, "Read"); | 1009 | swsusp_show_speed(start, stop, nr_to_read, "Read"); |
1009 | return ret; | 1010 | return ret; |
1010 | } | 1011 | } |
1011 | 1012 | ||
@@ -1067,8 +1068,8 @@ static int load_image_lzo(struct swap_map_handle *handle, | |||
1067 | int ret = 0; | 1068 | int ret = 0; |
1068 | int eof = 0; | 1069 | int eof = 0; |
1069 | struct bio *bio; | 1070 | struct bio *bio; |
1070 | struct timeval start; | 1071 | ktime_t start; |
1071 | struct timeval stop; | 1072 | ktime_t stop; |
1072 | unsigned nr_pages; | 1073 | unsigned nr_pages; |
1073 | size_t off; | 1074 | size_t off; |
1074 | unsigned i, thr, run_threads, nr_threads; | 1075 | unsigned i, thr, run_threads, nr_threads; |
@@ -1190,7 +1191,7 @@ static int load_image_lzo(struct swap_map_handle *handle, | |||
1190 | m = 1; | 1191 | m = 1; |
1191 | nr_pages = 0; | 1192 | nr_pages = 0; |
1192 | bio = NULL; | 1193 | bio = NULL; |
1193 | do_gettimeofday(&start); | 1194 | start = ktime_get(); |
1194 | 1195 | ||
1195 | ret = snapshot_write_next(snapshot); | 1196 | ret = snapshot_write_next(snapshot); |
1196 | if (ret <= 0) | 1197 | if (ret <= 0) |
@@ -1343,7 +1344,7 @@ out_finish: | |||
1343 | wait_event(crc->done, atomic_read(&crc->stop)); | 1344 | wait_event(crc->done, atomic_read(&crc->stop)); |
1344 | atomic_set(&crc->stop, 0); | 1345 | atomic_set(&crc->stop, 0); |
1345 | } | 1346 | } |
1346 | do_gettimeofday(&stop); | 1347 | stop = ktime_get(); |
1347 | if (!ret) { | 1348 | if (!ret) { |
1348 | printk(KERN_INFO "PM: Image loading done.\n"); | 1349 | printk(KERN_INFO "PM: Image loading done.\n"); |
1349 | snapshot_write_finalize(snapshot); | 1350 | snapshot_write_finalize(snapshot); |
@@ -1359,7 +1360,7 @@ out_finish: | |||
1359 | } | 1360 | } |
1360 | } | 1361 | } |
1361 | } | 1362 | } |
1362 | swsusp_show_speed(&start, &stop, nr_to_read, "Read"); | 1363 | swsusp_show_speed(start, stop, nr_to_read, "Read"); |
1363 | out_clean: | 1364 | out_clean: |
1364 | for (i = 0; i < ring_size; i++) | 1365 | for (i = 0; i < ring_size; i++) |
1365 | free_page((unsigned long)page[i]); | 1366 | free_page((unsigned long)page[i]); |