AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
ktime_get_ts64, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
struct timespec64 *ts = NULL;
AC_DEFUN([LIBCFS_KTIME_ADD],[
LB_CHECK_COMPILE([does function 'ktime_add' exist],
ktime_add, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
ktime_t start = ktime_set(0, 0);
AC_DEFUN([LIBCFS_KTIME_AFTER],[
LB_CHECK_COMPILE([does function 'ktime_after' exist],
ktime_after, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
ktime_t start = ktime_set(0, 0);
AC_DEFUN([LIBCFS_KTIME_BEFORE],[
LB_CHECK_COMPILE([does function 'ktime_before' exist],
ktime_before, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
ktime_t start = ktime_set(0, 0);
AC_DEFUN([LIBCFS_KTIME_COMPARE],[
LB_CHECK_COMPILE([does function 'ktime_compare' exist],
ktime_compare, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
ktime_t start = ktime_set(0, 0);
AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
ktime_get_real_seconds, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
time64_t now;
AC_DEFUN([LIBCFS_KTIME_GET_NS],[
LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
ktime_get_ns, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
u64 nanoseconds;
AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
ktime_get_real_ns, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
u64 nanoseconds;
AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
ktime_to_timespec64, [
+ #include <linux/hrtimer.h>
#include <linux/ktime.h>
],[
struct timespec64 ts;
]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
#
+# Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
+# introduced the helper function ktime_ms_delta.
+#
+AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
+LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
+ktime_ms_delta, [
+ #include <linux/ktime.h>
+],[
+ ktime_t start = ktime_set(0, 0);
+ ktime_t end = start;
+
+ ktime_ms_delta(start, end);
+],[
+ AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
+ ['ktime_ms_delta' is available])
+])
+]) # LIBCFS_KTIME_MS_DELTA
+
+#
# Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
# create per module locks which added kernel_param_[un]lock(). Older
# kernels you have to use __kernel_param_[un]lock(). In that case its
# 3.19
LIBCFS_KTIME_GET_SECONDS
LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
+# 4.0
+LIBCFS_KTIME_MS_DELTA
# 4.1
LIBCFS_KERNEL_PARAM_LOCK
# 4.2
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/jiffies.h>
+#include <linux/hrtimer.h>
#include <linux/types.h>
#include <linux/time.h>
#include <asm/div64.h>
}
#endif /* NEED_KTIME_GET_REAL_NS */
+#ifndef HAVE_KTIME_MS_DELTA
+static inline s64 ktime_ms_delta(const ktime_t later, const ktime_t earlier)
+{
+ return ktime_to_ms(ktime_sub(later, earlier));
+}
+#endif /* HAVE_KTIME_MS_DELTA */
+
#ifndef HAVE_KTIME_TO_TIMESPEC64
static inline struct timespec64 ktime_to_timespec64(ktime_t kt)
{
} od_stats;
/* configuration item(s) */
- int od_contention_time;
+ time64_t od_contention_time;
int od_lockless_truncate;
};
* True if locking against this stripe got -EUSERS.
*/
int oo_contended;
- cfs_time_t oo_contention_time;
+ ktime_t oo_contention_time;
#ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
/**
* IO context used for invariant checks in osc_lock_has_pages().
static inline void osc_object_set_contended(struct osc_object *obj)
{
- obj->oo_contention_time = cfs_time_current();
+ obj->oo_contention_time = ktime_get();
/* mb(); */
obj->oo_contended = 1;
}
/**
* Submit time - the time when the page is starting RPC. For debugging.
*/
- cfs_time_t ops_submit_time;
+ ktime_t ops_submit_time;
};
struct osc_brw_async_args {
struct obd_device *obd = m->private;
struct osc_device *od = obd2osc_dev(obd);
- seq_printf(m, "%u\n", od->od_contention_time);
+ seq_printf(m, "%lld\n", od->od_contention_time);
return 0;
}
struct obd_device *obd = m->private;
struct osc_device *od = obd2osc_dev(obd);
- seq_printf(m, "%u\n", od->od_contention_time);
+ seq_printf(m, "%lld\n", od->od_contention_time);
return 0;
}
ENTRY;
result = cl_page_make_ready(env, page, CRT_WRITE);
if (result == 0)
- opg->ops_submit_time = cfs_time_current();
+ opg->ops_submit_time = ktime_get();
RETURN(result);
}
/* Clear opg->ops_transfer_pinned before VM lock is released. */
opg->ops_transfer_pinned = 0;
- opg->ops_submit_time = 0;
+ opg->ops_submit_time = ktime_set(0, 0);
srvlock = oap->oap_brw_flags & OBD_BRW_SRVLOCK;
/* statistic */
int osc_object_is_contended(struct osc_object *obj)
{
- struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
- int osc_contention_time = dev->od_contention_time;
- cfs_time_t cur_time = cfs_time_current();
- cfs_time_t retry_time;
+ struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
+ time64_t osc_contention_time = dev->od_contention_time;
+ ktime_t retry_time;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
return 1;
if (!obj->oo_contended)
return 0;
- /*
- * I like copy-paste. the code is copied from
- * ll_file_is_contended.
- */
- retry_time = cfs_time_add(obj->oo_contention_time,
- cfs_time_seconds(osc_contention_time));
- if (cfs_time_after(cur_time, retry_time)) {
- osc_object_clear_contended(obj);
- return 0;
- }
- return 1;
+ /*
+ * I like copy-paste. the code is copied from
+ * ll_file_is_contended.
+ */
+ retry_time = ktime_add_ns(obj->oo_contention_time,
+ osc_contention_time * NSEC_PER_SEC);
+ if (ktime_after(ktime_get(), retry_time)) {
+ osc_object_clear_contended(obj);
+ return 0;
+ }
+ return 1;
}
EXPORT_SYMBOL(osc_object_is_contended);
return list_empty(head) ? "-" : "+";
}
-static inline cfs_time_t osc_submit_duration(struct osc_page *opg)
+static inline s64 osc_submit_duration(struct osc_page *opg)
{
- if (opg->ops_submit_time == 0)
- return 0;
+ if (ktime_to_ns(opg->ops_submit_time) == 0)
+ return 0;
- return (cfs_time_current() - opg->ops_submit_time);
+ return ktime_ms_delta(ktime_get(), opg->ops_submit_time);
}
static int osc_page_print(const struct lu_env *env,
return (*printer)(env, cookie, LUSTRE_OSC_NAME"-page@%p %lu: "
"1< %#x %d %u %s %s > "
"2< %lld %u %u %#x %#x | %p %p %p > "
- "3< %d %lu %d > "
+ "3< %d %lld %d > "
"4< %d %d %d %lu %s | %s %s %s %s > "
"5< %s %s %s %s | %d %s | %d %s %s>\n",
opg, osc_index(opg),
oap->oap_cmd |= OBD_BRW_NOQUOTA;
}
- opg->ops_submit_time = cfs_time_current();
+ opg->ops_submit_time = ktime_get();
osc_page_transfer_get(opg, "transfer\0imm");
osc_page_transfer_add(env, opg, crt);
}