From 078a31fbf245bebe0ea70f0038c2bc810159633a Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 12 Sep 2019 09:25:35 -0400 Subject: [PATCH] Inactive cores stats in stats-builder-like form. Signed-off-by: Michal Mielewczyk --- casadm/statistics_model.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/casadm/statistics_model.c b/casadm/statistics_model.c index 400986f..72c0a77 100644 --- a/casadm/statistics_model.c +++ b/casadm/statistics_model.c @@ -39,11 +39,11 @@ #define UNIT_REQUESTS "Requests" #define UNIT_BLOCKS "4KiB blocks" -static inline float percentage(uint64_t numerator, uint64_t denominator) +static inline float fraction(uint64_t numerator, uint64_t denominator) { float result; if (denominator) { - result = 100.0 * numerator / denominator; + result = 10000.0 * numerator / denominator; } else { result = 0; } @@ -415,28 +415,15 @@ void cache_stats_inactive_usage(int ctrl_fd, const struct kcas_cache_info *cache print_table_header(outfile, 4, "Inactive usage statistics", "Count", "%", "[Units]"); - print_val_perc_table_row(outfile, "Inactive Occupancy", UNIT_BLOCKS, - percentage(cache_info->info.inactive.occupancy, - cache_info->info.size), - "%lu", - cache_line_in_4k(cache_info->info.inactive.occupancy, - cache_info->info.cache_line_size / KiB)); - - print_val_perc_table_row(outfile, "Inactive Clean", UNIT_BLOCKS, - percentage(cache_info->info.inactive.occupancy - - cache_info->info.inactive.dirty, - cache_info->info.occupancy), - "%lu", - cache_line_in_4k(cache_info->info.inactive.occupancy - - cache_info->info.inactive.dirty, - cache_info->info.cache_line_size / KiB)); - - print_val_perc_table_row(outfile, "Inactive Dirty", UNIT_BLOCKS, - percentage(cache_info->info.inactive.dirty, - cache_info->info.occupancy), - "%lu", - cache_line_in_4k(cache_info->info.inactive.dirty, - cache_info->info.cache_line_size / KiB)); + print_val_perc_table_row(outfile, "Inactive Occupancy", UNIT_BLOCKS, + cache_info->info.inactive.occupancy.fraction, "%lu", + cache_info->info.inactive.occupancy.value); + print_val_perc_table_row(outfile, "Inactive Clean", UNIT_BLOCKS, + cache_info->info.inactive.clean.fraction, "%lu", + cache_info->info.inactive.clean.value); + print_val_perc_table_row(outfile, "Inactive Dirty", UNIT_BLOCKS, + cache_info->info.inactive.dirty.fraction, "%lu", + cache_info->info.inactive.dirty.value); } /**