Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On 14 January 2015 at 04:42, Thomas Gleixner wrote: > On Tue, 13 Jan 2015, Xunlei Pang wrote: > >> From: Xunlei Pang >> >> As part of addressing "y2038 problem" for in-kernel uses, this >> patch adds safe get_seconds64() using time64_t. >> >> After this patch, get_seconds() is deprecated and all its call sites >> will be fixed using get_seconds64(), after that it can be removed. > > Why another interface? > > We already have ktime_get_real_seconds(). That handles 32bit > correctly, while your new function does not. > > You cannot return a 64bit value unprotected against updates on 32bit, > unless you want to implement a RNG. Yes, ktime_get_real_seconds() should be used instead. Thanks, Xunlei -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On 14 January 2015 at 04:42, Thomas Gleixner t...@linutronix.de wrote: On Tue, 13 Jan 2015, Xunlei Pang wrote: From: Xunlei Pang pang.xun...@linaro.org As part of addressing y2038 problem for in-kernel uses, this patch adds safe get_seconds64() using time64_t. After this patch, get_seconds() is deprecated and all its call sites will be fixed using get_seconds64(), after that it can be removed. Why another interface? We already have ktime_get_real_seconds(). That handles 32bit correctly, while your new function does not. You cannot return a 64bit value unprotected against updates on 32bit, unless you want to implement a RNG. Yes, ktime_get_real_seconds() should be used instead. Thanks, Xunlei -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On Tue, 13 Jan 2015, Xunlei Pang wrote: > From: Xunlei Pang > > As part of addressing "y2038 problem" for in-kernel uses, this > patch adds safe get_seconds64() using time64_t. > > After this patch, get_seconds() is deprecated and all its call sites > will be fixed using get_seconds64(), after that it can be removed. Why another interface? We already have ktime_get_real_seconds(). That handles 32bit correctly, while your new function does not. You cannot return a 64bit value unprotected against updates on 32bit, unless you want to implement a RNG. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On Tuesday 13 January 2015 17:17:44 Alessandro Zummo wrote: > On Tue, 13 Jan 2015 23:44:50 +0800 > Xunlei Pang wrote: > > > -EXPORT_SYMBOL(get_seconds); > > +EXPORT_SYMBOL(get_seconds64); > > Please leave get_seconds untouched > The patch leaves it in place. However, we already have ktime_get_seconds() and ktime_get_real_seconds(). Code that currently uses get_seconds can trivially be converted to the latter. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On Tue, 13 Jan 2015 23:44:50 +0800 Xunlei Pang wrote: > -EXPORT_SYMBOL(get_seconds); > +EXPORT_SYMBOL(get_seconds64); Please leave get_seconds untouched -- Best regards, Alessandro Zummo, Tower Technologies - Torino, Italy http://www.towertech.it -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
From: Xunlei Pang As part of addressing "y2038 problem" for in-kernel uses, this patch adds safe get_seconds64() using time64_t. After this patch, get_seconds() is deprecated and all its call sites will be fixed using get_seconds64(), after that it can be removed. Signed-off-by: Xunlei Pang --- include/linux/timekeeping.h | 10 +- kernel/time/timekeeping.c | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 9b63d13..384d101 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -17,7 +17,7 @@ extern int do_sys_settimeofday(const struct timespec *tv, /* * Kernel time accessors */ -unsigned long get_seconds(void); +extern time64_t get_seconds64(void); struct timespec current_kernel_time(void); /* does not take xtime_lock */ struct timespec __current_kernel_time(void); @@ -34,6 +34,14 @@ extern time64_t ktime_get_real_seconds(void); extern int __getnstimeofday64(struct timespec64 *tv); extern void getnstimeofday64(struct timespec64 *tv); +/** + * Deprecated. Use get_seconds64(). + */ +static inline unsigned long get_seconds(void) +{ + return (unsigned long)get_seconds64(); +} + #if BITS_PER_LONG == 64 /** * Deprecated. Use do_settimeofday64(). diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6a93185..ab021a3 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1678,13 +1678,13 @@ void getboottime(struct timespec *ts) } EXPORT_SYMBOL_GPL(getboottime); -unsigned long get_seconds(void) +time64_t get_seconds64(void) { struct timekeeper *tk = _core.timekeeper; return tk->xtime_sec; } -EXPORT_SYMBOL(get_seconds); +EXPORT_SYMBOL(get_seconds64); struct timespec __current_kernel_time(void) { -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
From: Xunlei Pang pang.xun...@linaro.org As part of addressing y2038 problem for in-kernel uses, this patch adds safe get_seconds64() using time64_t. After this patch, get_seconds() is deprecated and all its call sites will be fixed using get_seconds64(), after that it can be removed. Signed-off-by: Xunlei Pang pang.xun...@linaro.org --- include/linux/timekeeping.h | 10 +- kernel/time/timekeeping.c | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 9b63d13..384d101 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -17,7 +17,7 @@ extern int do_sys_settimeofday(const struct timespec *tv, /* * Kernel time accessors */ -unsigned long get_seconds(void); +extern time64_t get_seconds64(void); struct timespec current_kernel_time(void); /* does not take xtime_lock */ struct timespec __current_kernel_time(void); @@ -34,6 +34,14 @@ extern time64_t ktime_get_real_seconds(void); extern int __getnstimeofday64(struct timespec64 *tv); extern void getnstimeofday64(struct timespec64 *tv); +/** + * Deprecated. Use get_seconds64(). + */ +static inline unsigned long get_seconds(void) +{ + return (unsigned long)get_seconds64(); +} + #if BITS_PER_LONG == 64 /** * Deprecated. Use do_settimeofday64(). diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6a93185..ab021a3 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1678,13 +1678,13 @@ void getboottime(struct timespec *ts) } EXPORT_SYMBOL_GPL(getboottime); -unsigned long get_seconds(void) +time64_t get_seconds64(void) { struct timekeeper *tk = tk_core.timekeeper; return tk-xtime_sec; } -EXPORT_SYMBOL(get_seconds); +EXPORT_SYMBOL(get_seconds64); struct timespec __current_kernel_time(void) { -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On Tue, 13 Jan 2015 23:44:50 +0800 Xunlei Pang xlp...@126.com wrote: -EXPORT_SYMBOL(get_seconds); +EXPORT_SYMBOL(get_seconds64); Please leave get_seconds untouched -- Best regards, Alessandro Zummo, Tower Technologies - Torino, Italy http://www.towertech.it -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On Tue, 13 Jan 2015, Xunlei Pang wrote: From: Xunlei Pang pang.xun...@linaro.org As part of addressing y2038 problem for in-kernel uses, this patch adds safe get_seconds64() using time64_t. After this patch, get_seconds() is deprecated and all its call sites will be fixed using get_seconds64(), after that it can be removed. Why another interface? We already have ktime_get_real_seconds(). That handles 32bit correctly, while your new function does not. You cannot return a 64bit value unprotected against updates on 32bit, unless you want to implement a RNG. Thanks, tglx -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v2 2/9] time: Provide y2106 safe get_seconds() replacement
On Tuesday 13 January 2015 17:17:44 Alessandro Zummo wrote: On Tue, 13 Jan 2015 23:44:50 +0800 Xunlei Pang xlp...@126.com wrote: -EXPORT_SYMBOL(get_seconds); +EXPORT_SYMBOL(get_seconds64); Please leave get_seconds untouched The patch leaves it in place. However, we already have ktime_get_seconds() and ktime_get_real_seconds(). Code that currently uses get_seconds can trivially be converted to the latter. Arnd -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/