First of all, sorry for the overly long series that this turned into.
I'm currently doing a survey of all code using time_t/timeval/timespec
to get an idea of what work needs to be done where, in particular in
terms of user interface changes.
Lustre is by far the most pervasive user of time types and functions,
and I could not even find my way through the code to see what needs
to be done other than actually doing that work.
On most other subsystems, we try to use montonic times where possible
for in-kernel uses. I did not do that here but kept using wall-clock
times, in order to leave the debug output and procfs files untouched.
A follow-up series could convert a lot of the ktime_get_real_*() to
ktime_get_*() to change that if we don't care about the format.
There are a couple of things that I left unchanged:
- Socket timestamps in drivers/staging/lustre/lnet/lnet/lib-socket.c
need to wait for the socket API to be changed first
- inode timestamps need to be changed in VFS, which is a larger work
- The conrpc selftest has a user interface based on timeval that is
hard to change.
All patches are based on staging-testing and built-tested on 32-bit
arm and x86 as well as 64-bit arm.
Arnd Bergmann (37):
staging/lustre: use jiffies for lp_last_query times
staging/lustre: use 64-bit inode timestamps internally
staging/lustre: obd: remove unused data structures
staging/lustre: tracefile: use 64-bit seconds
staging/lustre: use 64-bit timestamps in procfs output
staging/lustre: use time64_t for l_last_activity
staging/lustre: use ktime_t for calculating elapsed time
staging/lustre: change rq_at_index type
staging/lustre: avoid unnecessary timeval conversion
staging/lustre: use 64-bit time LNetCtl()
staging/lustre: use 'long' return type for cfs_duration_sec()
staging/lustre: use jiffies_to_timeval() instead of cfs_duration_usec
staging/lustre: use 64-bit ibn_incarnation computation
staging/lustre: use 64-bit times for lnet_shuffle_seed
staging/lustre: use 64-bit computation in s2dhms()
staging/lustre: use 64-bit timestamps for selftest
staging/lustre: use 64-bit time for pl_recalc
staging/lustre: use 64-bit time for obd eviction
staging/lustre: use 64-bit time for procfs output
staging/lustre: use 64-bit time for adaptive timeout
staging/lustre: use 64-bit llite procfs timestamps
staging/lustre: use 64-bit times for ksnd_connd
staging/lustre: use 64-bit time for ni_last_alive
staging/lustre: use 64-bit time for selftest
staging/lustre: partially use time64_t for capa expiry
staging/lustre: use 64-bit times in ptlrpc_enc_page_pool
staging/lustre: use 64-bit times in debug print
staging/lustre: use 64-bit times in another debug print
staging/lustre: use 64-bit timestamps for mdc
staging/lustre: use 64-bit times for ptlrpc sec expiry
staging/lustre: use 64-bit times for ptlrpc_sec
staging/lustre: use 64-bit times for exp_last_request_time
staging/lustre: use 64-bit times for request times
staging/lustre: remove a bit of dead code
staging/lustre: remove wrappers for timer functions
staging/lustre: remove unused time handling functions
staging/lustre: remove CFS_TIME_T definition
.../lustre/include/linux/libcfs/libcfs_debug.h | 4 +-
.../lustre/include/linux/libcfs/libcfs_prim.h | 13 --
.../lustre/include/linux/libcfs/libcfs_time.h | 49 --------
.../lustre/include/linux/libcfs/linux/linux-time.h | 35 +-----
.../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +-
.../staging/lustre/include/linux/lnet/lib-types.h | 2 +-
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 6 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 +-
drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +-
drivers/staging/lustre/lnet/lnet/config.c | 2 +-
drivers/staging/lustre/lnet/lnet/lib-eq.c | 9 +-
drivers/staging/lustre/lnet/lnet/lib-move.c | 4 +-
drivers/staging/lustre/lnet/lnet/router.c | 10 +-
drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +-
drivers/staging/lustre/lnet/selftest/conctl.c | 2 +-
drivers/staging/lustre/lnet/selftest/conrpc.c | 10 +-
drivers/staging/lustre/lnet/selftest/console.c | 2 +-
drivers/staging/lustre/lnet/selftest/console.h | 2 +-
drivers/staging/lustre/lnet/selftest/framework.c | 5 +-
drivers/staging/lustre/lnet/selftest/ping_test.c | 12 +-
drivers/staging/lustre/lnet/selftest/rpc.c | 9 +-
drivers/staging/lustre/lnet/selftest/selftest.h | 2 +-
drivers/staging/lustre/lnet/selftest/timer.c | 14 +--
drivers/staging/lustre/lnet/selftest/timer.h | 2 +-
drivers/staging/lustre/lustre/include/cl_object.h | 6 +-
.../staging/lustre/lustre/include/lprocfs_status.h | 6 +-
.../lustre/lustre/include/lustre/lustre_idl.h | 1 +
.../staging/lustre/lustre/include/lustre_capa.h | 16 ++-
drivers/staging/lustre/lustre/include/lustre_dlm.h | 6 +-
.../staging/lustre/lustre/include/lustre_export.h | 7 +-
.../staging/lustre/lustre/include/lustre_import.h | 14 +--
drivers/staging/lustre/lustre/include/lustre_net.h | 24 ++--
drivers/staging/lustre/lustre/include/lustre_sec.h | 2 +-
drivers/staging/lustre/lustre/include/obd.h | 97 +--------------
drivers/staging/lustre/lustre/include/obd_class.h | 2 +-
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +-
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 30 ++---
drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 29 ++---
drivers/staging/lustre/lustre/libcfs/debug.c | 4 +-
.../lustre/lustre/libcfs/linux/linux-prim.c | 70 -----------
.../lustre/lustre/libcfs/linux/linux-tracefile.c | 8 +-
drivers/staging/lustre/lustre/libcfs/module.c | 3 -
drivers/staging/lustre/lustre/llite/file.c | 2 +-
.../staging/lustre/lustre/llite/llite_internal.h | 2 +-
drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +-
drivers/staging/lustre/lustre/llite/lproc_llite.c | 24 ++--
drivers/staging/lustre/lustre/llite/super25.c | 6 +-
drivers/staging/lustre/lustre/llite/vvp_io.c | 4 +-
drivers/staging/lustre/lustre/llite/vvp_object.c | 12 +-
drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +-
drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +-
drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +-
drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +-
drivers/staging/lustre/lustre/obdclass/genops.c | 6 +-
drivers/staging/lustre/lustre/obdclass/llog.c | 2 +-
.../lustre/lustre/obdclass/lprocfs_status.c | 27 ++---
.../lustre/lustre/obdclass/lustre_handles.c | 6 +-
.../staging/lustre/lustre/obdclass/obd_config.c | 13 +-
.../staging/lustre/lustre/obdecho/echo_client.c | 4 +-
drivers/staging/lustre/lustre/osc/lproc_osc.c | 16 +--
drivers/staging/lustre/lustre/osc/osc_io.c | 6 +-
drivers/staging/lustre/lustre/osc/osc_request.c | 4 +-
drivers/staging/lustre/lustre/ptlrpc/client.c | 48 ++++----
drivers/staging/lustre/lustre/ptlrpc/events.c | 8 +-
drivers/staging/lustre/lustre/ptlrpc/import.c | 14 +--
.../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 16 +--
drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 10 +-
.../staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +-
drivers/staging/lustre/lustre/ptlrpc/pinger.c | 29 +++--
drivers/staging/lustre/lustre/ptlrpc/sec.c | 28 ++---
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 29 +++--
drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +-
drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +-
drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 4 +-
drivers/staging/lustre/lustre/ptlrpc/service.c | 135 +++++++++++----------
77 files changed, 380 insertions(+), 652 deletions(-)
--
2.1.0.rc2
Dear customer,
Your payment has been processed and your credit card has been charged.
Please print your e-ticket attached to this email.
Order details and e-ticket information:
FLIGHT NUMBER - ET599232
DATE & TIME - Sep 30 2015, 21:50
DEPARTING - Long Beach
TOTAL PRICE - $ 350.00
Thank you for flying with America Airlines.
- what is the time_t/timeval/timespec type used for in this driver
the timeval in dummy_g_get_frame is used for getting frame number in every
ms.
- is this broken in 2038 or not
No. The millisecond of the last second will be normal if tv_sec is
overflowed. But for consistency purpose, and avoiding further risks, I
have replaced timeval with timespec64.
- does the driver use monotonic or real time
Real time. But only microsecond part is used.
- if it uses real time, should it use monotonic time instead
Monotonic time will be ok if it can meet the precise requirement(us).
Signed-off-by: WEN Pingbo <pingbo.wen(a)linaro.org>
Cc: Y2038 <y2038(a)lists.linaro.org>
---
drivers/usb/gadget/udc/dummy_hcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 1379ad4..7be721dad 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -833,10 +833,10 @@ static const struct usb_ep_ops dummy_ep_ops = {
/* there are both host and device side versions of this call ... */
static int dummy_g_get_frame(struct usb_gadget *_gadget)
{
- struct timeval tv;
+ struct timespec64 tv;
- do_gettimeofday(&tv);
- return tv.tv_usec / 1000;
+ getnstimeofday64(&tv);
+ return tv.tv_nsec / 1000000L;
}
static int dummy_wakeup(struct usb_gadget *_gadget)
--
1.9.1
Replaces time_t type and get_seconds function which are not y2038 safe
on 32-bit systems. Function ktime_get_seconds use monotonic instead of
real time and therefore will not cause overflow.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic(a)gmail.com>
---
Changes in v2:
- change put_time to unsigned long type
- change commit message
net/rxrpc/ar-connection.c | 4 ++--
net/rxrpc/ar-internal.h | 4 ++--
net/rxrpc/ar-transport.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
index 6631f4f..692b3e6 100644
--- a/net/rxrpc/ar-connection.c
+++ b/net/rxrpc/ar-connection.c
@@ -808,7 +808,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
ASSERTCMP(atomic_read(&conn->usage), >, 0);
- conn->put_time = get_seconds();
+ conn->put_time = ktime_get_seconds();
if (atomic_dec_and_test(&conn->usage)) {
_debug("zombie");
rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -852,7 +852,7 @@ static void rxrpc_connection_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
write_lock_bh(&rxrpc_connection_lock);
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index aef1bd2..2934a73 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -208,7 +208,7 @@ struct rxrpc_transport {
struct rb_root server_conns; /* server connections on this transport */
struct list_head link; /* link in master session list */
struct sk_buff_head error_queue; /* error packets awaiting processing */
- time_t put_time; /* time at which to reap */
+ unsigned long put_time; /* time at which to reap */
spinlock_t client_lock; /* client connection allocation lock */
rwlock_t conn_lock; /* lock for active/dead connections */
atomic_t usage;
@@ -256,7 +256,7 @@ struct rxrpc_connection {
struct rxrpc_crypt csum_iv; /* packet checksum base */
unsigned long events;
#define RXRPC_CONN_CHALLENGE 0 /* send challenge packet */
- time_t put_time; /* time at which to reap */
+ unsigned long put_time; /* time at which to reap */
rwlock_t lock; /* access lock */
spinlock_t state_lock; /* state-change lock */
atomic_t usage;
diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
index 1976dec..9946467 100644
--- a/net/rxrpc/ar-transport.c
+++ b/net/rxrpc/ar-transport.c
@@ -189,7 +189,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)
ASSERTCMP(atomic_read(&trans->usage), >, 0);
- trans->put_time = get_seconds();
+ trans->put_time = ktime_get_seconds();
if (unlikely(atomic_dec_and_test(&trans->usage))) {
_debug("zombie");
/* let the reaper determine the timeout to avoid a race with
@@ -226,7 +226,7 @@ static void rxrpc_transport_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
/* extract all the transports that have been dead too long */
--
1.9.1
Replace get_seconds() which is not y2038 safe on 32bit systems.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic(a)gmail.com>
---
This patch is split out of the previous patch
[PATCH v3] net: rxrpc: Replace time_t with time64_t.
The rest of the changes is yet to be sent as separate patchset.
net/rxrpc/ar-connection.c | 4 ++--
net/rxrpc/ar-transport.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
index 6631f4f..692b3e6 100644
--- a/net/rxrpc/ar-connection.c
+++ b/net/rxrpc/ar-connection.c
@@ -808,7 +808,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
ASSERTCMP(atomic_read(&conn->usage), >, 0);
- conn->put_time = get_seconds();
+ conn->put_time = ktime_get_seconds();
if (atomic_dec_and_test(&conn->usage)) {
_debug("zombie");
rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -852,7 +852,7 @@ static void rxrpc_connection_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
write_lock_bh(&rxrpc_connection_lock);
diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
index 1976dec..9946467 100644
--- a/net/rxrpc/ar-transport.c
+++ b/net/rxrpc/ar-transport.c
@@ -189,7 +189,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)
ASSERTCMP(atomic_read(&trans->usage), >, 0);
- trans->put_time = get_seconds();
+ trans->put_time = ktime_get_seconds();
if (unlikely(atomic_dec_and_test(&trans->usage))) {
_debug("zombie");
/* let the reaper determine the timeout to avoid a race with
@@ -226,7 +226,7 @@ static void rxrpc_transport_reaper(struct work_struct *work)
_enter("");
- now = get_seconds();
+ now = ktime_get_seconds();
earliest = ULONG_MAX;
/* extract all the transports that have been dead too long */
--
1.9.1