diff options
author | Tina Ruchandani <ruchandani.tina@gmail.com> | 2014-10-30 22:35:01 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-10-30 22:41:59 +0100 |
commit | 9056be30542bfff51190bdda67088f319cf4c9f5 (patch) | |
tree | 188e27d7ab51cb974b8ef7d92084a9232701a157 | |
parent | staging: unisys: virtpci: Adjust lines to contain a maximum of 80 characters (diff) | |
download | linux-9056be30542bfff51190bdda67088f319cf4c9f5.tar.xz linux-9056be30542bfff51190bdda67088f319cf4c9f5.zip |
Staging: lustre: lnet: lnet: Better cookie gen
api-ni.c uses do_gettimeofday to get a 'cookie' or timestamp.
This patch replaces it with ktime_get_ns for the following reasons:
1. ktime_get_ns returns a __u64 which is safer than 'struct timeval'
which will overflow on 32-bit systems in year 2038 and beyond.
2. Improved resolution: nsecs instead of usecs.
3. Reduced compute: ktime_get_ns is faster than the multiply/add
combination used in this function
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/api-ni.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 60bc2ae4fdf1..5e6e4e22ed31 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -37,6 +37,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" #include <linux/log2.h> +#include <linux/ktime.h> #define D_LNI D_CONSOLE @@ -417,17 +418,9 @@ static __u64 lnet_create_interface_cookie(void) { /* NB the interface cookie in wire handles guards against delayed - * replies and ACKs appearing valid after reboot. Initialisation time, - * even if it's only implemented to millisecond resolution is probably - * easily good enough. */ - struct timeval tv; - __u64 cookie; - - do_gettimeofday(&tv); - cookie = tv.tv_sec; - cookie *= 1000000; - cookie += tv.tv_usec; - return cookie; + * replies and ACKs appearing valid after reboot. + */ + return ktime_get_ns(); } static char * |