Whamcloud - gitweb
LU-5443 libcfs: replace direct HZ access with kernel APIs 93/11993/11
authorJian Yu <jian.yu@intel.com>
Tue, 18 Nov 2014 02:32:20 +0000 (18:32 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 Dec 2014 08:10:31 +0000 (08:10 +0000)
commit3af952524b8de40537f7630fb600a73db3626bd7
tree3e993685d8c214c604fa97b7c80d69d6fc376e8e
parentad06e5506388a02ee388fe47bbf8e8bc048d705e
LU-5443 libcfs: replace direct HZ access with kernel APIs

On some customer's systems, kernel was compiled with HZ defined to
100, instead of 1000. This improves performance for HPC applications.
However, to use these systems with Lustre, customers have to re-build
Lustre for the kernel because Lustre directly uses the defined
constant HZ.

Since kernel 2.6.21, some non-HZ dependent timing APIs become non-
inline functions, which can be used in Lustre codes to replace the
direct HZ access.

These kernel APIs include:
 jiffies_to_msecs()
 jiffies_to_usecs()
 jiffies_to_timespec()
 msecs_to_jiffies()
 usecs_to_jiffies()
 timespec_to_jiffies()

And here are some samples of the replacement:
 HZ            -> msecs_to_jiffies(MSEC_PER_SEC)
 n * HZ        -> msecs_to_jiffies(n * MSEC_PER_SEC)
 HZ / n        -> msecs_to_jiffies(MSEC_PER_SEC / n)
 n / HZ        -> jiffies_to_msecs(n) / MSEC_PER_SEC
 n / HZ * 1000 -> jiffies_to_msecs(n)

This patch replaces the direct HZ access in libcfs module.

The patch also replaces ONE_BILLION with NSEC_PER_SEC,
and ONE_MILLION with USEC_PER_SEC in linux-time.h.

Signed-off-by: Jian Yu <jian.yu@intel.com>
Change-Id: I33846f378eb876cd8958ff0c397ffb56a552f256
Reviewed-on: http://review.whamcloud.com/11993
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/linux/linux-time.h
libcfs/libcfs/linux/linux-crypto.c
libcfs/libcfs/linux/linux-tcpip.c