staging: lustre: lnet: resolve time handling issues
cover staging: lustre: lnet: resolve time handling issues
The migration of lustre to 64 bit time handling exposed various bugs which have lead to problems like routers no longer functioning with the upstream client. This is due to the complex handling of time by lustre with seconds time units and jiffies. Add in the fact that jiffies can vary from node to node and you can encounter corner case issues in a large node deployment. The solution to resolve this was to migrate as much as possible to time64_t when all you needed was seconds percision and ktime_t if better percision was required. With these changes it is reduced down to using jiffies only for schedule_timeout calls.
James Simmons (8):
staging: lustre: lnet: simplify lnet_eq_wait_locked
staging: lustre: o2iblnd: use ktime_get_real_ns for ibn_incarnation
staging: lustre: ksocklnd: use ktime_get_real_ns for ksnn_incarnation
staging: lustre: ksocklnd: move remaining time handling to 64 bits
staging: lustre: lnet: use ktime_get_real_ns for cookie creation
staging: lustre: lnet: move ping and delay injection to time64_t
staging: lustre: ko2iblnd: remove remaining jiffy use
staging: lustre: selftest: fix time reporting
drivers/staging/lustre/include/linux/lnet/api.h | 2 +- .../staging/lustre/include/linux/lnet/lib-lnet.h | 8 +- .../staging/lustre/include/linux/lnet/lib-types.h | 13 ++- .../lustre/include/uapi/linux/lnet/lnet-types.h | 2 - .../lustre/include/uapi/linux/lnet/lnetst.h | 2 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 53 +++++----- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 28 ++--- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 36 +++---- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 44 ++++---- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 22 ++-- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 117 ++++++++++----------- drivers/staging/lustre/lnet/lnet/api-ni.c | 54 ++++++---- drivers/staging/lustre/lnet/lnet/lib-eq.c | 26 ++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 24 ++--- drivers/staging/lustre/lnet/lnet/net_fault.c | 72 ++++++------- drivers/staging/lustre/lnet/lnet/peer.c | 2 +- drivers/staging/lustre/lnet/lnet/router.c | 35 +++--- drivers/staging/lustre/lnet/lnet/router_proc.c | 27 +++-- drivers/staging/lustre/lnet/selftest/conrpc.c | 39 +++---- drivers/staging/lustre/lnet/selftest/conrpc.h | 2 +- drivers/staging/lustre/lnet/selftest/console.c | 4 +- drivers/staging/lustre/lnet/selftest/console.h | 2 +- drivers/staging/lustre/lnet/selftest/framework.c | 4 +- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- drivers/staging/lustre/lnet/selftest/timer.c | 8 +- 25 files changed, 304 insertions(+), 324 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/8 staging: lustre: lnet: simplify lnet_eq_wait_locked
We can simplify the code by taking advantage of the behavior of schedule_timeout_interruptible(). Instead of testing if tms is less than zero we can pass in a signed long that schedule_timeout_interruptible is expecting and for the case of no timeout we can pass in MAX_SCHEDULE_TIMEOUT.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/23147
--- drivers/staging/lustre/include/linux/lnet/api.h | 2 +- .../lustre/include/uapi/linux/lnet/lnet-types.h | 2 -- drivers/staging/lustre/lnet/lnet/api-ni.c | 38 ++++++++++++++-------- drivers/staging/lustre/lnet/lnet/lib-eq.c | 26 +++++---------- 4 files changed, 33 insertions(+), 35 deletions(-)
drivers/staging/lustre/include/linux/lnet/api.h +1 -1
@@ -168,7 +168,7 @@ int LNetEQAlloc(unsigned int count_in,int LNetEQPoll (struct lnet_handle_eq *eventqs_in,int neq_in, -int timeout_ms, +signed long timeout,int interruptible,struct lnet_event *event_out,int *which_eq_out);
drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +0 -2
@@ -77,8 +77,6 @@#define LNET_PID_USERFLAG 0x80000000/* set in userspace peers */ #define LNET_PID_LUSTRE 12345 -#define LNET_TIME_FOREVER (-1) -/* how an LNET NID encodes net:address */ /** extract the address part of an lnet_nid_t */
drivers/staging/lustre/lnet/lnet/api-ni.c +24 -14
@@ -59,7 +59,7 @@module_param (rnet_htable_size, int,0444 );MODULE_PARM_DESC (rnet_htable_size,"size of remote network hash table" ); -static int lnet_ping (struct lnet_process_id id,int timeout_ms, +static int lnet_ping (struct lnet_process_id id,signed long timeout,struct lnet_process_id __user *ids,int n_ids); static char *
@@ -2052,17 +2052,29 @@ void lnet_lib_exit(void)case IOC_LIBCFS_LNET_FAULT :return lnet_fault_ctl (data->ioc_flags, data); -case IOC_LIBCFS_PING : +case IOC_LIBCFS_PING : { +signed long timeout; + id.nid = data->ioc_nid; id.pid = data->ioc_u32[0 ]; - rc =lnet_ping (id, data->ioc_u32[1 ],/* timeout */ - data->ioc_pbuf1, + +/* Don't block longer than 2 minutes */ +if (data->ioc_u32[1 ] >120 *MSEC_PER_SEC ) +return -EINVAL ; + +/* If timestamp is negative then disable timeout */ +if ((s32 )data->ioc_u32[1 ] <0 ) + timeout =MAX_SCHEDULE_TIMEOUT ; +else + timeout =msecs_to_jiffies (data->ioc_u32[1 ]); + + rc =lnet_ping (id, timeout, data->ioc_pbuf1, data->ioc_plen1 /sizeof (struct lnet_process_id ));if (rc <0 )return rc; data->ioc_count = rc;return 0 ; - + }default : ni =lnet_net2ni (data->ioc_net);if (!ni)
@@ -2126,7 +2138,7 @@ void LNetDebugPeer(struct lnet_process_id id) }EXPORT_SYMBOL (LNetGetId); -static int lnet_ping (struct lnet_process_id id,int timeout_ms, +static int lnet_ping (struct lnet_process_id id,signed long timeout,struct lnet_process_id __user *ids,int n_ids) {struct lnet_handle_eq eqh;
@@ -2136,7 +2148,7 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,int which;int unlinked =0 ;int replied =0 ; -const int a_long_time =60000 ;/* mS */ +const signed long a_long_time =msecs_to_jiffies (60 *MSEC_PER_SEC );int infosz;struct lnet_ping_info *info;struct lnet_process_id tmpid;
@@ -2147,10 +2159,8 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms, infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]); -if (n_ids <=0 || - id.nid ==LNET_NID_ANY || - timeout_ms >500000 ||/* arbitrary limit! */ - n_ids >20 )/* arbitrary limit! */ +/* n_ids limit is arbitrary */ +if (n_ids <=0 || n_ids >20 || id.nid ==LNET_NID_ANY )return -EINVAL ;if (id.pid ==LNET_PID_ANY )
@@ -2194,13 +2204,13 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,/* NB must wait for the UNLINK event below... */ unlinked =1 ; - timeout_ms = a_long_time; + timeout = a_long_time; } do { /* MUST block for unlink to complete */ - rc2 = LNetEQPoll(&eqh, 1, timeout_ms, !unlinked, + rc2 = LNetEQPoll(&eqh, 1, timeout, !unlinked, &event, &which); CDEBUG(D_NET, "poll %d(%d %d)%s\n", rc2,
@@ -2222,7 +2232,7 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,LNetMDUnlink (mdh);/* No assertion (racing with network) */ unlinked =1 ; - timeout_ms = a_long_time; + timeout = a_long_time; }else if (!rc2) {/* timed out waiting for unlink */ CWARN("ping %s: late network completion\n",
drivers/staging/lustre/lnet/lnet/lib-eq.c +8 -18
@@ -308,13 +308,12 @@*/ static int -lnet_eq_wait_locked (int *timeout_ms,long state) +lnet_eq_wait_locked (signed long *timeout,long state) __must_hold(&the_lnet.ln_eq_wait_lock) { -int tms = *timeout_ms; +signed long tms = *timeout;int wait;wait_queue_entry_t wl; -unsigned long now;if (!tms)return -ENXIO ;/* don't want to wait and no new event */
@@ -325,18 +324,9 @@lnet_eq_wait_unlock (); -if (tms <0 ) { -schedule (); - }else { - now = jiffies; -schedule_timeout (msecs_to_jiffies (tms)); - tms -=jiffies_to_msecs (jiffies - now); -if (tms <0 )/* no more wait but may have new event */ - tms =0 ; - } - + tms =schedule_timeout_interruptible (tms); wait = tms;/* might need to call here again */ - *timeout_ms = tms; + *timeout = tms;lnet_eq_wait_lock ();remove_wait_queue (&the_lnet.ln_eq_waitq, &wl);
@@ -356,8 +346,8 @@* fixed period, or block indefinitely. * * \param eventqs,neq An array of EQ handles, and size of the array. -* \param timeout_ms Time in milliseconds to wait for an event to occur on -* one of the EQs. The constant LNET_TIME_FOREVER can be used to indicate an +* \param timeout Time in jiffies to wait for an event to occur on +* one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD * \param event,which On successful return (1 or -EOVERFLOW), \a event will
@@ -372,7 +362,7 @@* \retval -ENOENT If there's an invalid handle in \a eventqs. */ int -LNetEQPoll (struct lnet_handle_eq *eventqs,int neq,int timeout_ms, +LNetEQPoll (struct lnet_handle_eq *eventqs,int neq,signed long timeout,int interruptible,struct lnet_event *event,int *which) {
@@ -414,7 +404,7 @@* 0 : don't want to wait anymore, but might have new event * so need to call dequeue again */ - wait =lnet_eq_wait_locked (&timeout_ms, + wait =lnet_eq_wait_locked (&timeout, interruptible ?TASK_INTERRUPTIBLE :TASK_NOLOAD );if (wait <0 )/* no new event */
Signature · 1 line
1.8.3.1
PATCH 1/8 staging: lustre: lnet: simplify lnet_eq_wait_locked
Quoted 103 lines · James Simmons
We can simplify the code by taking advantage of the behavior of
schedule_timeout_interruptible(). Instead of testing if tms is less than zero we can pass in a signed long thatschedule_timeout_interruptibleis expecting and for the case of no timeout we can pass inMAX_SCHEDULE_TIMEOUT.Signed-off-by James Simmons <[email protected]>WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/23147Reviewed-by Doug Oucharek <[email protected]>Reviewed-by Dmitry Eremin <[email protected]>Reviewed-by Oleg Drokin <[email protected]>Signed-off-by James Simmons <[email protected]>--- drivers/staging/lustre/include/linux/lnet/api.h | 2 +- .../lustre/include/uapi/linux/lnet/lnet-types.h | 2 -- drivers/staging/lustre/lnet/lnet/api-ni.c | 38 ++++++++++++++-------- drivers/staging/lustre/lnet/lnet/lib-eq.c | 26 +++++---------- 4 files changed, 33 insertions(+), 35 deletions(-)drivers/staging/lustre/include/linux/lnet/api.h +1
-1@@ -168,7 +168,7 @@ int LNetEQAlloc(unsigned int count_in,int LNetEQPoll (struct lnet_handle_eq *eventqs_in,int neq_in, -int timeout_ms, +signed long timeout,int interruptible,struct lnet_event *event_out,int *which_eq_out);drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +0
-2@@ -77,8 +77,6 @@#define LNET_PID_USERFLAG 0x80000000/* set in userspace peers */ #define LNET_PID_LUSTRE 12345 -#define LNET_TIME_FOREVER (-1) -/* how an LNET NID encodes net:address */ /** extract the address part of an lnet_nid_t */ drivers/staging/lustre/lnet/lnet/api-ni.c +18
-6@@ -59,7 +59,7 @@module_param (rnet_htable_size, int,0444 );MODULE_PARM_DESC (rnet_htable_size,"size of remote network hash table" ); -static int lnet_ping (struct lnet_process_id id,int timeout_ms, +static int lnet_ping (struct lnet_process_id id,signed long timeout,struct lnet_process_id __user *ids,int n_ids); static char *@@ -2052,17 +2052,29 @@ void lnet_lib_exit(void)case IOC_LIBCFS_LNET_FAULT :return lnet_fault_ctl (data->ioc_flags, data); -case IOC_LIBCFS_PING : +case IOC_LIBCFS_PING : { +signed long timeout; + id.nid = data->ioc_nid; id.pid = data->ioc_u32[0 ]; - rc =lnet_ping (id, data->ioc_u32[1 ],/* timeout */ - data->ioc_pbuf1, + +/* Don't block longer than 2 minutes */ +if (data->ioc_u32[1 ] >120 *MSEC_PER_SEC ) +return -EINVAL ; + +/* If timestamp is negative then disable timeout */ +if ((s32 )data->ioc_u32[1 ] <0 ) + timeout =MAX_SCHEDULE_TIMEOUT ; +else + timeout =msecs_to_jiffies (data->ioc_u32[1 ]); + + rc =lnet_ping (id, timeout, data->ioc_pbuf1, data->ioc_plen1 /sizeof (struct lnet_process_id ));if (rc <0 )return rc; data->ioc_count = rc;return 0 ; - + }default : ni =lnet_net2ni (data->ioc_net);if (!ni)@@ -2126,7 +2138,7 @@ void LNetDebugPeer(struct lnet_process_id id) }EXPORT_SYMBOL (LNetGetId); -static int lnet_ping (struct lnet_process_id id,int timeout_ms, +static int lnet_ping (struct lnet_process_id id,signed long timeout,struct lnet_process_id __user *ids,int n_ids) {struct lnet_handle_eq eqh;
drivers/staging/lustre/lnet/lnet/api-ni.c static int lnet_ping(struct lnet_process_id id, int timeout_ms, · line 2151
Quoted 5 lines
drivers/staging/lustre/lnet/lnet/api-ni.c +1
-1@@ -2136,7 +2148,7 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,int which;int unlinked =0 ;int replied =0 ; -const int a_long_time =60000 ;/* mS */ +const signed long a_long_time =msecs_to_jiffies (60 *MSEC_PER_SEC );
I've changed this to
a_long_toime = 60*HZ;
as that is the more common pattern in the kernel.
Quoted 66 lines
drivers/staging/lustre/lnet/lnet/api-ni.c +5
-7int infosz;struct lnet_ping_info *info;struct lnet_process_id tmpid;@@ -2147,10 +2159,8 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms, infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]); -if (n_ids <=0 || - id.nid ==LNET_NID_ANY || - timeout_ms >500000 ||/* arbitrary limit! */ - n_ids >20 )/* arbitrary limit! */ +/* n_ids limit is arbitrary */ +if (n_ids <=0 || n_ids >20 || id.nid ==LNET_NID_ANY )return -EINVAL ;if (id.pid ==LNET_PID_ANY )@@ -2194,13 +2204,13 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,/* NB must wait for the UNLINK event below... */ unlinked =1 ; - timeout_ms = a_long_time; + timeout = a_long_time; } do { /* MUST block for unlink to complete */ - rc2 = LNetEQPoll(&eqh, 1, timeout_ms, !unlinked, + rc2 = LNetEQPoll(&eqh, 1, timeout, !unlinked, &event, &which); CDEBUG(D_NET, "poll %d(%d %d)%s\n", rc2,@@ -2222,7 +2232,7 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,LNetMDUnlink (mdh);/* No assertion (racing with network) */ unlinked =1 ; - timeout_ms = a_long_time; + timeout = a_long_time; }else if (!rc2) {/* timed out waiting for unlink */ CWARN("ping %s: late network completion\n",drivers/staging/lustre/lnet/lnet/lib-eq.c +2
-4@@ -308,13 +308,12 @@*/ static int -lnet_eq_wait_locked (int *timeout_ms,long state) +lnet_eq_wait_locked (signed long *timeout,long state) __must_hold(&the_lnet.ln_eq_wait_lock) { -int tms = *timeout_ms; +signed long tms = *timeout;int wait;wait_queue_entry_t wl; -unsigned long now;if (!tms)return -ENXIO ;/* don't want to wait and no new event */ @@ -325,18 +324,9 @@lnet_eq_wait_unlock (); -if (tms <0 ) {
drivers/staging/lustre/lnet/lnet/lib-eq.c line 327
Quoted 10 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c +1
-9-schedule (); - }else { - now = jiffies; -schedule_timeout (msecs_to_jiffies (tms)); - tms -=jiffies_to_msecs (jiffies - now); -if (tms <0 )/* no more wait but may have new event */ - tms =0 ; - } - + tms =schedule_timeout_interruptible (tms);
I've changed this to schedule_timeout().
The task state has already been set (to INTERRUPTIBLE or NOLOAD) and we don't want to set it again.
Thanks,
NeilBrown
Quoted 37 lines
drivers/staging/lustre/lnet/lnet/lib-eq.c +5
-5wait = tms;/* might need to call here again */ - *timeout_ms = tms; + *timeout = tms;lnet_eq_wait_lock ();remove_wait_queue (&the_lnet.ln_eq_waitq, &wl);@@ -356,8 +346,8 @@* fixed period, or block indefinitely. * * \param eventqs,neq An array of EQ handles, and size of the array. -* \param timeout_ms Time in milliseconds to wait for an event to occur on -* one of the EQs. The constant LNET_TIME_FOREVER can be used to indicate an +* \param timeout Time in jiffies to wait for an event to occur on +* one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an * infinite timeout. * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD * \param event,which On successful return (1 or -EOVERFLOW), \a event will @@ -372,7 +362,7 @@* \retval -ENOENT If there's an invalid handle in \a eventqs. */ int -LNetEQPoll (struct lnet_handle_eq *eventqs,int neq,int timeout_ms, +LNetEQPoll (struct lnet_handle_eq *eventqs,int neq,signed long timeout,int interruptible,struct lnet_event *event,int *which) {@@ -414,7 +404,7 @@* 0 : don't want to wait anymore, but might have new event * so need to call dequeue again */ - wait =lnet_eq_wait_locked (&timeout_ms, + wait =lnet_eq_wait_locked (&timeout, interruptible ?TASK_INTERRUPTIBLE :TASK_NOLOAD );if (wait <0 )/* no new event */ Signature · 1 line
1.8.3.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180625/42a1c406/attachment.sig>
PATCH 2/8 staging: lustre: o2iblnd: use ktime_get_real_ns for ibn_incarnation
In reply to James SimmonsInstead of getting the real time using ktime_get_real_ts64() and turning it into usecs we can simplify the code and call ktime_get_real_ns() instead.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/23267
--- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +1 -4
@@ -2822,7 +2822,6 @@ static int kiblnd_startup(struct lnet_ni *ni)char *ifname;struct kib_dev *ibdev =NULL ;struct kib_net *net; -struct timespec64 tv;unsigned long flags;int rc;int newdev;
@@ -2840,9 +2839,7 @@ static int kiblnd_startup(struct lnet_ni *ni)if (!net) goto net_failed; -ktime_get_real_ts64 (&tv); - net->ibn_incarnation = tv.tv_sec *USEC_PER_SEC + - tv.tv_nsec /NSEC_PER_USEC ; + net->ibn_incarnation =ktime_get_real_ns () /NSEC_PER_USEC ; rc =kiblnd_tunables_setup (ni);if (rc)
Signature · 1 line
1.8.3.1
PATCH 3/8 staging: lustre: ksocklnd: use ktime_get_real_ns for ksnn_incarnation
In reply to James SimmonsThe value generated for ksnn_incarnation is used as a unique identifier. Their exist a small chance that two nodes could end up with the same value but if we use ktime_get_real_ns() instead the change is even less so.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/25690
--- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +1 -10
@@ -2369,15 +2369,6 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)module_put (THIS_MODULE ); } -static __u64 -ksocknal_new_incarnation (void ) -{ -/* The incarnation number is the time this module loaded and it -* identifies this particular instance of the socknal. -*/ -return ktime_get_ns (); -} -static int ksocknal_base_startup (void ) {
@@ -2810,7 +2801,7 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id) goto fail_0;spin_lock_init (&net->ksnn_lock); - net->ksnn_incarnation =ksocknal_new_incarnation (); + net->ksnn_incarnation =ktime_get_real_ns (); ni->ni_data = net; ni->ni_peertimeout = *ksocknal_tunables.ksnd_peertimeout; ni->ni_maxtxcredits = *ksocknal_tunables.ksnd_credits;
Signature · 1 line
1.8.3.1
PATCH 4/8 staging: lustre: ksocklnd: move remaining time handling to 64 bits
In reply to James SimmonsExamination of the ksocklnd time handle revealed that the code only requires second level precision. Since this is the case we can move away from using jiffies to time64_t. This allows us to be independent of the HZ settings in addition to making it clear what is time handling, using time64_t verses unsigned long.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9397
Reviewed-on: https://review.whamcloud.com/26813
--- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 33 +++--- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 20 ++-- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 117 ++++++++++----------- 3 files changed, 83 insertions(+), 87 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +17 -16
@@ -1276,7 +1276,7 @@ struct ksock_peer * } conn->ksnc_peer = peer;/* conn takes my ref on peer */ - peer->ksnp_last_alive = jiffies; + peer->ksnp_last_alive =ktime_get_seconds (); peer->ksnp_send_keepalive =0 ; peer->ksnp_error =0 ;
@@ -1284,10 +1284,11 @@ struct ksock_peer * sched->kss_nconns++; conn->ksnc_scheduler = sched; - conn->ksnc_tx_last_post = jiffies; + conn->ksnc_tx_last_post =ktime_get_seconds ();/* Set the deadline for the outgoing HELLO to drain */ conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued; - conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout *HZ ; + conn->ksnc_tx_deadline =ktime_get_seconds () + + *ksocknal_tunables.ksnd_timeout;mb ();/* order with adding to peer's conn list */ list_add (&conn->ksnc_list, &peer->ksnp_conns);
@@ -1515,7 +1516,7 @@ struct ksock_peer * ksocknal_peer_failed(struct ksock_peer *peer) {int notify =0 ; -unsigned long last_alive =0 ; +time64_t last_alive =0 ;/* * There has been a connection failure or comms error; but I'll only
@@ -1536,7 +1537,7 @@ struct ksock_peer *if (notify)lnet_notify (peer->ksnp_ni, peer->ksnp_id.nid,0 , - last_alive); + last_alive *HZ ); }void
@@ -1660,7 +1661,7 @@ struct ksock_peer *void ksocknal_destroy_conn (struct ksock_conn *conn) { -unsigned long last_rcv; +time64_t last_rcv;/* Final coup-de-grace of the reaper */ CDEBUG (D_NET ,"connection %p\n" , conn);
@@ -1677,12 +1678,12 @@ struct ksock_peer *switch (conn->ksnc_rx_state) {case SOCKNAL_RX_LNET_PAYLOAD : last_rcv = conn->ksnc_rx_deadline - - *ksocknal_tunables.ksnd_timeout *HZ ; -CERROR ("Completing partial receive from %s[%d], ip %pI4h:%d, with error, wanted: %zd, left: %d, last alive is %ld secs ago\n" , + *ksocknal_tunables.ksnd_timeout; +CERROR ("Completing partial receive from %s[%d], ip %pI4h:%d, with error, wanted: %zd, left: %d, last alive is %lld secs ago\n" ,libcfs_id2str (conn->ksnc_peer->ksnp_id), conn->ksnc_type, &conn->ksnc_ipaddr, conn->ksnc_port,iov_iter_count (&conn->ksnc_rx_to), conn->ksnc_rx_nob_left, - (jiffies - last_rcv) /HZ ); +ktime_get_seconds () - last_rcv);lnet_finalize (conn->ksnc_peer->ksnp_ni, conn->ksnc_cookie, -EIO );break ;
@@ -1830,8 +1831,8 @@ struct ksock_peer * ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when) { int connect = 1; -unsigned long last_alive =0 ; -unsigned long now = jiffies; +time64_t last_alive =0 ; +time64_t now =ktime_get_seconds ();struct ksock_peer *peer =NULL ;rwlock_t *glock = &ksocknal_data.ksnd_global_lock; struct lnet_process_id id = {
@@ -1851,8 +1852,8 @@ struct ksock_peer *if (bufnob < conn->ksnc_tx_bufnob) {/* something got ACKed */ - conn->ksnc_tx_deadline = - jiffies + *ksocknal_tunables.ksnd_timeout *HZ ; + conn->ksnc_tx_deadline =ktime_get_seconds () + + *ksocknal_tunables.ksnd_timeout; peer->ksnp_last_alive = now; conn->ksnc_tx_bufnob = bufnob; }
@@ -1866,11 +1867,11 @@ struct ksock_peer *read_unlock (glock);if (last_alive) - *when = last_alive; + *when = last_alive *HZ ; -CDEBUG (D_NET ,"Peer %s %p, alive %ld secs ago, connect %d\n" , +CDEBUG (D_NET ,"Peer %s %p, alive %lld secs ago, connect %d\n" ,libcfs_nid2str (nid), peer, - last_alive ? (now - last_alive) /HZ :-1 , + last_alive ? now - last_alive :-1 , connect);if (!connect)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +10 -10
@@ -57,7 +57,7 @@#define SOCKNAL_PEER_HASH_SIZE 101/* # peer lists */ #define SOCKNAL_RESCHED 100/* # scheduler loops before reschedule */ #define SOCKNAL_INSANITY_RECONN 5000/* connd is trying on reconn infinitely */ -#define SOCKNAL_ENOMEM_RETRY 1/* jiffies between retries */ +#define SOCKNAL_ENOMEM_RETRY 1/* seconds between retries */ #define SOCKNAL_SINGLE_FRAG_TX 0/* disable multi-fragment sends */ #define SOCKNAL_SINGLE_FRAG_RX 0/* disable multi-fragment receives */
@@ -210,7 +210,7 @@ struct ksock_nal_data {* reaper_lock */ wait_queue_head_t ksnd_reaper_waitq;/* reaper sleeps here */ -unsigned long ksnd_reaper_waketime;/* when reaper will wake +time64_t ksnd_reaper_waketime;/* when reaper will wake */ spinlock_t ksnd_reaper_lock;/* serialise */
@@ -285,7 +285,7 @@ struct ksock_tx { /* transmit packet */struct ksock_conn *tx_conn;/* owning conn */ struct lnet_msg *tx_lnetmsg;/* lnet message for lnet_finalize() */ -unsigned long tx_deadline;/* when (in jiffies) tx times out */ +time64_t tx_deadline;/* when (in secs) tx times out */ struct ksock_msg tx_msg;/* socklnd message buffer */ int tx_desc_size;/* size of this descriptor */ union {
@@ -340,7 +340,7 @@ struct ksock_conn {struct list_head ksnc_rx_list;/* where I enq waiting input or a * forwarding descriptor */ -unsigned long ksnc_rx_deadline;/* when (in jiffies) receive times +time64_t ksnc_rx_deadline;/* when (in secs) receive times * out */ __u8 ksnc_rx_started;/* started receiving a message */
@@ -370,13 +370,13 @@ struct ksock_conn {struct ksock_tx *ksnc_tx_carrier;/* next TX that can carry a LNet * message or ZC-ACK */ -unsigned long ksnc_tx_deadline;/* when (in jiffies) tx times out +time64_t ksnc_tx_deadline;/* when (in secs) tx times out */ int ksnc_tx_bufnob;/* send buffer marker */ atomic_t ksnc_tx_nob;/* # bytes queued */ int ksnc_tx_ready;/* write space */ int ksnc_tx_scheduled;/* being progressed */ -unsigned long ksnc_tx_last_post;/* time stamp of the last posted +time64_t ksnc_tx_last_post;/* time stamp of the last posted * TX */ };
@@ -386,10 +386,10 @@ struct ksock_route {struct list_head ksnr_connd_list;/* chain on ksnr_connd_routes */ struct ksock_peer *ksnr_peer;/* owning peer */ atomic_t ksnr_refcount;/* # users */ -unsigned long ksnr_timeout;/* when (in jiffies) reconnection +time64_t ksnr_timeout;/* when (in secs) reconnection * can happen next */ -long ksnr_retry_interval;/* how long between retries */ +time64_t ksnr_retry_interval;/* how long between retries */ __u32 ksnr_myipaddr;/* my IP */ __u32 ksnr_ipaddr;/* IP address to connect to */ int ksnr_port;/* port to connect to */
@@ -411,7 +411,7 @@ struct ksock_route {struct ksock_peer {struct list_head ksnp_list;/* stash on global peer list */ -unsigned long ksnp_last_alive;/* when (in jiffies) I was last +time64_t ksnp_last_alive;/* when (in seconds) I was last * alive */ struct lnet_process_id ksnp_id;/* who's on the other end(s) */
@@ -432,7 +432,7 @@ struct ksock_peer {struct list_head ksnp_zc_req_list;/* zero copy requests wait for * ACK */ -unsigned long ksnp_send_keepalive;/* time to send keepalive */ +time64_t ksnp_send_keepalive;/* time to send keepalive */ struct lnet_ni *ksnp_ni;/* which network */ int ksnp_n_passive_ips;/* # of... */
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +56 -61
323 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 5/8 staging: lustre: lnet: use ktime_get_real_ns for cookie creation
In reply to James SimmonsThe ln_interface_cookie is used to ensure that a node can tell whether the following sequence of events has happened:
node sends GET or PUT to peer
node is rebooted
peer sends REPLY or ACK to node
The ln_interface_cookie is set once, when LNet starts, and remains unchanged afterwards. To avoid accidentally obtaining the same cookie after a reboot, the code generated ths cookie using ktime_get_ns(). Once generated, the value of the cookie is not interpreted, only compared for equality. Olaf Weber reported that due to the use of ktime_get_ns() a small chance exist of generating a cookie of identical value across reboots. Using ktime_get_real_ns() removes any chance of this from happening.
WC-bug-id: https://jira.whamcloud.com/browse/LU-4423
Reviewed-on: https://review.whamcloud.com/24682
--- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
@@ -554,7 +554,7 @@ struct lnet_libhandle ** NB the interface cookie in wire handles guards against delayed * replies and ACKs appearing valid after reboot. */ - the_lnet.ln_interface_cookie =ktime_get_ns (); + the_lnet.ln_interface_cookie =ktime_get_real_ns (); the_lnet.ln_counters =cfs_percpt_alloc (lnet_cpt_table (),sizeof (struct lnet_counters ));
Signature · 1 line
1.8.3.1
PATCH 6/8 staging: lustre: lnet: move ping and delay injection to time64_t
In reply to James SimmonsMigrate away from jiffies for the pinger to time_64_t to one make it clear its for time keeping and secondly to ensure the behavior is consistent across any nodes. Besides the lnet pinger code move the lnet delay injection code to time64_t as well.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/30658
WC-bug-id: https://jira.whamcloud.com/browse/LU-10672
Reviewed-on: https://review.whamcloud.com/31339
--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 8 +-- .../staging/lustre/include/linux/lnet/lib-types.h | 13 ++-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 11 ++-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 4 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 10 +-- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 14 +++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 24 ++++---- drivers/staging/lustre/lnet/lnet/net_fault.c | 72 ++++++++++------------ drivers/staging/lustre/lnet/lnet/peer.c | 2 +- drivers/staging/lustre/lnet/lnet/router.c | 35 +++++------ drivers/staging/lustre/lnet/lnet/router_proc.c | 27 ++++---- 13 files changed, 110 insertions(+), 116 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +4 -4
@@ -404,9 +404,9 @@ struct lnet_ni *void lnet_lib_exit (void );int lnet_notify (struct lnet_ni *ni,lnet_nid_t peer,int alive, -unsigned long when); +time64_t when);void lnet_notify_locked (struct lnet_peer *lp,int notifylnd,int alive, -unsigned long when); +time64_t when);int lnet_add_route (__u32 net,__u32 hops,lnet_nid_t gateway_nid,unsigned int priority);int lnet_check_routes (void );
@@ -643,8 +643,8 @@ int lnet_get_peer_info(__u32 peer_index, __u64 *nid,static inline void lnet_peer_set_alive (struct lnet_peer *lp) { - lp->lp_last_query = jiffies; - lp->lp_last_alive = jiffies; + lp->lp_last_query =ktime_get_seconds (); + lp->lp_last_alive = lp->lp_last_query;if (!lp->lp_alive)lnet_notify_locked (lp,0 ,1 , lp->lp_last_alive); }
drivers/staging/lustre/include/linux/lnet/lib-types.h +6 -7
@@ -239,8 +239,7 @@ struct lnet_lnd {void (*lnd_notify)(struct lnet_ni *ni,lnet_nid_t peer,int alive);/* query of peer aliveness */ -void (*lnd_query)(struct lnet_ni *ni,lnet_nid_t peer, -unsigned long *when); +void (*lnd_query)(struct lnet_ni *ni,lnet_nid_t peer,time64_t *when);/* accept a new connection */ int (*lnd_accept)(struct lnet_ni *ni,struct socket *sock);
@@ -334,17 +333,17 @@ struct lnet_peer {* dead<->alive */ long lp_txqnob;/* ytes queued for sending */ -unsigned long lp_timestamp;/* time of last aliveness +time64_t lp_timestamp;/* time of last aliveness * news */ -unsigned long lp_ping_timestamp;/* time of last ping +time64_t lp_ping_timestamp;/* time of last ping * attempt */ -unsigned long lp_ping_deadline;/* != 0 if ping reply +time64_t lp_ping_deadline;/* != 0 if ping reply * expected */ -unsigned long lp_last_alive;/* when I was last alive */ -unsigned long lp_last_query;/* when lp_ni was queried +time64_t lp_last_alive;/* when I was last alive */ +time64_t lp_last_query;/* when lp_ni was queried * last time */ struct lnet_ni *lp_ni;/* interface peer is on */
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +5 -6
@@ -1039,11 +1039,10 @@ static int kiblnd_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg)return rc; } -static void kiblnd_query (struct lnet_ni *ni,lnet_nid_t nid, -unsigned long *when) +static void kiblnd_query (struct lnet_ni *ni,lnet_nid_t nid,time64_t *when) { -unsigned long last_alive =0 ; -unsigned long now = jiffies; +time64_t last_alive =0 ; +time64_t now =ktime_get_seconds ();rwlock_t *glock = &kiblnd_data.kib_global_lock;struct kib_peer *peer;unsigned long flags;
@@ -1066,9 +1065,9 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,if (!peer)kiblnd_launch_tx (ni,NULL , nid); -CDEBUG (D_NET ,"Peer %s %p, alive %ld secs ago\n" , +CDEBUG (D_NET ,"Peer %s %p, alive %lld secs ago\n" ,libcfs_nid2str (nid), peer, - last_alive ? (now - last_alive) /HZ :-1 ); + last_alive ? now - last_alive :-1 ); }static void kiblnd_free_pages (struct kib_pages *p)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +2 -2
@@ -571,8 +571,8 @@ struct kib_peer {* round robin */ struct list_head ibp_tx_queue;/* msgs waiting for a conn */ __u64 ibp_incarnation;/* incarnation of peer */ -/* when (in jiffies) I was last alive */ -unsigned long ibp_last_alive; +/* when (in seconds) I was last alive */ +time64_t ibp_last_alive;/* # users */ atomic_t ibp_refcount;/* version of peer */
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +5 -5
@@ -1847,8 +1847,8 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,static void kiblnd_peer_alive (struct kib_peer *peer) { -/* This is racy, but everyone's only writing jiffies */ - peer->ibp_last_alive = jiffies; +/* This is racy, but everyone's only writing ktime_get_seconds() */ + peer->ibp_last_alive =ktime_get_seconds ();mb (); }
@@ -1856,7 +1856,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, kiblnd_peer_notify(struct kib_peer *peer) {int error =0 ; -unsigned long last_alive =0 ; +time64_t last_alive =0 ;unsigned long flags;read_lock_irqsave (&kiblnd_data.kib_global_lock, flags);
@@ -3216,9 +3216,9 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, }if (timedout) { -CERROR ("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n" , +CERROR ("Timed out RDMA with %s (%lld): c: %u, oc: %u, rc: %u\n" ,libcfs_nid2str (peer->ibp_nid), - (jiffies - peer->ibp_last_alive) /HZ , +ktime_get_seconds () - peer->ibp_last_alive, conn->ibc_credits, conn->ibc_outstanding_credits, conn->ibc_reserved_credits);
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +2 -2
@@ -1537,7 +1537,7 @@ struct ksock_peer *if (notify)lnet_notify (peer->ksnp_ni, peer->ksnp_id.nid,0 , - last_alive *HZ ); + last_alive); }void
@@ -1828,7 +1828,7 @@ struct ksock_peer * }void -ksocknal_query (struct lnet_ni *ni,lnet_nid_t nid,unsigned long *when) +ksocknal_query (struct lnet_ni *ni,lnet_nid_t nid,time64_t *when) {int connect =1 ;time64_t last_alive =0 ;
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +1 -1
@@ -658,7 +658,7 @@ int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,void ksocknal_queue_tx_locked (struct ksock_tx *tx,struct ksock_conn *conn);void ksocknal_txlist_done (struct lnet_ni *ni,struct list_head *txlist,int error);void ksocknal_notify (struct lnet_ni *ni,lnet_nid_t gw_nid,int alive); -void ksocknal_query (struct lnet_ni *ni,lnet_nid_t nid,unsigned long *when); +void ksocknal_query (struct lnet_ni *ni,lnet_nid_t nid,time64_t *when);int ksocknal_thread_start (int (*fn)(void *arg),void *arg,char *name);void ksocknal_thread_fini (void );void ksocknal_launch_all_connections_locked (struct ksock_peer *peer);
drivers/staging/lustre/lnet/lnet/api-ni.c +9 -5
@@ -1888,7 +1888,6 @@ void lnet_lib_exit(void)struct lnet_process_id id = {0 };struct lnet_ni *ni;int rc; -unsigned long secs_passed;BUILD_BUG_ON (LIBCFS_IOC_DATA_MAX < sizeof(struct lnet_ioctl_net_config) +
@@ -2028,12 +2027,17 @@ void lnet_lib_exit(void) &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob); } -case IOC_LIBCFS_NOTIFY_ROUTER : - secs_passed = (ktime_get_real_seconds () - data->ioc_u64[0 ]); - secs_passed *=msecs_to_jiffies (MSEC_PER_SEC ); +case IOC_LIBCFS_NOTIFY_ROUTER : { +time64_t deadline =ktime_get_real_seconds () - data->ioc_u64[0 ]; +/* The deadline passed in by the user should be some time in +* seconds in the future since the UNIX epoch. We have to map +* that deadline to the wall clock. +*/ + deadline +=ktime_get_seconds ();return lnet_notify (NULL , data->ioc_nid, data->ioc_flags, - jiffies - secs_passed); + deadline); + }case IOC_LIBCFS_LNET_DIST : rc =LNetDist (data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1 ]);
drivers/staging/lustre/lnet/lnet/lib-move.c +12 -12
@@ -492,7 +492,7 @@static void lnet_ni_query_locked (struct lnet_ni *ni,struct lnet_peer *lp) { -unsigned long last_alive =0 ; +time64_t last_alive =0 ;LASSERT (lnet_peer_aliveness_enabled (lp));LASSERT (ni->ni_lnd->lnd_query);
@@ -501,7 +501,7 @@ ni->ni_lnd->lnd_query (ni, lp->lp_nid, &last_alive);lnet_net_lock (lp->lp_cpt); - lp->lp_last_query = jiffies; + lp->lp_last_query =ktime_get_seconds ();if (last_alive)/* NI has updated timestamp */ lp->lp_last_alive = last_alive;
@@ -512,7 +512,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now) { int alive; -unsigned long deadline; +time64_t deadline;LASSERT (lnet_peer_aliveness_enabled (lp));
@@ -520,11 +520,11 @@* ignore the initial assumed death (see lnet_peers_start_down()). */ if (!lp->lp_alive && lp->lp_alive_count >0 && -time_after_eq (lp->lp_timestamp, lp->lp_last_alive)) + lp->lp_timestamp >= lp->lp_last_alive)return 0 ; - deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout *HZ ; - alive =time_after (deadline, now); + deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout; + alive = deadline > now;/* Update obsolete lp_alive except for routers assumed to be dead * initially, because router checker would update aliveness in this
@@ -544,7 +544,7 @@static int lnet_peer_alive_locked (struct lnet_peer *lp) { -unsigned long now = jiffies; +time64_t now =ktime_get_seconds ();if (!lnet_peer_aliveness_enabled (lp))return -ENODEV ;
@@ -558,15 +558,15 @@*/ if (lp->lp_last_query) {static const int lnet_queryinterval =1 ; +time64_t next_query; -unsigned long next_query = - lp->lp_last_query + lnet_queryinterval *HZ ; + next_query = lp->lp_last_query + lnet_queryinterval; -if (time_before (now, next_query)) { +if (now < next_query) {if (lp->lp_alive) -CWARN ("Unexpected aliveness of peer %s: %d < %d (%d/%d)\n" , +CWARN ("Unexpected aliveness of peer %s: %lld < %lld (%d/%d)\n" ,libcfs_nid2str (lp->lp_nid), - (int )now, (int )next_query, + now, next_query, lnet_queryinterval, lp->lp_ni->ni_peertimeout);return 0 ;
drivers/staging/lustre/lnet/lnet/net_fault.c +34 -38
154 lines not on this page · raw message
drivers/staging/lustre/lnet/lnet/peer.c +1 -1
@@ -315,7 +315,7 @@ struct lnet_peer * lp->lp_alive_count =0 ; lp->lp_timestamp =0 ; lp->lp_alive = !lnet_peers_start_down ();/* 1 bit!! */ - lp->lp_last_alive = jiffies;/* assumes alive */ + lp->lp_last_alive =ktime_get_seconds ();/* assumes alive */ lp->lp_last_query =0 ;/* haven't asked NI yet */ lp->lp_ping_timestamp =0 ; lp->lp_ping_feats =LNET_PING_FEAT_INVAL ;
drivers/staging/lustre/lnet/lnet/router.c +17 -18
@@ -101,9 +101,9 @@void lnet_notify_locked (struct lnet_peer *lp,int notifylnd,int alive, -unsigned long when) +time64_t when) { -if (time_before (when, lp->lp_timestamp)) {/* out of date information */ +if (lp->lp_timestamp > when) {/* out of date information */ CDEBUG (D_NET ,"Out of date\n" );return ; }
@@ -765,7 +765,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg)* we ping alive routers to try to detect router death before * apps get burned). */ -lnet_notify_locked (lp,1 , !event->status, jiffies); +lnet_notify_locked (lp,1 , !event->status,ktime_get_seconds ());/* * The router checker will wake up very shortly and do the
@@ -832,7 +832,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) {struct lnet_ni *ni;time64_t now; -int timeout; +time64_t timeout;LASSERT (the_lnet.ln_routing);
@@ -857,7 +857,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg)LASSERT (ni->ni_status);if (ni->ni_status->ns_status !=LNET_NI_STATUS_DOWN ) { -CDEBUG (D_NET ,"NI(%s:%d) status changed to down\n" , +CDEBUG (D_NET ,"NI(%s:%lld) status changed to down\n" ,libcfs_nid2str (ni->ni_nid), timeout);/* * NB: so far, this is the only place to set
@@ -976,13 +976,13 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) lnet_ping_router_locked(struct lnet_peer *rtr) {struct lnet_rc_data *rcd =NULL ; -unsigned long now = jiffies; -int secs; +time64_t now =ktime_get_seconds (); +time64_t secs;lnet_peer_addref_locked (rtr);if (rtr->lp_ping_deadline &&/* ping timed out? */ -time_after (now, rtr->lp_ping_deadline)) + now > rtr->lp_ping_deadline)lnet_notify_locked (rtr,1 ,0 , now);/* Run any outstanding notifications */
@@ -1004,13 +1004,13 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) secs =lnet_router_check_interval (rtr);CDEBUG (D_NET , -"rtr %s %d: deadline %lu ping_notsent %d alive %d alive_count %d lp_ping_timestamp %lu\n" , +"rtr %s %lldd: deadline %lld ping_notsent %d alive %d alive_count %d lp_ping_timestamp %lld\n" ,libcfs_nid2str (rtr->lp_nid), secs, rtr->lp_ping_deadline, rtr->lp_ping_notsent, rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);if (secs && !rtr->lp_ping_notsent && -time_after (now, rtr->lp_ping_timestamp + secs *HZ )) { + now > rtr->lp_ping_timestamp + secs) {int rc;struct lnet_process_id id;struct lnet_handle_md mdh;
@@ -1025,8 +1025,8 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) mdh = rcd->rcd_mdh;if (!rtr->lp_ping_deadline) { - rtr->lp_ping_deadline = - jiffies + router_ping_timeout *HZ ; + rtr->lp_ping_deadline =ktime_get_seconds () + + router_ping_timeout; }lnet_net_unlock (rtr->lp_cpt);
@@ -1726,10 +1726,10 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) }int -lnet_notify (struct lnet_ni *ni,lnet_nid_t nid,int alive,unsigned long when) +lnet_notify (struct lnet_ni *ni,lnet_nid_t nid,int alive,time64_t when) {struct lnet_peer *lp =NULL ; -unsigned long now = jiffies; +time64_t now =ktime_get_seconds ();int cpt =lnet_cpt_of_nid (nid);LASSERT (!in_interrupt ());
@@ -1748,11 +1748,10 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) }/* can't do predictions... */ -if (time_after (when, now)) { -CWARN ("Ignoring prediction from %s of %s %s %ld seconds in the future\n" , +if (when > now) { +CWARN ("Ignoring prediction from %s of %s %s %lld seconds in the future\n" , !ni ?"userspace" :libcfs_nid2str (ni->ni_nid), -libcfs_nid2str (nid), alive ?"up" :"down" , - (when - now) /HZ ); +libcfs_nid2str (nid), alive ?"up" :"down" , when - now);return -EINVAL ; }
drivers/staging/lustre/lnet/lnet/router_proc.c +12 -15
@@ -323,14 +323,14 @@ static int proc_lnet_routers(struct ctl_table *table, int write,if (peer) {lnet_nid_t nid = peer->lp_nid; -unsigned long now = jiffies; -unsigned long deadline = peer->lp_ping_deadline; +time64_t now =ktime_get_seconds (); +time64_t deadline = peer->lp_ping_deadline;int nrefs = peer->lp_refcount;int nrtrrefs = peer->lp_rtr_refcount;int alive_cnt = peer->lp_alive_count;int alive = peer->lp_alive;int pingsent = !peer->lp_ping_notsent; -int last_ping = (now - peer->lp_ping_timestamp) /HZ ; +time64_t last_ping = now - peer->lp_ping_timestamp;int down_ni =0 ;struct lnet_route *rtr;
@@ -351,18 +351,17 @@ static int proc_lnet_routers(struct ctl_table *table, int write,if (!deadline) s +=snprintf (s, tmpstr + tmpsiz - s, -"%-4d %7d %9d %6s %12d %9d %8s %7d %s\n" , +"%-4d %7d %9d %6s %12llu %9d %8s %7d %s\n" , nrefs, nrtrrefs, alive_cnt, alive ?"up" :"down" , last_ping, pingsent,"NA" , down_ni,libcfs_nid2str (nid));else s +=snprintf (s, tmpstr + tmpsiz - s, -"%-4d %7d %9d %6s %12d %9d %8lu %7d %s\n" , +"%-4d %7d %9d %6s %12llu %9d %8llu %7d %s\n" , nrefs, nrtrrefs, alive_cnt, alive ?"up" :"down" , last_ping, - pingsent, - (deadline - now) /HZ , + pingsent, deadline - now, down_ni,libcfs_nid2str (nid));LASSERT (tmpstr + tmpsiz - s >0 ); }
@@ -493,7 +492,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,if (peer) {lnet_nid_t nid = peer->lp_nid;int nrefs = peer->lp_refcount; -int lastalive =-1 ; +time64_t lastalive =-1 ;char *aliveness ="NA" ;int maxcr = peer->lp_ni->ni_peertxcredits;int txcr = peer->lp_txcredits;
@@ -507,11 +506,9 @@ static int proc_lnet_peers(struct ctl_table *table, int write, aliveness = peer->lp_alive ?"up" :"down" ;if (lnet_peer_aliveness_enabled (peer)) { -unsigned long now = jiffies; -long delta; +time64_t now =ktime_get_seconds (); - delta = now - peer->lp_last_alive; - lastalive = (delta) /HZ ; + lastalive = now - peer->lp_last_alive;/* No need to mess up peers contents with * arbitrarily long integers - it suffices to
@@ -524,7 +521,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,lnet_net_unlock (cpt); s +=snprintf (s, tmpstr + tmpsiz - s, -"%-24s %4d %5s %5d %5d %5d %5d %5d %5d %d\n" , +"%-24s %4d %5s %5lld %5d %5d %5d %5d %5d %d\n" ,libcfs_nid2str (nid), nrefs, aliveness, lastalive, maxcr, rtrcr, minrtrcr, txcr, mintxcr, txqnob);
@@ -679,7 +676,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,struct lnet_tx_queue *tq;char *stat;time64_t now =ktime_get_real_seconds (); -int last_alive =-1 ; +time64_t last_alive =-1 ;int i;int j;
@@ -714,7 +711,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,lnet_net_lock (i); s += snprintf(s, tmpstr + tmpsiz - s, - "%-24s %6s %5d %4d %4d %4d %5d %5d %5d\n", + "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n", libcfs_nid2str(ni->ni_nid), stat, last_alive, *ni->ni_refs[i], ni->ni_peertxcredits,
Signature · 1 line
1.8.3.1
PATCH 7/8 staging: lustre: ko2iblnd: remove remaining jiffy use
In reply to James SimmonsConvert the remaining jiffy use in ko2iblnd to time64_t and ktime_t. The HZ value can be configured differently for a set of nodes and this can lead to corner case problems with node to node interactions. This allows lustre to have consistent behavior across nodes.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/31042
--- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 37 +++++++++++----------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 24 +++++++------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 26 +++++++-------- 3 files changed, 45 insertions(+), 42 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +19 -18
@@ -1445,7 +1445,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,if (rc) goto out_fpo; - fpo->fpo_deadline = jiffies +IBLND_POOL_DEADLINE *HZ ; + fpo->fpo_deadline =ktime_get_seconds () +IBLND_POOL_DEADLINE ; fpo->fpo_owner = fps; *pp_fpo = fpo;
@@ -1515,13 +1515,13 @@ static void kiblnd_fini_fmr_poolset(struct kib_fmr_poolset *fps)return rc; } -static int kiblnd_fmr_pool_is_idle (struct kib_fmr_pool *fpo,unsigned long now) +static int kiblnd_fmr_pool_is_idle (struct kib_fmr_pool *fpo,time64_t now) {if (fpo->fpo_map_count)/* still in use */ return 0 ;if (fpo->fpo_failed)return 1 ; -return time_after_eq (now, fpo->fpo_deadline); +return now >= fpo->fpo_deadline; } static int
@@ -1551,7 +1551,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)LIST_HEAD (zombies);struct kib_fmr_pool *fpo = fmr->fmr_pool;struct kib_fmr_poolset *fps; -unsigned long now = jiffies; +time64_t now =ktime_get_seconds ();struct kib_fmr_pool *tmp;int rc;
@@ -1618,7 +1618,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,spin_lock (&fps->fps_lock); version = fps->fps_version;list_for_each_entry (fpo, &fps->fps_pool_list, fpo_list) { - fpo->fpo_deadline = jiffies +IBLND_POOL_DEADLINE *HZ ; + fpo->fpo_deadline =ktime_get_seconds () +IBLND_POOL_DEADLINE ; fpo->fpo_map_count++;if (fpo->fpo_is_fmr) {
@@ -1725,7 +1725,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx, goto again; } -if (time_before (jiffies, fps->fps_next_retry)) { +if (ktime_get_seconds () < fps->fps_next_retry) {/* someone failed recently */ spin_unlock (&fps->fps_lock);return -EAGAIN ;
@@ -1742,7 +1742,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx, fps->fps_version++;list_add_tail (&fpo->fpo_list, &fps->fps_pool_list); }else { - fps->fps_next_retry = jiffies +IBLND_POOL_RETRY *HZ ; + fps->fps_next_retry =ktime_get_seconds () +IBLND_POOL_RETRY ; }spin_unlock (&fps->fps_lock);
@@ -1763,7 +1763,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, intmemset (pool,0 ,sizeof (*pool));INIT_LIST_HEAD (&pool->po_free_list); - pool->po_deadline = jiffies +IBLND_POOL_DEADLINE *HZ ; + pool->po_deadline =ktime_get_seconds () +IBLND_POOL_DEADLINE ; pool->po_owner = ps; pool->po_size = size; }
@@ -1843,13 +1843,13 @@ static int kiblnd_init_poolset(struct kib_poolset *ps, int cpt,return rc; } -static int kiblnd_pool_is_idle (struct kib_pool *pool,unsigned long now) +static int kiblnd_pool_is_idle (struct kib_pool *pool,time64_t now) {if (pool->po_allocated)/* still in use */ return 0 ;if (pool->po_failed)return 1 ; -return time_after_eq (now, pool->po_deadline); +return now >= pool->po_deadline; }void kiblnd_pool_free_node (struct kib_pool *pool,struct list_head *node)
@@ -1857,7 +1857,7 @@ void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)LIST_HEAD (zombies);struct kib_poolset *ps = pool->po_owner;struct kib_pool *tmp; -unsigned long now = jiffies; +time64_t now =ktime_get_seconds ();spin_lock (&ps->ps_lock);
@@ -1887,7 +1887,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)struct list_head *node;struct kib_pool *pool;unsigned int interval =1 ; -unsigned long time_before; +ktime_t time_before;unsigned int trips =0 ;int rc;
@@ -1898,7 +1898,8 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)continue ; pool->po_allocated++; - pool->po_deadline = jiffies +IBLND_POOL_DEADLINE *HZ ; + pool->po_deadline =ktime_get_seconds () + +IBLND_POOL_DEADLINE ; node = pool->po_free_list.next;list_del (node);
@@ -1926,7 +1927,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps) goto again; } -if (time_before (jiffies, ps->ps_next_retry)) { +if (ktime_get_seconds () < ps->ps_next_retry) {/* someone failed recently */ spin_unlock (&ps->ps_lock);return NULL ;
@@ -1936,17 +1937,17 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)spin_unlock (&ps->ps_lock);CDEBUG (D_NET ,"%s pool exhausted, allocate new pool\n" , ps->ps_name); - time_before = jiffies; + time_before =ktime_get (); rc = ps->ps_pool_create (ps, ps->ps_pool_size, &pool); -CDEBUG (D_NET ,"ps_pool_create took %lu HZ to complete" , - jiffies - time_before); +CDEBUG (D_NET ,"ps_pool_create took %lld ms to complete" , +ktime_ms_delta (ktime_get (), time_before));spin_lock (&ps->ps_lock); ps->ps_increasing =0 ;if (!rc) {list_add_tail (&pool->po_list, &ps->ps_pool_list); }else { - ps->ps_next_retry = jiffies +IBLND_POOL_RETRY *HZ ; + ps->ps_next_retry =ktime_get_seconds () +IBLND_POOL_RETRY ;CERROR ("Can't allocate new %s pool because out of memory\n" , ps->ps_name); }
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +13 -11
@@ -155,7 +155,7 @@ struct kib_dev {char ibd_ifname[KIB_IFNAME_SIZE ];int ibd_nnets;/* # nets extant */ -unsigned long ibd_next_failover; +time64_t ibd_next_failover;int ibd_failed_failover;/* # failover failures */ unsigned int ibd_failover;/* failover in progress */ unsigned int ibd_can_failover;/* IPoIB interface is a bonding master */
@@ -205,7 +205,7 @@ struct kib_poolset {char ps_name[IBLND_POOL_NAME_LEN ];/* pool set name */ struct list_head ps_pool_list;/* list of pools */ struct list_head ps_failed_pool_list;/* failed pool list */ -unsigned long ps_next_retry;/* time stamp for retry if */ +time64_t ps_next_retry;/* time stamp for retry if */ /* failed to allocate */ int ps_increasing;/* is allocating new pool */ int ps_pool_size;/* new pool size */
@@ -221,7 +221,7 @@ struct kib_pool {struct list_head po_list;/* chain on pool list */ struct list_head po_free_list;/* pre-allocated node */ struct kib_poolset *po_owner;/* pool_set of this pool */ -unsigned long po_deadline;/* deadline of this pool */ +time64_t po_deadline;/* deadline of this pool */ int po_allocated;/* # of elements in use */ int po_failed;/* pool is created on failed HCA */ int po_size;/* # of pre-allocated elements */
@@ -250,8 +250,9 @@ struct kib_fmr_poolset {int fps_flush_trigger;int fps_cache;int fps_increasing;/* is allocating new pool */ -unsigned long fps_next_retry;/* time stamp for retry if*/ -/* failed to allocate */ +time64_t fps_next_retry;/* time stamp for retry +* if failed to allocate +*/ };struct kib_fast_reg_descriptor {/* For fast registration */
@@ -275,7 +276,7 @@ struct kib_fmr_pool {int fpo_pool_size; } fast_reg; }; -unsigned long fpo_deadline;/* deadline of this pool */ +time64_t fpo_deadline;/* deadline of this pool */ int fpo_failed;/* fmr pool is failed */ int fpo_map_count;/* # of mapped FMR */ int fpo_is_fmr;
@@ -487,7 +488,7 @@ struct kib_tx { /* transmit message */short tx_queued;/* queued for sending */ short tx_waiting;/* waiting for peer */ int tx_status;/* LNET completion status */ -unsigned long tx_deadline;/* completion deadline */ +ktime_t tx_deadline;/* completion deadline */ __u64 tx_cookie;/* completion cookie */ struct lnet_msg *tx_lntmsg[2 ];/* lnet msgs to finalize on completion */ struct kib_msg *tx_msg;/* message buffer (host vaddr) */
@@ -533,7 +534,7 @@ struct kib_conn { unsigned int ibc_nrx:16; /* receive buffers owned */ unsigned int ibc_scheduled:1; /* scheduled for attention */ unsigned int ibc_ready:1; /* CQ callback fired */ -unsigned long ibc_last_send;/* time of last send */ +ktime_t ibc_last_send;/* time of last send */ struct list_head ibc_connd_list;/* link chain for */ /* kiblnd_check_conns only */ struct list_head ibc_early_rxs;/* rxs completed before ESTABLISHED */
@@ -763,10 +764,11 @@ struct kib_peer {static inline int kiblnd_send_keepalive (struct kib_conn *conn) { +s64 keepalive_ns = *kiblnd_tunables.kib_keepalive *NSEC_PER_SEC ; +return (*kiblnd_tunables.kib_keepalive >0 ) && -time_after (jiffies, conn->ibc_last_send + -msecs_to_jiffies (*kiblnd_tunables.kib_keepalive * -MSEC_PER_SEC )); +ktime_after (ktime_get (), +ktime_add_ns (conn->ibc_last_send, keepalive_ns)); } static inline int
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +13 -13
@@ -852,7 +852,7 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx, rc =ib_post_send (conn->ibc_cmid->qp, wrq, &bad); } - conn->ibc_last_send = jiffies; + conn->ibc_last_send =ktime_get ();if (!rc)return 0 ;
@@ -1137,15 +1137,15 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx, kiblnd_queue_tx_locked(struct kib_tx *tx, struct kib_conn *conn) { struct list_head *q; +s64 timeout_ns;LASSERT (tx->tx_nwrq >0 );/* work items set up */ LASSERT (!tx->tx_queued);/* not queued for sending already */ LASSERT (conn->ibc_state >=IBLND_CONN_ESTABLISHED ); + timeout_ns = *kiblnd_tunables.kib_timeout *NSEC_PER_SEC ; tx->tx_queued =1 ; - tx->tx_deadline = jiffies + -msecs_to_jiffies (*kiblnd_tunables.kib_timeout * -MSEC_PER_SEC ); + tx->tx_deadline =ktime_add_ns (ktime_get (), timeout_ns);if (!tx->tx_conn) {kiblnd_conn_addref (conn);
@@ -2135,7 +2135,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,/* connection established */ write_lock_irqsave (&kiblnd_data.kib_global_lock, flags); - conn->ibc_last_send = jiffies; + conn->ibc_last_send =ktime_get ();kiblnd_set_conn_state (conn,IBLND_CONN_ESTABLISHED );kiblnd_peer_alive (peer);
@@ -3153,10 +3153,11 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,LASSERT (tx->tx_waiting || tx->tx_sending); } -if (time_after_eq (jiffies, tx->tx_deadline)) { -CERROR ("Timed out tx: %s, %lu seconds\n" , +if (ktime_compare (ktime_get (), tx->tx_deadline) >=0 ) { +CERROR ("Timed out tx: %s, %lld seconds\n" ,kiblnd_queue2str (conn, txs), - (jiffies - tx->tx_deadline) /HZ ); +ktime_ms_delta (ktime_get (), + tx->tx_deadline) /MSEC_PER_SEC );return 1 ; } }
@@ -3692,8 +3693,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,list_for_each_entry (dev, &kiblnd_data.kib_failed_devs, ibd_fail_list) { -if (time_before (jiffies, - dev->ibd_next_failover)) +if (ktime_get_seconds () < dev->ibd_next_failover)continue ; do_failover =1 ;break ;
@@ -3711,13 +3711,13 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,LASSERT (dev->ibd_failover); dev->ibd_failover =0 ;if (rc >=0 ) {/* Device is OK or failover succeed */ - dev->ibd_next_failover = jiffies +3 *HZ ; + dev->ibd_next_failover =ktime_get_seconds () +3 ;continue ; }/* failed to failover, retry later */ - dev->ibd_next_failover = - jiffies +min (dev->ibd_failed_failover,10 ) *HZ ; + dev->ibd_next_failover =ktime_get_seconds () + +min (dev->ibd_failed_failover,10 );if (kiblnd_dev_can_failover (dev)) {list_add_tail (&dev->ibd_fail_list, &kiblnd_data.kib_failed_devs);
Signature · 1 line
1.8.3.1
PATCH 8/8 staging: lustre: selftest: fix time reporting
In reply to James SimmonsMigrate crp_stamp to nanoseconds and both timestamps nd_stamp, sn_start to ktime. The move away from jiffies, which can vary on platforms, to something that is the consistent on every node. Currently jiffies data was being transmitted over the wire and the other node could have a different HZ value configured which lead to incorrect results. This will ensure that the reported results to the user will always be correct.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9019
Reviewed-on: https://review.whamcloud.com/31041
--- .../lustre/include/uapi/linux/lnet/lnetst.h | 2 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 39 +++++++++++----------- drivers/staging/lustre/lnet/selftest/conrpc.h | 2 +- drivers/staging/lustre/lnet/selftest/console.c | 4 +-- drivers/staging/lustre/lnet/selftest/console.h | 2 +- drivers/staging/lustre/lnet/selftest/framework.c | 4 +-- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- drivers/staging/lustre/lnet/selftest/timer.c | 8 ++--- 8 files changed, 32 insertions(+), 31 deletions(-)
drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h +1 -1
@@ -71,7 +71,7 @@struct lst_sid {lnet_nid_t ses_nid;/* nid of console node */ -__u64 ses_stamp;/* time stamp */ +__s64 ses_stamp;/* time stamp */ };/*** session id */ extern struct lst_sid LST_INVALID_SID ;
drivers/staging/lustre/lnet/selftest/conrpc.c +20 -19
@@ -70,11 +70,11 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,/* not an orphan RPC */ crpc->crp_finished =1 ; -if (!crpc->crp_stamp) { +if (!crpc->crp_stamp_ns) {/* not aborted */ LASSERT (!crpc->crp_status); - crpc->crp_stamp = jiffies; + crpc->crp_stamp_ns =ktime_get_ns (); crpc->crp_status = rpc->crpc_status; }
@@ -102,7 +102,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, crpc->crp_finished =0 ; crpc->crp_unpacked =0 ; crpc->crp_status =0 ; - crpc->crp_stamp =0 ; + crpc->crp_stamp_ns =0 ; crpc->crp_embedded = embedded;INIT_LIST_HEAD (&crpc->crp_link);
@@ -294,16 +294,16 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,spin_lock (&rpc->crpc_lock);if (!crpc->crp_posted ||/* not posted */ - crpc->crp_stamp) {/* rpc done or aborted already */ -if (!crpc->crp_stamp) { - crpc->crp_stamp = jiffies; + crpc->crp_stamp_ns) {/* rpc done or aborted already */ +if (!crpc->crp_stamp_ns) { + crpc->crp_stamp_ns =ktime_get_ns (); crpc->crp_status = -EINTR ; }spin_unlock (&rpc->crpc_lock);continue ; } - crpc->crp_stamp = jiffies; + crpc->crp_stamp_ns =ktime_get_ns (); crpc->crp_status = error;spin_unlock (&rpc->crpc_lock);
@@ -314,10 +314,10 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,continue ; nd = crpc->crp_node; -if (time_after (nd->nd_stamp, crpc->crp_stamp)) +if (ktime_to_ns (nd->nd_stamp) > crpc->crp_stamp_ns)continue ; - nd->nd_stamp = crpc->crp_stamp; + nd->nd_stamp =ktime_set (0 , crpc->crp_stamp_ns); nd->nd_state =LST_NODE_DOWN ; } }
@@ -390,7 +390,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,struct srpc_generic_reply *rep;LASSERT (nd && rpc); -LASSERT (crpc->crp_stamp); +LASSERT (crpc->crp_stamp_ns);if (crpc->crp_status) { *msgpp =NULL ;
@@ -403,10 +403,10 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, crpc->crp_unpacked =1 ; } -if (time_after (nd->nd_stamp, crpc->crp_stamp)) +if (ktime_to_ns (nd->nd_stamp) > crpc->crp_stamp_ns)return 0 ; - nd->nd_stamp = crpc->crp_stamp; + nd->nd_stamp =ktime_set (0 , crpc->crp_stamp_ns); rep = &(*msgpp)->msg_body.reply;if (rep->sid.ses_nid ==LNET_NID_ANY )
@@ -433,7 +433,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,list_for_each_entry (crpc, &trans->tas_rpcs_list, crp_link) {lstcon_rpc_stat_total (stat,1 ); -LASSERT (crpc->crp_stamp); +LASSERT (crpc->crp_stamp_ns); error =lstcon_rpc_get_reply (crpc, &rep);if (error) {
@@ -474,9 +474,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,struct lstcon_rpc *crpc;struct srpc_msg *msg;struct lstcon_node *nd; -long dur;struct timeval tv;int error; +s64 dur;LASSERT (head_up);
@@ -493,15 +493,15 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, ent = list_entry(next, struct lstcon_rpc_ent, rpe_link); -LASSERT (crpc->crp_stamp); +LASSERT (crpc->crp_stamp_ns); error =lstcon_rpc_get_reply (crpc, &msg); nd = crpc->crp_node; - dur = (long )(crpc->crp_stamp - - (unsigned long )console_session.ses_id.ses_stamp); -jiffies_to_timeval (dur, &tv); + dur = crpc->crp_stamp_ns - + console_session.ses_id.ses_stamp *NSEC_PER_MSEC ; + tv =ns_to_timeval (dur); if (copy_to_user(&ent->rpe_peer, &nd->nd_id, sizeof(struct lnet_process_id)) ||
@@ -1246,7 +1246,8 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,if (nd->nd_state !=LST_NODE_ACTIVE )continue ; - intv = (jiffies - nd->nd_stamp) /msecs_to_jiffies (MSEC_PER_SEC ); + intv =div_u64 (ktime_ms_delta (ktime_get (), nd->nd_stamp), +MSEC_PER_SEC );if (intv < nd->nd_timeout /2 )continue ;
drivers/staging/lustre/lnet/selftest/conrpc.h +1 -1
@@ -70,7 +70,7 @@ struct lstcon_rpc {/** RPC is embedded in other structure and can't free it */ unsigned int crp_embedded:1;int crp_status;/* console rpc errors */ -unsigned long crp_stamp;/* replied time stamp */ +s64 crp_stamp_ns;/* replied time stamp */ };struct lstcon_rpc_trans {
drivers/staging/lustre/lnet/selftest/console.c +2 -2
@@ -97,7 +97,7 @@ ndl->ndl_node->nd_ref =1 ; ndl->ndl_node->nd_id = id; - ndl->ndl_node->nd_stamp = jiffies; + ndl->ndl_node->nd_stamp =ktime_get (); ndl->ndl_node->nd_state =LST_NODE_UNKNOWN ; ndl->ndl_node->nd_timeout =0 ;memset (&ndl->ndl_node->nd_ping,0 ,sizeof (struct lstcon_rpc ));
@@ -1700,7 +1700,7 @@ static void lstcon_group_ndlink_release(struct lstcon_group *,LNetGetId (1 , &id); sid->ses_nid = id.nid; - sid->ses_stamp = jiffies; + sid->ses_stamp =div_u64 (ktime_get_ns (),NSEC_PER_MSEC ); }int
drivers/staging/lustre/lnet/selftest/console.h +1 -1
@@ -51,7 +51,7 @@ struct lstcon_node {int nd_ref;/* reference count */ int nd_state;/* state of the node */ int nd_timeout;/* session timeout */ -unsigned long nd_stamp;/* timestamp of last replied RPC */ +ktime_t nd_stamp;/* timestamp of last replied RPC */ struct lstcon_rpc nd_ping;/* ping rpc */ };
drivers/staging/lustre/lnet/selftest/framework.c +2 -2
@@ -272,7 +272,7 @@ sn->sn_id = sid; sn->sn_features = features; sn->sn_timeout = session_timeout; - sn->sn_started = jiffies; + sn->sn_started =ktime_get (); timer->stt_data = sn; timer->stt_func = sfw_session_expired;
@@ -384,7 +384,7 @@* send over the msecs since the session was started * with 32 bits to send, this is ~49 days */ - cnt->running_ms =jiffies_to_msecs (jiffies - sn->sn_started); + cnt->running_ms =ktime_ms_delta (ktime_get (), sn->sn_started); cnt->brw_errors =atomic_read (&sn->sn_brw_errors); cnt->ping_errors =atomic_read (&sn->sn_ping_errors); cnt->zombie_sessions =atomic_read (&sfw_data.fw_nzombies);
drivers/staging/lustre/lnet/selftest/selftest.h +1 -1
@@ -331,7 +331,7 @@ struct sfw_session {atomic_t sn_refcount;atomic_t sn_brw_errors;atomic_t sn_ping_errors; -unsigned long sn_started; +ktime_t sn_started; };#define sfw_sid_equal (sid0, sid1) ((sid0).ses_nid == (sid1).ses_nid && \
drivers/staging/lustre/lnet/selftest/timer.c +4 -4
@@ -55,7 +55,7 @@ static struct st_timer_data { spinlock_t stt_lock; - unsigned long stt_prev_slot; /* start time of the slot processed + time64_t stt_prev_slot; /* start time of the slot processed * previously */ struct list_head stt_hash[STTIMER_NSLOTS];
@@ -144,18 +144,18 @@ }static int -stt_check_timers (unsigned long *last) +stt_check_timers (time64_t *last) {int expired =0 ;time64_t now; -unsigned long this_slot; +time64_t this_slot; now =ktime_get_real_seconds (); this_slot = now &STTIMER_SLOTTIMEMASK ;spin_lock (&stt_data.stt_lock); -while (time_after_eq (this_slot, *last)) { +while (this_slot >= *last) { expired +=stt_expire_list (STTIMER_SLOT (this_slot), now); this_slot = this_slot -STTIMER_SLOTTIME ; }
Signature · 1 line
1.8.3.1
cover staging: lustre: lnet: resolve time handling issues
In reply to James SimmonsQuoted 11 lines · James Simmons
The migration of lustre to 64 bit time handling exposed various bugs which have lead to problems like routers no longer functioning with the upstream client. This is due to the complex handling of time by lustre with seconds time units and jiffies. Add in the fact that jiffies can vary from node to node and you can encounter corner case issues in a large node deployment. The solution to resolve this was to migrate as much as possible to
time64_twhen all you needed was seconds percision andktime_tif better percision was required. With these changes it is reduced down to using jiffies only forschedule_timeoutcalls.
Quoted 9 lines
James Simmons (8):
staging: lustre: lnet: simplifylnet_eq_wait_locked
staging: lustre: o2iblnd: usektime_get_real_nsforibn_incarnation
staging: lustre: ksocklnd: usektime_get_real_nsforksnn_incarnation
staging: lustre: ksocklnd: move remaining time handling to 64 bits
staging: lustre: lnet: usektime_get_real_nsfor cookie creation
staging: lustre: lnet: move ping and delay injection totime64_t
staging: lustre: ko2iblnd: remove remaining jiffy use
staging: lustre: selftest: fix time reporting
Lots of nice improvements in there - thanks.
I've applied all patches, though I made small changed to the first as described separately.
Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180625/8baaf29f/attachment.sig>