Merge pull request #260 from mmichal10/unify-inactive-cores-stats
Unify inactive cores stats
This commit is contained in:
commit
58012cd14b
@ -16,6 +16,7 @@
|
|||||||
#include "ocf_volume.h"
|
#include "ocf_volume.h"
|
||||||
#include "ocf_ctx.h"
|
#include "ocf_ctx.h"
|
||||||
#include "ocf_def.h"
|
#include "ocf_def.h"
|
||||||
|
#include "ocf_stats.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cache info: configuration, status
|
* @brief Cache info: configuration, status
|
||||||
@ -32,10 +33,13 @@ struct ocf_cache_info {
|
|||||||
|
|
||||||
/* Statistics of inactive cores */
|
/* Statistics of inactive cores */
|
||||||
struct {
|
struct {
|
||||||
uint32_t occupancy;
|
struct ocf_stat occupancy;
|
||||||
/*!< Cache occupancy (in cache lines) */
|
/*!< Cache occupancy (in cache lines) */
|
||||||
|
|
||||||
uint32_t dirty;
|
struct ocf_stat clean;
|
||||||
|
/*!< Clean blocks within cache (in cache lines) */
|
||||||
|
|
||||||
|
struct ocf_stat dirty;
|
||||||
/*!< Dirty blocks within cache (in cache lines) */
|
/*!< Dirty blocks within cache (in cache lines) */
|
||||||
} inactive;
|
} inactive;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "utils/utils_part.h"
|
#include "utils/utils_part.h"
|
||||||
#include "ocf_priv.h"
|
#include "ocf_priv.h"
|
||||||
#include "ocf_cache_priv.h"
|
#include "ocf_cache_priv.h"
|
||||||
|
#include "utils/utils_stats.h"
|
||||||
|
|
||||||
ocf_volume_t ocf_cache_get_volume(ocf_cache_t cache)
|
ocf_volume_t ocf_cache_get_volume(ocf_cache_t cache)
|
||||||
{
|
{
|
||||||
@ -84,6 +85,8 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
|
|||||||
|
|
||||||
ENV_BUG_ON(env_memset(info, sizeof(*info), 0));
|
ENV_BUG_ON(env_memset(info, sizeof(*info), 0));
|
||||||
|
|
||||||
|
_ocf_stats_zero(&info->inactive);
|
||||||
|
|
||||||
info->attached = ocf_cache_is_device_attached(cache);
|
info->attached = ocf_cache_is_device_attached(cache);
|
||||||
if (info->attached) {
|
if (info->attached) {
|
||||||
info->volume_type = ocf_ctx_get_volume_type_id(cache->owner,
|
info->volume_type = ocf_ctx_get_volume_type_id(cache->owner,
|
||||||
@ -145,8 +148,20 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
|
|||||||
cache->device->metadata_offset / PAGE_SIZE : 0;
|
cache->device->metadata_offset / PAGE_SIZE : 0;
|
||||||
|
|
||||||
info->state = cache->cache_state;
|
info->state = cache->cache_state;
|
||||||
info->inactive.occupancy = cache_occupancy_inactive;
|
|
||||||
info->inactive.dirty = dirty_blocks_inactive;
|
if (info->attached) {
|
||||||
|
_set(&info->inactive.occupancy,
|
||||||
|
_lines4k(cache_occupancy_inactive, ocf_line_size(cache)),
|
||||||
|
_lines4k(info->size, ocf_line_size(cache)));
|
||||||
|
_set(&info->inactive.clean,
|
||||||
|
_lines4k(cache_occupancy_inactive - dirty_blocks_inactive,
|
||||||
|
ocf_line_size(cache)),
|
||||||
|
_lines4k(cache_occupancy_total, ocf_line_size(cache)));
|
||||||
|
_set(&info->inactive.dirty,
|
||||||
|
_lines4k(dirty_blocks_inactive, ocf_line_size(cache)),
|
||||||
|
_lines4k(cache_occupancy_total, ocf_line_size(cache)));
|
||||||
|
}
|
||||||
|
|
||||||
info->flushed = (env_atomic_read(&cache->flush_in_progress)) ?
|
info->flushed = (env_atomic_read(&cache->flush_in_progress)) ?
|
||||||
flushed_total : 0;
|
flushed_total : 0;
|
||||||
|
|
||||||
|
@ -9,46 +9,7 @@
|
|||||||
#include "engine/cache_engine.h"
|
#include "engine/cache_engine.h"
|
||||||
#include "utils/utils_part.h"
|
#include "utils/utils_part.h"
|
||||||
#include "utils/utils_cache_line.h"
|
#include "utils/utils_cache_line.h"
|
||||||
|
#include "utils/utils_stats.h"
|
||||||
#define _ocf_stats_zero(stats) \
|
|
||||||
do { \
|
|
||||||
if (stats) { \
|
|
||||||
typeof(*stats) zero = { { 0 } }; \
|
|
||||||
*stats = zero; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static uint64_t _fraction(uint64_t numerator, uint64_t denominator)
|
|
||||||
{
|
|
||||||
uint64_t result;
|
|
||||||
if (denominator) {
|
|
||||||
result = 10000 * numerator / denominator;
|
|
||||||
} else {
|
|
||||||
result = 0;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t _lines4k(uint64_t size,
|
|
||||||
ocf_cache_line_size_t cache_line_size)
|
|
||||||
{
|
|
||||||
long unsigned int result;
|
|
||||||
|
|
||||||
result = size * (cache_line_size / 4096);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t _bytes4k(uint64_t bytes)
|
|
||||||
{
|
|
||||||
return (bytes + 4095UL) >> 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _set(struct ocf_stat *stat, uint64_t value, uint64_t denominator)
|
|
||||||
{
|
|
||||||
stat->value = value;
|
|
||||||
stat->fraction = _fraction(value, denominator);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _fill_req(struct ocf_stats_requests *req, struct ocf_stats_core *s)
|
static void _fill_req(struct ocf_stats_requests *req, struct ocf_stats_core *s)
|
||||||
{
|
{
|
||||||
|
50
src/utils/utils_stats.h
Normal file
50
src/utils/utils_stats.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(c) 2012-2019 Intel Corporation
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UTILS_STATS_H_
|
||||||
|
#define UTILS_STATS_H_
|
||||||
|
|
||||||
|
#define _ocf_stats_zero(stats) \
|
||||||
|
do { \
|
||||||
|
if (stats) { \
|
||||||
|
typeof(*stats) zero = { { 0 } }; \
|
||||||
|
*stats = zero; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static inline uint64_t _fraction(uint64_t numerator, uint64_t denominator)
|
||||||
|
{
|
||||||
|
uint64_t result;
|
||||||
|
if (denominator) {
|
||||||
|
result = 10000 * numerator / denominator;
|
||||||
|
} else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t _lines4k(uint64_t size,
|
||||||
|
ocf_cache_line_size_t cache_line_size)
|
||||||
|
{
|
||||||
|
long unsigned int result;
|
||||||
|
|
||||||
|
result = size * (cache_line_size / 4096);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t _bytes4k(uint64_t bytes)
|
||||||
|
{
|
||||||
|
return (bytes + 4095UL) >> 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void _set(struct ocf_stat *stat, uint64_t value,
|
||||||
|
uint64_t denominator)
|
||||||
|
{
|
||||||
|
stat->value = value;
|
||||||
|
stat->fraction = _fraction(value, denominator);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -468,9 +468,14 @@ class Cache:
|
|||||||
"size": CacheLines(cache_info.size, line_size),
|
"size": CacheLines(cache_info.size, line_size),
|
||||||
"inactive": {
|
"inactive": {
|
||||||
"occupancy": CacheLines(
|
"occupancy": CacheLines(
|
||||||
cache_info.inactive.occupancy, line_size
|
cache_info.inactive.occupancy.value, line_size
|
||||||
|
),
|
||||||
|
"dirty": CacheLines(
|
||||||
|
cache_info.inactive.dirty.value, line_size
|
||||||
|
),
|
||||||
|
"clean": CacheLines(
|
||||||
|
cache_info.inactive.clean.value, line_size
|
||||||
),
|
),
|
||||||
"dirty": CacheLines(cache_info.inactive.dirty, line_size),
|
|
||||||
},
|
},
|
||||||
"occupancy": CacheLines(cache_info.occupancy, line_size),
|
"occupancy": CacheLines(cache_info.occupancy, line_size),
|
||||||
"dirty": CacheLines(cache_info.dirty, line_size),
|
"dirty": CacheLines(cache_info.dirty, line_size),
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from ctypes import c_uint8, c_uint32, c_uint64, c_bool, c_int, Structure
|
from ctypes import c_uint8, c_uint32, c_uint64, c_bool, c_int, Structure
|
||||||
|
from pyocf.types.stats.shared import _Stat
|
||||||
|
|
||||||
|
|
||||||
class _Inactive(Structure):
|
class _Inactive(Structure):
|
||||||
_fields_ = [("occupancy", c_uint32), ("dirty", c_uint32)]
|
_fields_ = [("occupancy", _Stat), ("clean", _Stat), ("dirty", _Stat)]
|
||||||
|
|
||||||
|
|
||||||
class _FallbackPt(Structure):
|
class _FallbackPt(Structure):
|
||||||
|
Loading…
Reference in New Issue
Block a user