aoe: use ktime_t instead of timeval
Subsystems (2)
PATCH RESEND 1/1 aoe: use ktime_t instead of timeval
From: Tina Ruchandani <[email protected]>
'struct frame' uses two variables to store the sent timestamp - 'struct timeval' and jiffies. jiffies is used to avoid discrepancies caused by updates to system time. 'struct timeval' is deprecated because it uses 32-bit representation for seconds which will overflow in year 2038.
This patch does the following:
- Replace the use of 'struct timeval' and jiffies with ktime_t, which is the recommended type for timestamping
- ktime_t provides both long range (like jiffies) and high resolution (like timeval). Using ktime_get (monotonic time) instead of wall-clock time prevents any discprepancies caused by updates to system time.
[updates by Arnd below]
The original patch from Tina never went anywhere as we discussed how to keep the impact on performance minimal. I've started over now but arrived at basically the same patch that she had originally, except for an slightly improved tsince_hr() function. I'm making it more robust against overflows, and also optimize explicitly for the common case in which a frame is less than 4.2 seconds old, using only a 32-bit division in that case.
This should make the new version more efficient than the old code, since we replace the existing two 32-bit division in do_gettimeofday() plus one multiplication with a single single 32-bit division in tsince_hr() and drop the double bookkeeping. It's also more efficient than the ktime_get_us() API we discussed before, since that would also rely on multiple divisions.
---
I submitted this version in November 2017, but got no reply from Ed. Jens, could you pick it up directly?
--- drivers/block/aoe/aoe.h | 3 +-- drivers/block/aoe/aoecmd.c | 48 +++++++++++++--------------------------------- 2 files changed, 14 insertions(+), 37 deletions(-)
drivers/block/aoe/aoe.h +1 -2
@@ -112,8 +112,7 @@ enum frame_flags {struct frame {struct list_head head;u32 tag; -struct timeval sent;/* high-res time packet was sent */ -u32 sent_jiffs;/* low-res jiffies-based sent time */ +ktime_t sent;/* high-res time packet was sent */ ulong waited;ulong waited_total;struct aoetgt *t;/* parent target I belong to */
drivers/block/aoe/aoecmd.c +13 -35
87 lines not on this page · raw message
Signature · 1 line
2.9.0
Quoted 23 lines · Arnd Bergmann
From: Tina Ruchandani <[email protected]>
'struct frame' uses two variables to store the sent timestamp - 'struct timeval' and jiffies. jiffies is used to avoid discrepancies caused by updates to system time. 'struct timeval' is deprecated because it uses 32-bit representation for seconds which will overflow in year 2038.
This patch does the following:
- Replace the use of 'struct timeval' and jiffies withktime_t, which is the recommended type for timestamping
-ktime_tprovides both long range (like jiffies) and high resolution (like timeval). Usingktime_get(monotonic time) instead of wall-clock time prevents any discprepancies caused by updates to system time.[updates by Arnd below]
The original patch from Tina never went anywhere as we discussed how to keep the impact on performance minimal. I've started over now but arrived at basically the same patch that she had originally, except for an slightly improvedtsince_hr()function. I'm making it more robust against overflows, and also optimize explicitly for the common case in which a frame is less than 4.2 seconds old, using only a 32-bit division in that case.
Quoted 6 lines
This should make the new version more efficient than the old code, since we replace the existing two 32-bit division in
do_gettimeofday()plus one multiplication with a single single 32-bit division intsince_hr()and drop the double bookkeeping. It's also more efficient than thektime_get_us()API we discussed before, since that would also rely on multiple divisions.
Applied, thanks Arnd/Tina.
Signature · 1 line
Jens Axboe
On 01/17/2018 10:41 AM, Jens Axboe wrote:
...
Quoted 1 line
Applied, thanks Arnd/Tina.
Thank you for the CC. Sorry for the lack of response in November.
Signature · 1 line
Ed