diff --git a/inc/ocf_trace.h b/inc/ocf_trace.h index 3971427..92439cf 100644 --- a/inc/ocf_trace.h +++ b/inc/ocf_trace.h @@ -172,7 +172,7 @@ typedef void (*ocf_trace_callback_t)(ocf_cache_t cache, void *trace_ctx, * @retval 0 Tracing started successfully * @retval Non-zero Error */ -int ocf_mgnt_start_trace(ocf_cache_t cache, void *trace_ctx, +int ocf_mngt_start_trace(ocf_cache_t cache, void *trace_ctx, ocf_trace_callback_t trace_callback); /** @@ -183,6 +183,6 @@ int ocf_mgnt_start_trace(ocf_cache_t cache, void *trace_ctx, * @retval 0 Tracing stopped successfully * @retval Non-zero Error */ -int ocf_mgnt_stop_trace(ocf_cache_t cache); +int ocf_mngt_stop_trace(ocf_cache_t cache); #endif /* __OCF_TRACE_H__ */ diff --git a/src/ocf_cache_priv.h b/src/ocf_cache_priv.h index bfe735b..30d98cc 100644 --- a/src/ocf_cache_priv.h +++ b/src/ocf_cache_priv.h @@ -27,10 +27,10 @@ */ struct ocf_trace { /* Placeholder for push_event callback */ - volatile ocf_trace_callback_t trace_callback; + ocf_trace_callback_t trace_callback; /* Telemetry context */ - volatile void *trace_ctx; + void *trace_ctx; env_atomic64 trace_seq_ref; }; diff --git a/src/ocf_trace.c b/src/ocf_trace.c index 520c80b..fc92cea 100644 --- a/src/ocf_trace.c +++ b/src/ocf_trace.c @@ -24,7 +24,9 @@ static int _ocf_core_desc(ocf_core_t core, void *ctx) ocf_cache_t cache = visitor_ctx->cache; ocf_event_init_hdr(&core_desc.hdr, ocf_event_type_core_desc, - ocf_trace_seq_id(cache), env_get_tick_ns(), sizeof(core_desc)); + ocf_trace_seq_id(cache), + env_ticks_to_nsecs(env_get_tick_count()), + sizeof(core_desc)); core_desc.id = ocf_core_get_id(core); core_desc.core_size = ocf_dobj_get_length( ocf_core_get_data_object(core)); @@ -42,7 +44,9 @@ static int _ocf_trace_cache_info(ocf_cache_t cache, uint32_t io_queue) struct core_trace_visitor_ctx visitor_ctx; ocf_event_init_hdr(&cache_desc.hdr, ocf_event_type_cache_desc, - ocf_trace_seq_id(cache), env_get_tick_ns(), sizeof(cache_desc)); + ocf_trace_seq_id(cache), + env_ticks_to_nsecs(env_get_tick_count()), + sizeof(cache_desc)); cache_desc.id = ocf_cache_get_id(cache); cache_desc.cache_line_size = ocf_cache_get_line_size(cache); @@ -70,10 +74,10 @@ static int _ocf_trace_cache_info(ocf_cache_t cache, uint32_t io_queue) return retval; } -int ocf_mgnt_start_trace(ocf_cache_t cache, void *trace_ctx, +int ocf_mngt_start_trace(ocf_cache_t cache, void *trace_ctx, ocf_trace_callback_t trace_callback) { - int result; + int queue, result; uint32_t i; OCF_CHECK_NULL(cache); @@ -98,9 +102,8 @@ int ocf_mgnt_start_trace(ocf_cache_t cache, void *trace_ctx, cache->trace.trace_ctx = trace_ctx; // Reset trace stop flag - for (int queue = 0; queue < cache->io_queues_no; queue++) { + for (queue = 0; queue < cache->io_queues_no; queue++) env_atomic_set(&cache->io_queues[queue].trace_stop, 0); - } for (i = 0; i < cache->io_queues_no; i++) { result = _ocf_trace_cache_info(cache, i); @@ -121,9 +124,9 @@ trace_deinit: return result; } -int ocf_mgnt_stop_trace(ocf_cache_t cache) +int ocf_mngt_stop_trace(ocf_cache_t cache) { - int result; + int queue, result; result = ocf_mngt_cache_lock(cache); if (result) @@ -138,8 +141,9 @@ int ocf_mgnt_stop_trace(ocf_cache_t cache) } // Set trace stop flag - for (int queue = 0; queue < cache->io_queues_no; queue++) { - env_atomic_set(&cache->io_queues[queue].trace_stop, OCF_TRACING_STOP); + for (queue = 0; queue < cache->io_queues_no; queue++) { + env_atomic_set(&cache->io_queues[queue].trace_stop, + OCF_TRACING_STOP); } cache->trace.trace_callback = NULL; diff --git a/src/ocf_trace_priv.h b/src/ocf_trace_priv.h index d447285..a9645bc 100644 --- a/src/ocf_trace_priv.h +++ b/src/ocf_trace_priv.h @@ -6,6 +6,8 @@ #ifndef __OCF_TRACE_PRIV_H__ #define __OCF_TRACE_PRIV_H__ +#include "ocf/ocf.h" +#include "ocf_env.h" #include "ocf/ocf_trace.h" #include "engine/engine_common.h" #include "ocf_request.h" @@ -14,10 +16,11 @@ static inline bool ocf_is_trace_ongoing(ocf_cache_t cache) { - for (int i = 0; i < cache->io_queues_no; i++) { - if (env_atomic64_read(&cache->io_queues[i].trace_ref_cntr)) { + int i; + + for (i = 0; i < cache->io_queues_no; i++) { + if (env_atomic64_read(&cache->io_queues[i].trace_ref_cntr)) return true; - } } return false; @@ -39,7 +42,7 @@ static inline uint64_t ocf_trace_seq_id(ocf_cache_t cache) static inline void ocf_trace_init_io(struct ocf_core_io *io, ocf_cache_t cache) { - io->timestamp = env_get_tick_ns(); + io->timestamp = env_ticks_to_nsecs(env_get_tick_count()); io->sid = ocf_trace_seq_id(cache); } @@ -120,7 +123,9 @@ static inline void ocf_trace_io_cmpl(struct ocf_core_io *io, ocf_cache_t cache) rq = io->req; ocf_event_init_hdr(&ev.hdr, ocf_event_type_io_cmpl, - ocf_trace_seq_id(cache), env_get_tick_ns(), sizeof(ev)); + ocf_trace_seq_id(cache), + env_ticks_to_nsecs(env_get_tick_count()), + sizeof(ev)); ev.rsid = io->sid; ev.is_hit = ocf_engine_is_hit(rq);