Skip to contentSkip to conversation

Use timespec64 for select like timeouts

PATCH Applied Deepa Dinamani 5 participants 12 messages Apr 29, 2016 – May 6, 2016

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

cover Use timespec64 for select like timeouts

The series is part of y2038 changes.

This changes a few syscalls that have common functions to use struct timespec64 instead of struct timespec.

This does not include changes to system call uapi interfaces. Those will be in a different series.

Thanks to Arnd Bergmann for comments on the patches.

Deepa Dinamani (3):
time: Add missing implementation for timespec64_add_safe()
fs: poll/select/recvmmsg: use timespec64 for timeout events
time: Remove timespec_add_safe()

 fs/eventpoll.c         | 12 ++++-----
 fs/select.c            | 67 ++++++++++++++++++++++++++++----------------------
 include/linux/poll.h   | 11 +++++----
 include/linux/time64.h | 17 ++++++-------
 kernel/time/time.c     | 21 ++++++++++++++++
 net/socket.c           |  8 +++---
 6 files changed, 82 insertions(+), 54 deletions(-)
Signature · 7 lines
1.9.1

Cc: John Stultz <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
#1 lore raw

PATCH 1/3 time: Add missing implementation for timespec64_add_safe()

timespec64_add_safe() has been defined in time64.h for 64 bit systems.
But, 32 bit systems only have an extern function prototype defined. Provide a definition for the above function.

The function will be necessary as part of y2038 changes. struct timespec is not y2038 safe. All references to timespec will be replaced by struct timespec64. The function is meant to be a replacement for timespec_add_safe().

The implementation is similar to timespec_add_safe().

Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 include/linux/time64.h |  4 +---
 kernel/time/time.c     | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
include/linux/time64.h +1 -3
index 367d5af..1778937 100644
@@ -136,13 +136,11 @@ extern void set_normalized_timespec64(struct timespec64 *ts, time64_t sec, s64 n
 
 /*
  * timespec64_add_safe assumes both values are positive and checks for
- * overflow. It will return TIME_T_MAX if the returned value would be
- * smaller then either of the arguments.
+ * overflow. It will return TIME64_MAX in case of overflow.
  */
 extern struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
 					 const struct timespec64 rhs);
 
-
 static inline struct timespec64 timespec64_add(struct timespec64 lhs,
 						struct timespec64 rhs)
 {
kernel/time/time.c +25 -0
index be115b0..558f5fe 100644
@@ -769,3 +769,28 @@ struct timespec timespec_add_safe(const struct timespec lhs,
 
 	return res;
 }
+
+#if __BITS_PER_LONG != 64
+
+/*
+ * Add two timespec64 values and do a safety check for overflow.
+ * It's assumed that both values are valid (>= 0).
+ * And, each timespec64 is in normalized form.
+ */
+struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
+				const struct timespec64 rhs)
+{
+	struct timespec64 res;
+
+	set_normalized_timespec64(&res, lhs.tv_sec + rhs.tv_sec,
+			lhs.tv_nsec + rhs.tv_nsec);
+
+	if (unlikely(res.tv_sec < lhs.tv_sec || res.tv_sec < rhs.tv_sec)) {
+		res.tv_sec = TIME64_MAX;
+		res.tv_nsec = 0;
+	}
+
+	return res;
+}
+
+#endif
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 1/3] time: Add missing implementation for timespec64_add_safe()

Wanted to add a note here:

