Skip to contentSkip to conversation

time: include math64.h in time64.h

PATCH In review Xunlei Pang 2 participants 4 messages Apr 9, 2015 – May 13, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 time: include math64.h in time64.h

From: Xunlei Pang <[email protected]>

On 32-bit systems, timespec64_add_ns() calls __iter_div_u64_rem() which needs match64.h, and we want to include time64.h in some cases.

---
 include/linux/time64.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/time64.h +1 -0
index a383147..12d4e82 100644
@@ -2,6 +2,7 @@
 #define _LINUX_TIME64_H
 
 #include <uapi/linux/time.h>
+#include <linux/math64.h>
 
 typedef __s64 time64_t;
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 s390: time: Provide read_boot_clock64() and read_persistent_clock64()

From: Xunlei Pang <[email protected]>

As part of addressing "y2038 problem" for in-kernel uses, this patch converts read_boot_clock() to read_boot_clock64() and read_persistent_clock() to read_persistent_clock64() using timespec64.

Rename some timespec to timespec64 in time.c and related references.

---
We've already had read_boot_clock64() in timekeeping, now provide read_boot_clock64() for S390.

 arch/s390/include/asm/timex.h |  5 +++--
 arch/s390/kernel/debug.c      | 11 ++++++-----
 arch/s390/kernel/time.c       |  6 +++---
 3 files changed, 12 insertions(+), 10 deletions(-)
arch/s390/include/asm/timex.h +3 -2
index 98eb2a5..f39220f 100644
@@ -10,6 +10,7 @@
 #define _ASM_S390_TIMEX_H
 
 #include <asm/lowcore.h>
+#include <linux/time64.h>
 
 /* The value of the TOD clock for 1.1.1970. */
 #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
@@ -108,10 +109,10 @@ int get_sync_clock(unsigned long long *clock);
 void init_cpu_timer(void);
 unsigned long long monotonic_clock(void);
 
-void tod_to_timeval(__u64, struct timespec *);
+void tod_to_timeval(__u64, struct timespec64 *);
 
 static inline
-void stck_to_timespec(unsigned long long stck, struct timespec *ts)
+void stck_to_timespec64(unsigned long long stck, struct timespec64 *ts)
 {
 	tod_to_timeval(stck - TOD_UNIX_EPOCH, ts);
 }
arch/s390/kernel/debug.c +6 -5
index c1f21ac..4f2d11d 100644
@@ -1457,23 +1457,24 @@ int
 debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
 			 int area, debug_entry_t * entry, char *out_buf)
 {
-	struct timespec time_spec;
+	struct timespec64 time_spec;
 	char *except_str;
 	unsigned long caller;
 	int rc = 0;
 	unsigned int level;
 
 	level = entry->id.fields.level;
-	stck_to_timespec(entry->id.stck, &time_spec);
+	stck_to_timespec64(entry->id.stck, &time_spec);
 
 	if (entry->id.fields.exception)
 		except_str = "*";
 	else
 		except_str = "-";
 	caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN;
-	rc += sprintf(out_buf, "%02i %011lu:%06lu %1u %1s %02i %p  ",
-		      area, time_spec.tv_sec, time_spec.tv_nsec / 1000, level,
-		      except_str, entry->id.fields.cpuid, (void *) caller);
+	rc += sprintf(out_buf, "%02i %011lld:%06lu %1u %1s %02i %p  ",
+		      area, (long long) time_spec.tv_sec,
+		      time_spec.tv_nsec / 1000, level, except_str,
+		      entry->id.fields.cpuid, (void *) caller);
 	return rc;
 }
 EXPORT_SYMBOL(debug_dflt_header_fn);
arch/s390/kernel/time.c +3 -3
index 170ddd2..9e733d9 100644
@@ -76,7 +76,7 @@ unsigned long long monotonic_clock(void)
 }
 EXPORT_SYMBOL(monotonic_clock);
 
-void tod_to_timeval(__u64 todval, struct timespec *xt)
+void tod_to_timeval(__u64 todval, struct timespec64 *xt)
 {
 	unsigned long long sec;
 
@@ -181,12 +181,12 @@ static void timing_alert_interrupt(struct ext_code ext_code,
 static void etr_reset(void);
 static void stp_reset(void);
 
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
 	tod_to_timeval(get_tod_clock() - TOD_UNIX_EPOCH, ts);
 }
 
-void read_boot_clock(struct timespec *ts)
+void read_boot_clock64(struct timespec64 *ts)
 {
 	tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, ts);
 }
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 time: Remove read_boot_clock()

In reply to Xunlei Pang

From: Xunlei Pang <[email protected]>

Now we have all the read_boot_clock64() for all implementations, it's time to remove read_boot_clock() completely from the kernel.

---
 include/linux/timekeeping.h |  1 -
 kernel/time/timekeeping.c   | 14 +++-----------
 2 files changed, 3 insertions(+), 12 deletions(-)
include/linux/timekeeping.h +0 -1
index 99176af..88e5f2e 100644
@@ -266,7 +266,6 @@ extern int persistent_clock_is_local;
 
 extern void read_persistent_clock(struct timespec *ts);
 extern void read_persistent_clock64(struct timespec64 *ts);
-extern void read_boot_clock(struct timespec *ts);
 extern void read_boot_clock64(struct timespec64 *ts);
 extern int update_persistent_clock(struct timespec now);
 extern int update_persistent_clock64(struct timespec64 now);
kernel/time/timekeeping.c +3 -11
index 946acb7..87f0ea5 100644
@@ -1179,28 +1179,20 @@ void __weak read_persistent_clock64(struct timespec64 *ts64)
 }
 
 /**
- * read_boot_clock -  Return time of the system start.
+ * read_boot_clock64 -  Return time of the system start.
  *
  * Weak dummy function for arches that do not yet support it.
  * Function to read the exact time the system has been started.
- * Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.
+ * Returns a timespec64 with tv_sec=0 and tv_nsec=0 if unsupported.
  *
  *  XXX - Do be sure to remove it once all arches implement it.
  */
-void __weak read_boot_clock(struct timespec *ts)
+void __weak read_boot_clock64(struct timespec64 *ts)
 {
 	ts->tv_sec = 0;
 	ts->tv_nsec = 0;
 }
 
-void __weak read_boot_clock64(struct timespec64 *ts64)
-{
-	struct timespec ts;
-
-	read_boot_clock(&ts);
-	*ts64 = timespec_to_timespec64(ts);
-}
-
 /* Flag for if timekeeping_resume() has injected sleeptime */
 static bool sleeptime_injected;
 
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): OFA4796A71.FC7D341F-ON48257E31.002793F7-48257E31.0028F99A@zte.com.cn

#4 lore raw

Re: [PATCH 3/3] time: Remove read_boot_clock()

Quoted 13 lines · On Fri, Apr 24, 2015 at 12:27 AM, <[email protected]> wrote:

Ping

[email protected] wrote 2015-04-09 AM 09:04:42:

Quoted 9 lines

[PATCH 3/3] time: Remove read_boot_clock()

From: Xunlei Pang <[email protected]>

Now we have all the read_boot_clock64() for all implementations, it's time to remove read_boot_clock() completely from the kernel.

Queued for testing & hopefully 4.2

thanks
-john