diff --git a/casadm/statistics_model.c b/casadm/statistics_model.c index 6b74f69..07ca37d 100644 --- a/casadm/statistics_model.c +++ b/casadm/statistics_model.c @@ -70,11 +70,11 @@ static float calc_gb(uint64_t clines) return (float) clines * 4 * KiB / GiB; } -static void print_dirty_for_time(uint32_t t, FILE *outfile) +static void print_dirty_for_time(uint64_t t, FILE *outfile) { uint32_t d, h, m, s; - fprintf(outfile, "%u,[s],", t); + fprintf(outfile, "%lu,[s],", t); if (!t) { fprintf(outfile, "Cache clean"); @@ -112,7 +112,7 @@ static void print_kv_pair(FILE *outfile, const char *title, const char *fmt, ... fprintf(outfile, "\n"); } -static void print_kv_pair_time(FILE *outfile, const char *title, uint32_t time) +static void print_kv_pair_time(FILE *outfile, const char *title, uint64_t time) { fprintf(outfile, TAG(KV_PAIR) "\"%s\",", title); print_dirty_for_time(time, outfile); diff --git a/configure.d/1_timekeeping.conf b/configure.d/1_timekeeping.conf new file mode 100644 index 0000000..372e2ff --- /dev/null +++ b/configure.d/1_timekeeping.conf @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Copyright(c) 2012-2021 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +. $(dirname $3)/conf_framework + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "ktime_get_real_ts64(NULL)" "linux/ktime.h" + then + echo $cur_name "1" >> $config_file_path + else + echo $cur_name "2" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_GET_CURRENT_TIME(timespec) ktime_get_real_ts64(timespec)" ;; + "2") + add_define "CAS_GET_CURRENT_TIME(timespec) getnstimeofday(timespec)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/modules/cas_cache/linux_kernel_version.h b/modules/cas_cache/linux_kernel_version.h index 4520e43..40dd497 100644 --- a/modules/cas_cache/linux_kernel_version.h +++ b/modules/cas_cache/linux_kernel_version.h @@ -39,6 +39,7 @@ #include #include #include +#include #include "generated_defines.h" diff --git a/modules/cas_cache/ocf_env.h b/modules/cas_cache/ocf_env.h index 46721d2..d879b04 100644 --- a/modules/cas_cache/ocf_env.h +++ b/modules/cas_cache/ocf_env.h @@ -533,23 +533,40 @@ static inline void env_cond_resched(void) static inline int env_in_interrupt(void) { - return in_interrupt();; + return in_interrupt(); } /* *** TIME *** */ static inline uint64_t env_get_tick_count(void) { - return jiffies; -} - -static inline uint64_t env_ticks_to_msecs(uint64_t j) -{ - return jiffies_to_msecs(j); + struct timespec64 ts; + CAS_GET_CURRENT_TIME(&ts); + return ts.tv_sec * 1000000000UL + ts.tv_nsec; } static inline uint64_t env_ticks_to_nsecs(uint64_t j) { - return jiffies_to_usecs(j) * NSEC_PER_USEC; + return j; +} + +static inline uint64_t env_ticks_to_usecs(uint64_t j) +{ + return j / 1000UL; +} + +static inline uint64_t env_ticks_to_msecs(uint64_t j) +{ + return j / 1000000UL; +} + +static inline uint64_t env_ticks_to_secs(uint64_t j) +{ + return j / 1000000000UL; +} + +static inline uint64_t env_secs_to_ticks(uint64_t j) +{ + return j * 1000000000UL; } static inline bool env_time_after(uint64_t a, uint64_t b) @@ -557,14 +574,9 @@ static inline bool env_time_after(uint64_t a, uint64_t b) return time_after64(a,b); } -static inline uint64_t env_ticks_to_secs(uint64_t j) +static inline void env_msleep(uint64_t n) { - return j >> SHIFT_HZ; -} - -static inline uint64_t env_secs_to_ticks(uint64_t j) -{ - return j << SHIFT_HZ; + msleep(n); } /* *** BIT OPERATIONS *** */ @@ -584,11 +596,6 @@ static inline int env_bit_test(int nr, const void *addr) return test_bit(nr, addr); } -static inline void env_msleep(uint64_t n) -{ - msleep(n); -} - /* *** STRING OPERATIONS *** */