kernel/time/time.c struct timespec timespec_add_safe(const struct timespec lhs, · line 788

Quoted 13 lines

+ * Add two timespec64 values and do a safety check for overflow.
+ * It's assumed that both values are valid (>= 0).
+ * And, each timespec64 is in normalized form.
+ */

kernel/time/time.c +9 -0
+struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
+                               const struct timespec64 rhs)
+{
+       struct timespec64 res;
+
+       set_normalized_timespec64(&res, lhs.tv_sec + rhs.tv_sec,
+                       lhs.tv_nsec + rhs.tv_nsec);
+
+       if (unlikely(res.tv_sec < lhs.tv_sec || res.tv_sec < rhs.tv_sec)) {

This check can be reduced to only the first condition if we assume the timespecs passed in to be normalized.
The current patch maintains the way timespec_add_safe() does it for consistency.

-Deepa

#3 lore raw

Re: [PATCH 1/3] time: Add missing implementation for timespec64_add_safe()

In reply to Deepa Dinamani
Quoted 12 lines · Deepa Dinamani

timespec64_add_safe() has been defined in time64.h for 64 bit systems.
But, 32 bit systems only have an extern function prototype defined. Provide a definition for the above function.

The function will be necessary as part of y2038 changes. struct timespec is not y2038 safe. All references to timespec will be replaced by struct timespec64. The function is meant to be a replacement for timespec_add_safe().

The implementation is similar to timespec_add_safe().

Quoted 7 lines
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 include/linux/time64.h |  4 +---
 kernel/time/time.c     | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

Looks ok at the first glance. I've queued these up for testing, however I only got #1 and #3 of the set. Are you hoping these two patches will go through tip/timers/core or are you looking for acks so they can go via another tree?

thanks
-john

#4 lore raw

PATCH 2/3 fs: poll/select/recvmmsg: use timespec64 for timeout events

In reply to Deepa Dinamani

struct timespec is not y2038 safe.
Even though timespec might be sufficient to represent timeouts, use struct timespec64 here as the plan is to get rid of all timespec reference in the kernel.

The patch transitions the common functions:
poll_select_set_timeout() and select_estimate_accuracy() to use timespec64. And, all the syscalls that use these functions are transitioned in the same patch.

The restart block parameters for poll uses monotonic time. Use timespec64 here as well to assign timeout value. This parameter in the restart block need not change because this only holds the monotonic timestamp at which timeout should occur. And, unsigned long data type should be big enough for this timestamp.

The system call interfaces will be handled in a separate series.

Compat interfaces need not change as timespec64 is an alias to struct timespec on a 64 bit system.

Cc Alexander Viro <[email protected]>
Cc "David S. Miller" <[email protected]>
---
 fs/eventpoll.c       | 12 +++++-----
 fs/select.c          | 67 +++++++++++++++++++++++++++++-----------------------
 include/linux/poll.h | 11 +++++----
 net/socket.c         |  8 ++++---
 4 files changed, 54 insertions(+), 44 deletions(-)
fs/eventpoll.c +6 -6
index 8a74a2a..10db912 100644
@@ -1583,15 +1583,15 @@ static int ep_send_events(struct eventpoll *ep,
 	return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false);
 }
 
-static inline struct timespec ep_set_mstimeout(long ms)
+static inline struct timespec64 ep_set_mstimeout(long ms)
 {
-	struct timespec now, ts = {
+	struct timespec64 now, ts = {
 		.tv_sec = ms / MSEC_PER_SEC,
 		.tv_nsec = NSEC_PER_MSEC * (ms % MSEC_PER_SEC),
 	};
 
-	ktime_get_ts(&now);
-	return timespec_add_safe(now, ts);
+	ktime_get_ts64(&now);
+	return timespec64_add_safe(now, ts);
 }
 
 /**
@@ -1621,11 +1621,11 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
 	ktime_t expires, *to = NULL;
 
 	if (timeout > 0) {
-		struct timespec end_time = ep_set_mstimeout(timeout);
+		struct timespec64 end_time = ep_set_mstimeout(timeout);
 
 		slack = select_estimate_accuracy(&end_time);
 		to = &expires;
-		*to = timespec_to_ktime(end_time);
+		*to = timespec64_to_ktime(end_time);
 	} else if (timeout == 0) {
 		/*
 		 * Avoid the unnecessary trip to the wait queue loop, if the
fs/select.c +37 -30

196 lines not on this page · raw message

include/linux/poll.h +6 -5
index 9fb4f40..37b057b 100644
@@ -96,7 +96,7 @@ extern void poll_initwait(struct poll_wqueues *pwq);
 extern void poll_freewait(struct poll_wqueues *pwq);
 extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
 				 ktime_t *expires, unsigned long slack);
-extern u64 select_estimate_accuracy(struct timespec *tv);
+extern u64 select_estimate_accuracy(struct timespec64 *tv);
 
 
 static inline int poll_schedule(struct poll_wqueues *pwq, int state)
@@ -153,12 +153,13 @@ void zero_fd_set(unsigned long nr, unsigned long *fdset)
 
 #define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1)
 
-extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time);
+extern int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time);
 extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds,
-		       struct timespec *end_time);
+		       struct timespec64 *end_time);
 extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
-			   fd_set __user *exp, struct timespec *end_time);
+			   fd_set __user *exp, struct timespec64 *end_time);
 
-extern int poll_select_set_timeout(struct timespec *to, long sec, long nsec);
+extern int poll_select_set_timeout(struct timespec64 *to, time64_t sec,
+				   long nsec);
 
 #endif /* _LINUX_POLL_H */
net/socket.c +5 -3
index 5dbb0bb..bdfe115 100644
@@ -2171,7 +2171,8 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	struct mmsghdr __user *entry;
 	struct compat_mmsghdr __user *compat_entry;
 	struct msghdr msg_sys;
-	struct timespec end_time;
+	struct timespec64 end_time;
+	struct timespec64 timeout64;
 
 	if (timeout &&
 	    poll_select_set_timeout(&end_time, timeout->tv_sec,
@@ -2223,8 +2224,9 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 			flags |= MSG_DONTWAIT;
 
 		if (timeout) {
-			ktime_get_ts(timeout);
-			*timeout = timespec_sub(end_time, *timeout);
+			ktime_get_ts64(&timeout64);
+			*timeout = timespec64_to_timespec(
+					timespec64_sub(end_time, timeout64));
 			if (timeout->tv_sec < 0) {
 				timeout->tv_sec = timeout->tv_nsec = 0;
 				break;
Signature · 1 line
1.9.1
#5 lore raw

PATCH RESEND 2/3 fs: poll/select/recvmmsg: use timespec64 for timeout events

struct timespec is not y2038 safe.
Even though timespec might be sufficient to represent timeouts, use struct timespec64 here as the plan is to get rid of all timespec reference in the kernel.

The patch transitions the common functions:
poll_select_set_timeout() and select_estimate_accuracy() to use timespec64. And, all the syscalls that use these functions are transitioned in the same patch.

The restart block parameters for poll uses monotonic time. Use timespec64 here as well to assign timeout value. This parameter in the restart block need not change because this only holds the monotonic timestamp at which timeout should occur. And, unsigned long data type should be big enough for this timestamp.

The system call interfaces will be handled in a separate series.

Compat interfaces need not change as timespec64 is an alias to struct timespec on a 64 bit system.

Cc Alexander Viro <[email protected]>
Cc "David S. Miller" <[email protected]>

---
Resending to include John and Thomas on this patch as well. This is to include this patch also in John's tree.
This will let all 3 patches in the series to merged through the same tree.

 fs/eventpoll.c       | 12 +++++-----
 fs/select.c          | 67 +++++++++++++++++++++++++++++-----------------------
 include/linux/poll.h | 11 +++++----
 net/socket.c         |  8 ++++---
 4 files changed, 54 insertions(+), 44 deletions(-)
fs/eventpoll.c +6 -6
index 8a74a2a..10db912 100644
@@ -1583,15 +1583,15 @@ static int ep_send_events(struct eventpoll *ep,
 	return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false);
 }
 
-static inline struct timespec ep_set_mstimeout(long ms)
+static inline struct timespec64 ep_set_mstimeout(long ms)
 {
-	struct timespec now, ts = {
+	struct timespec64 now, ts = {
 		.tv_sec = ms / MSEC_PER_SEC,
 		.tv_nsec = NSEC_PER_MSEC * (ms % MSEC_PER_SEC),
 	};
 
-	ktime_get_ts(&now);
-	return timespec_add_safe(now, ts);
+	ktime_get_ts64(&now);
+	return timespec64_add_safe(now, ts);
 }
 
 /**
@@ -1621,11 +1621,11 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
 	ktime_t expires, *to = NULL;
 
 	if (timeout > 0) {
-		struct timespec end_time = ep_set_mstimeout(timeout);
+		struct timespec64 end_time = ep_set_mstimeout(timeout);
 
 		slack = select_estimate_accuracy(&end_time);
 		to = &expires;
-		*to = timespec_to_ktime(end_time);
+		*to = timespec64_to_ktime(end_time);
 	} else if (timeout == 0) {
 		/*
 		 * Avoid the unnecessary trip to the wait queue loop, if the
fs/select.c +37 -30

196 lines not on this page · raw message

include/linux/poll.h +6 -5
index 9fb4f40..37b057b 100644
@@ -96,7 +96,7 @@ extern void poll_initwait(struct poll_wqueues *pwq);
 extern void poll_freewait(struct poll_wqueues *pwq);
 extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
 				 ktime_t *expires, unsigned long slack);
-extern u64 select_estimate_accuracy(struct timespec *tv);
+extern u64 select_estimate_accuracy(struct timespec64 *tv);
 
 
 static inline int poll_schedule(struct poll_wqueues *pwq, int state)
@@ -153,12 +153,13 @@ void zero_fd_set(unsigned long nr, unsigned long *fdset)
 
 #define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1)
 
-extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time);
+extern int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time);
 extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds,
-		       struct timespec *end_time);
+		       struct timespec64 *end_time);
 extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
-			   fd_set __user *exp, struct timespec *end_time);
+			   fd_set __user *exp, struct timespec64 *end_time);
 
-extern int poll_select_set_timeout(struct timespec *to, long sec, long nsec);
+extern int poll_select_set_timeout(struct timespec64 *to, time64_t sec,
+				   long nsec);
 
 #endif /* _LINUX_POLL_H */
net/socket.c +5 -3
index 5dbb0bb..bdfe115 100644
@@ -2171,7 +2171,8 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	struct mmsghdr __user *entry;
 	struct compat_mmsghdr __user *compat_entry;
 	struct msghdr msg_sys;
-	struct timespec end_time;
+	struct timespec64 end_time;
+	struct timespec64 timeout64;
 
 	if (timeout &&
 	    poll_select_set_timeout(&end_time, timeout->tv_sec,
@@ -2223,8 +2224,9 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 			flags |= MSG_DONTWAIT;
 
 		if (timeout) {
-			ktime_get_ts(timeout);
-			*timeout = timespec_sub(end_time, *timeout);
+			ktime_get_ts64(&timeout64);
+			*timeout = timespec64_to_timespec(
+					timespec64_sub(end_time, timeout64));
 			if (timeout->tv_sec < 0) {
 				timeout->tv_sec = timeout->tv_nsec = 0;
 				break;
Signature · 6 lines
1.9.1

_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038
#6 lore raw

Re: [RESEND PATCH 2/3] fs: poll/select/recvmmsg: use timespec64 for timeout events

Quoted 32 lines · Deepa Dinamani

struct timespec is not y2038 safe.
Even though timespec might be sufficient to represent timeouts, use struct timespec64 here as the plan is to get rid of all timespec reference in the kernel.

The patch transitions the common functions:
poll_select_set_timeout() and select_estimate_accuracy() to use timespec64. And, all the syscalls that use these functions are transitioned in the same patch.

The restart block parameters for poll uses monotonic time. Use timespec64 here as well to assign timeout value. This parameter in the restart block need not change because this only holds the monotonic timestamp at which timeout should occur. And, unsigned long data type should be big enough for this timestamp.

The system call interfaces will be handled in a separate series.

Compat interfaces need not change as timespec64 is an alias to struct timespec on a 64 bit system.

Cc Alexander Viro <[email protected]>
Cc "David S. Miller" <[email protected]>

---
Resending to include John and Thomas on this patch as well. This is to include this patch also in John's tree.
This will let all 3 patches in the series to merged through the same tree.

Quoted 5 lines
 fs/eventpoll.c       | 12 +++++-----
 fs/select.c          | 67 +++++++++++++++++++++++++++++-----------------------
 include/linux/poll.h | 11 +++++----
 net/socket.c         |  8 ++++---
 4 files changed, 54 insertions(+), 44 deletions(-)

So with the other two patches, I'm more comfortable queueing and sending through to Thomas.

But I'm less comfortable making the call on this one. It looks relatively straight forward, but it would be good to have maintainer acks before I add it to my tree.

thanks
-john
_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

Reviewed-by
#7 lore raw

Re: [Y2038] [RESEND PATCH 2/3] fs: poll/select/recvmmsg: use timespec64 for timeout events

Quoted 40 lines · On Wednesday 04 May 2016 13:04:37 John Stultz wrote:
Quoted 32 lines · Deepa Dinamani

struct timespec is not y2038 safe.
Even though timespec might be sufficient to represent timeouts, use struct timespec64 here as the plan is to get rid of all timespec reference in the kernel.

The patch transitions the common functions:
poll_select_set_timeout() and select_estimate_accuracy() to use timespec64. And, all the syscalls that use these functions are transitioned in the same patch.

The restart block parameters for poll uses monotonic time. Use timespec64 here as well to assign timeout value. This parameter in the restart block need not change because this only holds the monotonic timestamp at which timeout should occur. And, unsigned long data type should be big enough for this timestamp.

The system call interfaces will be handled in a separate series.

Compat interfaces need not change as timespec64 is an alias to struct timespec on a 64 bit system.

Cc Alexander Viro <[email protected]>
Cc "David S. Miller" <[email protected]>

---
Resending to include John and Thomas on this patch as well. This is to include this patch also in John's tree.
This will let all 3 patches in the series to merged through the same tree.

Quoted 5 lines
 fs/eventpoll.c       | 12 +++++-----
 fs/select.c          | 67 +++++++++++++++++++++++++++++-----------------------
 include/linux/poll.h | 11 +++++----
 net/socket.c         |  8 ++++---
 4 files changed, 54 insertions(+), 44 deletions(-)
Quoted 2 lines

So with the other two patches, I'm more comfortable queueing and sending through to Thomas.

Note that of course patch 3 depends on patch 2, otherwise it would be a simple rename.

Quoted 3 lines

But I'm less comfortable making the call on this one. It looks relatively straight forward, but it would be good to have maintainer acks before I add it to my tree.

Agreed. Feel free to add my

at least (whoever picks it up). The file hasn't changed much in the past decade, these are all the people who did more than 1 patch for fs/select.c in git history:

7 Al Viro
6 Eliezer Tamir
6 Arjan van de Ven
4 Andrew Morton
3 Linus Torvalds
3 Heiko Carstens
2 Vadim Lobanov
2 Roland McGrath
2 Oleg Nesterov
2 Jiri Slaby
2 Guillaume Knispel
2 Eric Dumazet
2 Dipankar Sarma
2 Alexey Dobriyan

adding a few more to Cc, maybe someone else finds the time to take a second look.

Arnd

#8 lore raw

Re: [Y2038] [RESEND PATCH 2/3] fs: poll/select/recvmmsg: use timespec64 for timeout events

Quoted 9 lines · On Wed, 04 May 2016 23:08:11 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 3 lines

But I'm less comfortable making the call on this one. It looks relatively straight forward, but it would be good to have maintainer acks before I add it to my tree.

Agreed. Feel free to add my

at least (whoever picks it up).

In reply to [1/3] John said

: Looks ok at the first glance. I've queued these up for testing, : however I only got #1 and #3 of the set. Are you hoping these two : patches will go through tip/timers/core or are you looking for acks so : they can go via another tree?

However none of the patches are in linux-next.

John had qualms about [2/3], but it looks like a straightforward substitution in areas which will get plenty of testing

I'll grab the patches for now to get them some external testing.
_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

#9 lore raw

Re: [Y2038] [RESEND PATCH 2/3] fs: poll/select/recvmmsg: use timespec64 for timeout events

Quoted 19 lines · Andrew Morton
Quoted 9 lines · On Wed, 04 May 2016 23:08:11 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 3 lines

But I'm less comfortable making the call on this one. It looks relatively straight forward, but it would be good to have maintainer acks before I add it to my tree.

Agreed. Feel free to add my

at least (whoever picks it up).

In reply to [1/3] John said

: Looks ok at the first glance. I've queued these up for testing, : however I only got #1 and #3 of the set. Are you hoping these two : patches will go through tip/timers/core or are you looking for acks so : they can go via another tree?

Quoted 4 lines

However none of the patches are in linux-next.

John had qualms about [2/3], but it looks like a straightforward substitution in areas which will get plenty of testing

Yea. My main concern is just not stepping on any other maintainers toes.

Quoted 1 line

I'll grab the patches for now to get them some external testing.

I'd be just as happy if the set went through you Andrew.

For the set: Acked-by: John Stultz <[email protected]>

thanks
-john

maintainer Acked-by
#10 lore raw

Re: [Y2038] [RESEND PATCH 2/3] fs: poll/select/recvmmsg: use timespec64 for timeout events

From: John Stultz <[email protected]>
Date: Wed, 4 May 2016 17:01:24 -0700

Quoted 20 lines · Andrew Morton
Quoted 19 lines · On Wed, 04 May 2016 23:08:11 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 10 lines
Quoted 4 lines

But I'm less comfortable making the call on this one. It looks relatively straight forward, but it would be good to have maintainer acks before I add it to my tree.

Agreed. Feel free to add my

at least (whoever picks it up).

In reply to [1/3] John said

: Looks ok at the first glance. I've queued these up for testing, : however I only got #1 and #3 of the set. Are you hoping these two : patches will go through tip/timers/core or are you looking for acks so : they can go via another tree?

Quoted 6 lines
Quoted 4 lines

However none of the patches are in linux-next.

John had qualms about [2/3], but it looks like a straightforward substitution in areas which will get plenty of testing

Yea. My main concern is just not stepping on any other maintainers toes.

The networking changes look fine to me:

_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

#11 lore raw

PATCH 3/3 time: Remove timespec_add_safe()

In reply to Deepa Dinamani

All references to timespec_add_safe() now use timespec64_add_safe().

The plan is to replace struct timespec references with struct timespec64 throughout the kernel as timespec is not y2038 safe.

Drop timespec_add_safe() and use timespec64_add_safe() for all architectures.

Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 include/linux/time64.h | 15 +++++++--------
 kernel/time/time.c     |  4 ----
 2 files changed, 7 insertions(+), 12 deletions(-)
include/linux/time64.h +7 -8
index 1778937..7e5d2fa 100644
@@ -65,7 +65,6 @@ static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec *
 # define timespec64_equal		timespec_equal
 # define timespec64_compare		timespec_compare
 # define set_normalized_timespec64	set_normalized_timespec
-# define timespec64_add_safe		timespec_add_safe
 # define timespec64_add			timespec_add
 # define timespec64_sub			timespec_sub
 # define timespec64_valid		timespec_valid
@@ -134,13 +133,6 @@ static inline int timespec64_compare(const struct timespec64 *lhs, const struct
 
 extern void set_normalized_timespec64(struct timespec64 *ts, time64_t sec, s64 nsec);
 
-/*
- * timespec64_add_safe assumes both values are positive and checks for
- * overflow. It will return TIME64_MAX in case of overflow.
- */
-extern struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
-					 const struct timespec64 rhs);
-
 static inline struct timespec64 timespec64_add(struct timespec64 lhs,
 						struct timespec64 rhs)
 {
@@ -222,4 +214,11 @@ static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns)
 
 #endif
 
+/*
+ * timespec64_add_safe assumes both values are positive and checks for
+ * overflow. It will return TIME64_MAX in case of overflow.
+ */
+extern struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
+					 const struct timespec64 rhs);
+
 #endif /* _LINUX_TIME64_H */
kernel/time/time.c +0 -4
index 558f5fe..703306a 100644
@@ -770,8 +770,6 @@ struct timespec timespec_add_safe(const struct timespec lhs,
 	return res;
 }
 
-#if __BITS_PER_LONG != 64
-
 /*
  * Add two timespec64 values and do a safety check for overflow.
  * It's assumed that both values are valid (>= 0).
@@ -792,5 +790,3 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
 
 	return res;
 }
-
-#endif
Signature · 1 line
1.9.1