Use time since epoch instead of jiffies
If time is counted in jiffies, machine reboot brokes `dirty for` statistic for caches loaded at boot. The counter overflows and `dirty for` shows some huge values. Cast ticks to unsigned long. Add necessary header. Move `env_msleep` to `TIME` subgroup of header. Move `env_time_after` below time converting functions. Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
parent
6c4bf5a9ba
commit
eef4e49904
@ -39,6 +39,7 @@
|
|||||||
#include <linux/ratelimit.h>
|
#include <linux/ratelimit.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/blk-mq.h>
|
#include <linux/blk-mq.h>
|
||||||
|
#include <linux/time.h>
|
||||||
|
|
||||||
#include "generated_defines.h"
|
#include "generated_defines.h"
|
||||||
|
|
||||||
|
@ -539,17 +539,34 @@ static inline int env_in_interrupt(void)
|
|||||||
/* *** TIME *** */
|
/* *** TIME *** */
|
||||||
static inline uint64_t env_get_tick_count(void)
|
static inline uint64_t env_get_tick_count(void)
|
||||||
{
|
{
|
||||||
return jiffies;
|
struct timespec ts;
|
||||||
}
|
getnstimeofday(&ts);
|
||||||
|
return ts.tv_sec * 1000000000UL + ts.tv_nsec;
|
||||||
static inline uint64_t env_ticks_to_msecs(uint64_t j)
|
|
||||||
{
|
|
||||||
return jiffies_to_msecs(j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t env_ticks_to_nsecs(uint64_t j)
|
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)
|
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);
|
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;
|
msleep(n);
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t env_secs_to_ticks(uint64_t j)
|
|
||||||
{
|
|
||||||
return j << SHIFT_HZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *** BIT OPERATIONS *** */
|
/* *** BIT OPERATIONS *** */
|
||||||
@ -584,11 +596,6 @@ static inline int env_bit_test(int nr, const void *addr)
|
|||||||
return test_bit(nr, addr);
|
return test_bit(nr, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_msleep(uint64_t n)
|
|
||||||
{
|
|
||||||
msleep(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* *** STRING OPERATIONS *** */
|
/* *** STRING OPERATIONS *** */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user