From 703a757db16ba78021165894a7b5f32aa835f7f4 Mon Sep 17 00:00:00 2001 From: Jan Musial Date: Mon, 9 Sep 2019 12:24:33 +0200 Subject: [PATCH] Fix minor bugs in promotion policy Signed-off-by: Jan Musial --- inc/ocf_cache.h | 5 ++++- src/ocf_cache.c | 1 + src/promotion/nhit/nhit.c | 9 ++++----- src/promotion/promotion.c | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/inc/ocf_cache.h b/inc/ocf_cache.h index 7020e37..11fd75f 100644 --- a/inc/ocf_cache.h +++ b/inc/ocf_cache.h @@ -73,7 +73,10 @@ struct ocf_cache_info { /*!< Eviction policy selected */ ocf_cleaning_t cleaning_policy; - /*!< Cleaning policy selected (alru/nop) */ + /*!< Cleaning policy selected */ + + ocf_promotion_t promotion_policy; + /*!< Promotion policy selected */ ocf_cache_line_size_t cache_line_size; /*!< Cache line size in KiB */ diff --git a/src/ocf_cache.c b/src/ocf_cache.c index 86ffabb..e479b40 100644 --- a/src/ocf_cache.c +++ b/src/ocf_cache.c @@ -156,6 +156,7 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info) info->eviction_policy = cache->conf_meta->eviction_policy_type; info->cleaning_policy = cache->conf_meta->cleaning_policy_type; + info->promotion_policy = cache->conf_meta->promotion_policy_type; info->metadata_footprint = ocf_cache_is_device_attached(cache) ? ocf_metadata_size_of(cache) : 0; info->cache_line_size = ocf_line_size(cache); diff --git a/src/promotion/nhit/nhit.c b/src/promotion/nhit/nhit.c index 5c9b340..784f508 100644 --- a/src/promotion/nhit/nhit.c +++ b/src/promotion/nhit/nhit.c @@ -183,7 +183,7 @@ bool nhit_req_should_promote(ocf_promotion_policy_t policy, ocf_metadata_get_cachelines_count(policy->owner) - ocf_freelist_num_free(policy->owner->freelist); - if (occupied_cachelines > env_atomic64_read(&ctx->trigger_threshold)) + if (occupied_cachelines < env_atomic64_read(&ctx->trigger_threshold)) return true; for (i = 0, core_line = req->core_line_first; @@ -196,9 +196,8 @@ bool nhit_req_should_promote(ocf_promotion_policy_t policy, } } - /* We don't want to reject even partially - * hit requests - this way we could trigger passthrough and invalidation. - * Let's let it in! */ - return result || req->info.hit_no; + /* We don't want to reject even partially hit requests - this way we + * could trigger passthrough and invalidation. Let's let it in! */ + return result || ocf_engine_mapped_count(req); } diff --git a/src/promotion/promotion.c b/src/promotion/promotion.c index aa4c8b4..4708007 100644 --- a/src/promotion/promotion.c +++ b/src/promotion/promotion.c @@ -68,6 +68,7 @@ ocf_error_t ocf_promotion_set_policy(ocf_promotion_policy_t policy, ocf_promotion_policies[prev_policy].deinit(policy); cache->conf_meta->promotion_policy_type = type; + policy->type = type; if (ocf_promotion_policies[type].init) result = ocf_promotion_policies[type].init(cache, policy);