mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Serge Hallyn <serge.hallyn@canonical.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Alex Thorlton <athorlton@sgi.com>,
	"vishnu.ps" <vishnu.ps@samsung.com>
Subject: [RFC][PATCH] sysinfo: Use timespec64 accessors for calculating uptime
Date: Thu, 12 Mar 2015 10:24:03 -0700	[thread overview]
Message-ID: <1426181043-2453-1-git-send-email-john.stultz@linaro.org> (raw)

As part of the y2038 effort, convert sysinfo's uptime calculation
to use the timespec64 based accessor.

Uptime isn't likely to ever exceed a s32, so this doesn't actually
bring much in the way of change, but it is done for consistency
sake as we deprecate 32bit internal interfaces.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Alex Thorlton <athorlton@sgi.com>
Cc: "vishnu.ps" <vishnu.ps@samsung.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 kernel/sys.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index a03d9cd..6d2d700 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2260,12 +2260,16 @@ static int do_sysinfo(struct sysinfo *info)
 {
 	unsigned long mem_total, sav_total;
 	unsigned int mem_unit, bitcount;
-	struct timespec tp;
+	struct timespec64 tp;
 
 	memset(info, 0, sizeof(struct sysinfo));
 
-	get_monotonic_boottime(&tp);
-	info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
+	get_monotonic_boottime64(&tp);
+	/*
+	 * y2038: uptime is unlikely to ever grow beyond an s32
+	 * so this cast to a long shouldn't be an issue.
+	 */
+	info->uptime = (long)tp.tv_sec + (tp.tv_nsec ? 1 : 0);
 
 	get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
 
-- 
1.9.1


                 reply	other threads:[~2015-03-12 17:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1426181043-2453-1-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=athorlton@sgi.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gorcunov@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge.hallyn@canonical.com \
    --cc=tglx@linutronix.de \
    --cc=vishnu.ps@samsung.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

all inboxes | Powered by JetHome®