drivers: s390: net: ctcm: migrate variables to handle y2038 problem
Subsystems (3)
PATCH v2 1/1 drivers: s390: net: ctcm: migrate variables to handle y2038 problem
This patch is concerned with migrating the time variables for the s390 network driver. The changes handle the y2038 problem where timespec will overflow in the year 2038. timespec was replaced by unsigned long and all time variables get their values from the jiffies global variable. This was done for the sake of speed and efficiency.
---
v1: Arnd has advised me to provide you with options for time
calculation. The first option: "accuracy" is used in this patch. The second option: "speed" can be done through jiffies.
v2: Moved on to the speed option. Let me know if I explicitly
need to include the jiffies header. The module compiles with no problems on my side.
drivers/s390/net/ctcm_fsms.c | 18 +++++++----------- drivers/s390/net/ctcm_main.h | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-)
drivers/s390/net/ctcm_fsms.c +7 -11
@@ -251,13 +251,11 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)int first =1 ;int i;unsigned long duration; -struct timespec done_stamp =current_kernel_time ();/* xtime */ +unsigned long done_stamp = jiffies;CTCM_PR_DEBUG ("%s(%s): %s\n" , __func__, ch->id, dev->name); - duration = - (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) *1000000 + - (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) /1000 ; + duration =time_before (done_stamp, ch->prof.send_stamp);if (duration > ch->prof.tx_time) ch->prof.tx_time = duration;
@@ -307,7 +305,7 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)spin_unlock (&ch->collect_lock); ch->ccw[1 ].count = ch->trans_skb->len;fsm_addtimer (&ch->timer,CTCM_TIME_5_SEC ,CTC_EVENT_TIMER , ch); - ch->prof.send_stamp =current_kernel_time ();/* xtime */ + ch->prof.send_stamp = jiffies; rc =ccw_device_start (ch->cdev, &ch->ccw[0 ], (unsigned long )ch,0xff ,0 ); ch->prof.doios_multi++;
@@ -1229,14 +1227,12 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)int rc;struct th_header *header;struct pdu *p_header; -struct timespec done_stamp =current_kernel_time ();/* xtime */ +unsigned long done_stamp = jiffies;CTCM_PR_DEBUG ("Enter %s: %s cp:%i\n" , __func__, dev->name,smp_processor_id ()); - duration = - (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) *1000000 + - (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) /1000 ; + duration =time_before (done_stamp, ch->prof.send_stamp);if (duration > ch->prof.tx_time) ch->prof.tx_time = duration;
@@ -1361,7 +1357,7 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ch->ccw[1 ].count = ch->trans_skb->len;fsm_addtimer (&ch->timer,CTCM_TIME_5_SEC ,CTC_EVENT_TIMER , ch); - ch->prof.send_stamp =current_kernel_time ();/* xtime */ + ch->prof.send_stamp = jiffies;if (do_debug_ccw)ctcmpc_dumpit ((char *)&ch->ccw[0 ],sizeof (struct ccw1 ) *3 ); rc = ccw_device_start(ch->cdev, &ch->ccw[0],
@@ -1827,7 +1823,7 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg)fsm_newstate (wch->fsm,CTC_STATE_TX );spin_lock_irqsave (get_ccwdev_lock (wch->cdev), saveflags); - wch->prof.send_stamp =current_kernel_time ();/* xtime */ + wch->prof.send_stamp = jiffies; rc =ccw_device_start (wch->cdev, &wch->ccw[3 ], (unsigned long ) wch,0xff ,0 );spin_unlock_irqrestore (get_ccwdev_lock (wch->cdev), saveflags);
drivers/s390/net/ctcm_main.h +1 -1
@@ -121,7 +121,7 @@ struct ctcm_profile {unsigned long doios_multi;unsigned long txlen;unsigned long tx_time; -struct timespec send_stamp; +unsigned long send_stamp; };/*
Signature · 1 line
1.9.3
thanks, Aya. I miss drivers/s390/net/ctcm_main.c in your patch. And "time_before()" is not the right function to use here, because it returns a Bool value. Purpose of the ctcm timespec stuff is to determine the time interval between triggering the send operation and receiving the confirmation of the send operation. The maximum value is saved and can be displayed in the statistics.
Regards, Ursula Braun
Quoted 98 lines · Aya Mahfouz
This patch is concerned with migrating the time variables for the s390 network driver. The changes handle the y2038 problem where timespec will overflow in the year 2038. timespec was replaced by unsigned long and all time variables get their values from the jiffies global variable. This was done for the sake of speed and efficiency.
Signed-off-by Aya Mahfouz <[email protected]>---
v1: Arnd has advised me to provide you with options for time
calculation. The first option: "accuracy" is used in this patch. The second option: "speed" can be done through jiffies.v2: Moved on to the speed option. Let me know if I explicitly
need to include the jiffies header. The module compiles with no problems on my side.drivers/s390/net/ctcm_fsms.c | 18 +++++++----------- drivers/s390/net/ctcm_main.h | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-)drivers/s390/net/ctcm_fsms.c +7
-11@@ -251,13 +251,11 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)int first =1 ;int i;unsigned long duration; -struct timespec done_stamp =current_kernel_time ();/* xtime */ +unsigned long done_stamp = jiffies;CTCM_PR_DEBUG ("%s(%s): %s\n" , __func__, ch->id, dev->name); - duration = - (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) *1000000 + - (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) /1000 ; + duration =time_before (done_stamp, ch->prof.send_stamp);if (duration > ch->prof.tx_time) ch->prof.tx_time = duration;@@ -307,7 +305,7 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)spin_unlock (&ch->collect_lock); ch->ccw[1 ].count = ch->trans_skb->len;fsm_addtimer (&ch->timer,CTCM_TIME_5_SEC ,CTC_EVENT_TIMER , ch); - ch->prof.send_stamp =current_kernel_time ();/* xtime */ + ch->prof.send_stamp = jiffies; rc =ccw_device_start (ch->cdev, &ch->ccw[0 ], (unsigned long )ch,0xff ,0 ); ch->prof.doios_multi++;@@ -1229,14 +1227,12 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)int rc;struct th_header *header;struct pdu *p_header; -struct timespec done_stamp =current_kernel_time ();/* xtime */ +unsigned long done_stamp = jiffies;CTCM_PR_DEBUG ("Enter %s: %s cp:%i\n" , __func__, dev->name,smp_processor_id ()); - duration = - (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) *1000000 + - (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) /1000 ; + duration =time_before (done_stamp, ch->prof.send_stamp);if (duration > ch->prof.tx_time) ch->prof.tx_time = duration;@@ -1361,7 +1357,7 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ch->ccw[1 ].count = ch->trans_skb->len;fsm_addtimer (&ch->timer,CTCM_TIME_5_SEC ,CTC_EVENT_TIMER , ch); - ch->prof.send_stamp =current_kernel_time ();/* xtime */ + ch->prof.send_stamp = jiffies;if (do_debug_ccw)ctcmpc_dumpit ((char *)&ch->ccw[0 ],sizeof (struct ccw1 ) *3 ); rc = ccw_device_start(ch->cdev, &ch->ccw[0],@@ -1827,7 +1823,7 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg)fsm_newstate (wch->fsm,CTC_STATE_TX );spin_lock_irqsave (get_ccwdev_lock (wch->cdev), saveflags); - wch->prof.send_stamp =current_kernel_time ();/* xtime */ + wch->prof.send_stamp = jiffies; rc =ccw_device_start (wch->cdev, &wch->ccw[3 ], (unsigned long ) wch,0xff ,0 );spin_unlock_irqrestore (get_ccwdev_lock (wch->cdev), saveflags);drivers/s390/net/ctcm_main.h +1
-1@@ -121,7 +121,7 @@ struct ctcm_profile {unsigned long doios_multi;unsigned long txlen;unsigned long tx_time; -struct timespec send_stamp; +unsigned long send_stamp; };/*
Quoted 1 line · Ursula Braun
thanks, Aya. I miss
drivers/s390/net/ctcm_main.cin your patch. And
Hello Ursula,
ok. I will see what needs to do in it. I did not change it.
Quoted 5 lines
"
time_before()" is not the right function to use here, because it returns a Bool value. Purpose of the ctcm timespec stuff is to determine the time interval between triggering the send operation and receiving the confirmation of the send operation. The maximum value is saved and can be displayed in the statistics.
Yes, you're right. I will fix that. Sorry!
Quoted 3 lines
Regards, Ursula Braun
Kind Regards,
Aya Saif El-yazal Mahfouz
Quoted 101 lines · Aya Mahfouz
Quoted 98 lines
This patch is concerned with migrating the time variables for the s390 network driver. The changes handle the y2038 problem where timespec will overflow in the year 2038. timespec was replaced by unsigned long and all time variables get their values from the jiffies global variable. This was done for the sake of speed and efficiency.
Signed-off-by Aya Mahfouz <[email protected]>---
v1: Arnd has advised me to provide you with options for time
calculation. The first option: "accuracy" is used in this patch. The second option: "speed" can be done through jiffies.v2: Moved on to the speed option. Let me know if I explicitly
need to include the jiffies header. The module compiles with no problems on my side.drivers/s390/net/ctcm_fsms.c | 18 +++++++----------- drivers/s390/net/ctcm_main.h | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-)drivers/s390/net/ctcm_fsms.c +7
-11@@ -251,13 +251,11 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)int first =1 ;int i;unsigned long duration; -struct timespec done_stamp =current_kernel_time ();/* xtime */ +unsigned long done_stamp = jiffies;CTCM_PR_DEBUG ("%s(%s): %s\n" , __func__, ch->id, dev->name); - duration = - (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) *1000000 + - (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) /1000 ; + duration =time_before (done_stamp, ch->prof.send_stamp);if (duration > ch->prof.tx_time) ch->prof.tx_time = duration;@@ -307,7 +305,7 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)spin_unlock (&ch->collect_lock); ch->ccw[1 ].count = ch->trans_skb->len;fsm_addtimer (&ch->timer,CTCM_TIME_5_SEC ,CTC_EVENT_TIMER , ch); - ch->prof.send_stamp =current_kernel_time ();/* xtime */ + ch->prof.send_stamp = jiffies; rc =ccw_device_start (ch->cdev, &ch->ccw[0 ], (unsigned long )ch,0xff ,0 ); ch->prof.doios_multi++;@@ -1229,14 +1227,12 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)int rc;struct th_header *header;struct pdu *p_header; -struct timespec done_stamp =current_kernel_time ();/* xtime */ +unsigned long done_stamp = jiffies;CTCM_PR_DEBUG ("Enter %s: %s cp:%i\n" , __func__, dev->name,smp_processor_id ()); - duration = - (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) *1000000 + - (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) /1000 ; + duration =time_before (done_stamp, ch->prof.send_stamp);if (duration > ch->prof.tx_time) ch->prof.tx_time = duration;@@ -1361,7 +1357,7 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ch->ccw[1 ].count = ch->trans_skb->len;fsm_addtimer (&ch->timer,CTCM_TIME_5_SEC ,CTC_EVENT_TIMER , ch); - ch->prof.send_stamp =current_kernel_time ();/* xtime */ + ch->prof.send_stamp = jiffies;if (do_debug_ccw)ctcmpc_dumpit ((char *)&ch->ccw[0 ],sizeof (struct ccw1 ) *3 ); rc = ccw_device_start(ch->cdev, &ch->ccw[0],@@ -1827,7 +1823,7 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg)fsm_newstate (wch->fsm,CTC_STATE_TX );spin_lock_irqsave (get_ccwdev_lock (wch->cdev), saveflags); - wch->prof.send_stamp =current_kernel_time ();/* xtime */ + wch->prof.send_stamp = jiffies; rc =ccw_device_start (wch->cdev, &wch->ccw[3 ], (unsigned long ) wch,0xff ,0 );spin_unlock_irqrestore (get_ccwdev_lock (wch->cdev), saveflags);drivers/s390/net/ctcm_main.h +1
-1@@ -121,7 +121,7 @@ struct ctcm_profile {unsigned long doios_multi;unsigned long txlen;unsigned long tx_time; -struct timespec send_stamp; +unsigned long send_stamp; };/*