diff --git a/inc/ocf_debug.h b/inc/ocf_debug.h new file mode 100644 index 0000000..9cd2c1f --- /dev/null +++ b/inc/ocf_debug.h @@ -0,0 +1,21 @@ +/* + * Copyright(c) 2012-2018 Intel Corporation + * SPDX-License-Identifier: BSD-3-Clause-Clear + */ + +#ifndef __OCF_DEBUG_H__ +#define __OCF_DEBUG_H__ + +struct ocf_dbg_seq_cutoff_status { + struct { + uint64_t last; + uint64_t bytes; + uint32_t rw : 1; + uint32_t active : 1; + } streams[OCF_SEQ_CUTOFF_MAX_STREAMS]; +}; + +void ocf_dbg_get_seq_cutoff_status(ocf_core_t core, + struct ocf_dbg_seq_cutoff_status *status); + +#endif /* __OCF_DEBUG_H__ */ diff --git a/src/ocf_seq_cutoff.c b/src/ocf_seq_cutoff.c index 13553c4..c8df601 100644 --- a/src/ocf_seq_cutoff.c +++ b/src/ocf_seq_cutoff.c @@ -6,6 +6,7 @@ #include "ocf_seq_cutoff.h" #include "ocf_cache_priv.h" #include "ocf_priv.h" +#include "ocf/ocf_debug.h" #define SEQ_CUTOFF_FULL_MARGIN \ (OCF_TO_EVICTION_MIN + OCF_PENDING_EVICTION_LIMIT) @@ -62,6 +63,29 @@ void ocf_core_seq_cutoff_init(ocf_core_t core) } } +void ocf_dbg_get_seq_cutoff_status(ocf_core_t core, + struct ocf_dbg_seq_cutoff_status *status) +{ + struct ocf_seq_cutoff_stream *stream; + uint32_t threshold; + int i = 0; + + OCF_CHECK_NULL(core); + OCF_CHECK_NULL(status); + + threshold = ocf_core_get_seq_cutoff_threshold(core); + + env_rwlock_read_lock(&core->seq_cutoff.lock); + list_for_each_entry(stream, &core->seq_cutoff.lru, list) { + status->streams[i].last = stream->last; + status->streams[i].bytes = stream->bytes; + status->streams[i].rw = stream->rw; + status->streams[i].active = (stream->bytes >= threshold); + i++; + } + env_rwlock_read_unlock(&core->seq_cutoff.lock); +} + bool ocf_core_seq_cutoff_check(ocf_core_t core, struct ocf_request *req) { ocf_seq_cutoff_policy policy = ocf_core_get_seq_cutoff_policy(core);