Unify type of dirty_for
in info structs
Reformat function that calculates how long cache/core is dirty Update `dirty_for` types in functional tests Values stored in info structs fields (both in cache and core structs) are unsigned 64-bits ints but `dirty_for`s were unsigned 32-bits ints. Use existing function to transform returned value to seconds. Replace seconds stored in metadata with seconds. Replacement was done if old value of replaced field was equal to zero. Acquiring monotonic high precission timestamp is potentially slow and it makes sense to compare the field's value to zero before calling atomic function. Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
parent
9dba49192f
commit
eeda1f3f0f
@ -53,7 +53,7 @@ struct ocf_cache_info {
|
|||||||
* out of WB mode
|
* out of WB mode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32_t dirty_for;
|
uint64_t dirty_for;
|
||||||
/*!< How long there are dirty cache lines (in seconds) */
|
/*!< How long there are dirty cache lines (in seconds) */
|
||||||
|
|
||||||
ocf_cache_mode_t cache_mode;
|
ocf_cache_mode_t cache_mode;
|
||||||
|
@ -32,7 +32,7 @@ struct ocf_core_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** How long core is dirty in seconds unit */
|
/** How long core is dirty in seconds unit */
|
||||||
uint32_t dirty_for;
|
uint64_t dirty_for;
|
||||||
|
|
||||||
/** Sequential cutoff threshold (in bytes) */
|
/** Sequential cutoff threshold (in bytes) */
|
||||||
uint32_t seq_cutoff_threshold;
|
uint32_t seq_cutoff_threshold;
|
||||||
|
@ -1192,8 +1192,9 @@ static void _recovery_rebuild_cline_metadata(ocf_cache_t cache,
|
|||||||
env_atomic_inc(&core->runtime_meta->dirty_clines);
|
env_atomic_inc(&core->runtime_meta->dirty_clines);
|
||||||
env_atomic_inc(&core->runtime_meta->
|
env_atomic_inc(&core->runtime_meta->
|
||||||
part_counters[part_id].dirty_clines);
|
part_counters[part_id].dirty_clines);
|
||||||
env_atomic64_cmpxchg(&core->runtime_meta->dirty_since,
|
if (!env_atomic64_read(&core->runtime_meta->dirty_since))
|
||||||
0, env_get_tick_count());
|
env_atomic64_cmpxchg(&core->runtime_meta->dirty_since, 0,
|
||||||
|
env_ticks_to_secs(env_get_tick_count()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ ocf_cache_mode_t ocf_cache_get_mode(ocf_cache_t cache)
|
|||||||
return cache->conf_meta->cache_mode;
|
return cache->conf_meta->cache_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t _calc_dirty_for(uint64_t dirty_since)
|
static uint64_t _calc_dirty_for(uint64_t dirty_since)
|
||||||
{
|
{
|
||||||
return dirty_since ?
|
uint64_t current_time = env_ticks_to_secs(env_get_tick_count());
|
||||||
(env_ticks_to_msecs(env_get_tick_count() - dirty_since) / 1000)
|
|
||||||
: 0;
|
return dirty_since ? (current_time - dirty_since) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
|
int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
|
||||||
|
@ -142,11 +142,11 @@ int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
|
|||||||
|
|
||||||
/* *** HELPER FUNCTIONS *** */
|
/* *** HELPER FUNCTIONS *** */
|
||||||
|
|
||||||
static uint32_t _calc_dirty_for(uint64_t dirty_since)
|
static uint64_t _calc_dirty_for(uint64_t dirty_since)
|
||||||
{
|
{
|
||||||
return dirty_since ?
|
uint64_t current_time = env_ticks_to_secs(env_get_tick_count());
|
||||||
(env_ticks_to_msecs(env_get_tick_count() - dirty_since) / 1000)
|
|
||||||
: 0;
|
return dirty_since ? (current_time - dirty_since) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct ocf_request *ocf_io_to_req(struct ocf_io *io)
|
static inline struct ocf_request *ocf_io_to_req(struct ocf_io *io)
|
||||||
|
@ -156,8 +156,10 @@ void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
|
|||||||
/*
|
/*
|
||||||
* If this is first dirty cline set dirty timestamp
|
* If this is first dirty cline set dirty timestamp
|
||||||
*/
|
*/
|
||||||
env_atomic64_cmpxchg(&req->core->runtime_meta->dirty_since,
|
if (!env_atomic64_read(&req->core->runtime_meta->dirty_since))
|
||||||
0, env_get_tick_count());
|
env_atomic64_cmpxchg(
|
||||||
|
&req->core->runtime_meta->dirty_since, 0,
|
||||||
|
env_ticks_to_secs(env_get_tick_count()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the number of dirty cached data for that
|
* Update the number of dirty cached data for that
|
||||||
|
@ -24,7 +24,7 @@ class CacheInfo(Structure):
|
|||||||
("occupancy", c_uint32),
|
("occupancy", c_uint32),
|
||||||
("dirty", c_uint32),
|
("dirty", c_uint32),
|
||||||
("dirty_initial", c_uint32),
|
("dirty_initial", c_uint32),
|
||||||
("dirty_for", c_uint32),
|
("dirty_for", c_uint64),
|
||||||
("cache_mode", c_uint32),
|
("cache_mode", c_uint32),
|
||||||
("fallback_pt", _FallbackPt),
|
("fallback_pt", _FallbackPt),
|
||||||
("state", c_uint8),
|
("state", c_uint8),
|
||||||
|
@ -15,7 +15,7 @@ class CoreInfo(Structure):
|
|||||||
("core_size_bytes", c_uint64),
|
("core_size_bytes", c_uint64),
|
||||||
("dirty", c_uint32),
|
("dirty", c_uint32),
|
||||||
("flushed", c_uint32),
|
("flushed", c_uint32),
|
||||||
("dirty_for", c_uint32),
|
("dirty_for", c_uint64),
|
||||||
("seq_cutoff_threshold", c_uint32),
|
("seq_cutoff_threshold", c_uint32),
|
||||||
("seq_cutoff_policy", c_uint32),
|
("seq_cutoff_policy", c_uint32),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user