/* * linux/kernel/power/swsusp.c * * This file provides code to write suspend image to swap and read it back. * * Copyright (C) 1998-2001 Gabor Kuti * Copyright (C) 1998,2001-2005 Pavel Machek * * This file is released under the GPLv2. * * I'd like to thank the following people for their work: * * Pavel Machek : * Modifications, defectiveness pointing, being with me at the very beginning, * suspend to swap space, stop all tasks. Port to 2.4.18-ac and 2.5.17. * * Steve Doddi : * Support the possibility of hardware state restoring. * * Raph : * Support for preserving states of network devices and virtual console * (including X and svgatextmode) * * Kurt Garloff : * Straightened the critical function in order to prevent compilers from * playing tricks with local variables. * * Andreas Mohr * * Alex Badea : * Fixed runaway init * * Rafael J. Wysocki * Reworked the freeing of memory and the handling of swap * * More state savers are welcome. Especially for the scsi layer... * * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "power.h" int in_suspend __nosavedata = 0; /** * swsusp_show_speed - print the time elapsed between two events represented by * @start and @stop * * @nr_pages - number of pages processed between @start and @stop * @msg - introductory message to print */ void swsusp_show_speed(struct timeval *start, struct timeval *stop, unsigned nr_pages, char *msg) { s64 elapsed_centisecs64; int centisecs; int k; int kps; elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start); do_div(elapsed_centisecs64, NSEC_PER_SEC / 100); centisecs = elapsed_centisecs64; if (centisecs == 0) centisecs = 1; /* avoid div-by-zero */ k = nr_pages * (PAGE_SIZE / 1024); kps = (k * 100) / centisecs; printk(KERN_INFO "PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k, centisecs / 100, centisecs % 100, kps / 1000, (kps % 1000) / 10); }