From: Pavel Machek <pavel@ucw.cz>
To: Tina Ruchandani <ruchandani.tina@gmail.com>
Cc: Linux PM List <linux-pm@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>, Len Brown <len.brown@intel.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] PM: Use 64-bit timekeeping
Date: Wed, 28 Jan 2015 08:42:54 +0100 [thread overview]
Message-ID: <20150128074254.GA31048@amd> (raw)
In-Reply-To: <20150128043836.GA4112@tinar>
On Wed 2015-01-28 10:08:37, Tina Ruchandani wrote:
> The freezer try_to_freeze_tasks uses 'struct timeval' for start
> and end times, tracking time taken to freeze tasks. 'struct timeval'
> on 32-bit systems will have its tv_sec overflow in year 2038 and
> beyond. This patches uses 'ktime_t' (which has 64 bit values
> for seconds) for start and end time.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Nicer code, and without the overflow. Thanks!
Acked-by: Pavel Machek <pavel@ucw.cz>
> ---
> Changes in v2:
> - Use ktime_t to be able to use ktime_ms_delta
> which is more efficient than timespec64 based methods.
> ---
> kernel/power/process.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/power/process.c b/kernel/power/process.c
> index 5a6ec86..52414dd 100644
> --- a/kernel/power/process.c
> +++ b/kernel/power/process.c
> @@ -17,6 +17,7 @@
> #include <linux/delay.h>
> #include <linux/workqueue.h>
> #include <linux/kmod.h>
> +#include <linux/ktime.h>
> #include <trace/events/power.h>
x>
> /*
> @@ -30,13 +31,12 @@ static int try_to_freeze_tasks(bool user_only)
> unsigned long end_time;
> unsigned int todo;
> bool wq_busy = false;
> - struct timeval start, end;
> - u64 elapsed_msecs64;
> + ktime_t start, end;
> unsigned int elapsed_msecs;
> bool wakeup = false;
> int sleep_usecs = USEC_PER_MSEC;
>
> - do_gettimeofday(&start);
> + start = ktime_get();
>
> end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);
>
> @@ -78,10 +78,8 @@ static int try_to_freeze_tasks(bool user_only)
> sleep_usecs *= 2;
> }
>
> - do_gettimeofday(&end);
> - elapsed_msecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
> - do_div(elapsed_msecs64, NSEC_PER_MSEC);
> - elapsed_msecs = elapsed_msecs64;
> + end = ktime_get();
> + elapsed_msecs = (unsigned int) ktime_ms_delta(end, start);
>
> if (todo) {
> printk("\n");
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
prev parent reply other threads:[~2015-01-28 20:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 4:38 [PATCH v2] PM: Use 64-bit timekeeping Tina Ruchandani
2015-01-28 7:42 ` Pavel Machek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150128074254.GA31048@amd \
--to=pavel@ucw.cz \
--cc=arnd@arndb.de \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=ruchandani.tina@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).