nhit PP: change trigger_threshold to percent value

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
Michal Rakowski 2019-09-25 14:15:40 +02:00
parent 23aba6a9f3
commit 547306efea

View File

@ -18,7 +18,7 @@ struct nhit_policy_context {
/* Configurable parameters */ /* Configurable parameters */
env_atomic insertion_threshold; env_atomic insertion_threshold;
env_atomic64 trigger_threshold; env_atomic trigger_threshold;
}; };
ocf_error_t nhit_init(ocf_cache_t cache, ocf_promotion_policy_t policy) ocf_error_t nhit_init(ocf_cache_t cache, ocf_promotion_policy_t policy)
@ -38,10 +38,7 @@ ocf_error_t nhit_init(ocf_cache_t cache, ocf_promotion_policy_t policy)
goto dealloc_ctx; goto dealloc_ctx;
env_atomic_set(&ctx->insertion_threshold, OCF_NHIT_THRESHOLD_DEFAULT); env_atomic_set(&ctx->insertion_threshold, OCF_NHIT_THRESHOLD_DEFAULT);
env_atomic64_set(&ctx->trigger_threshold, env_atomic_set(&ctx->trigger_threshold, OCF_NHIT_TRIGGER_DEFAULT);
OCF_DIV_ROUND_UP((OCF_NHIT_TRIGGER_DEFAULT *
ocf_metadata_get_cachelines_count(cache)), 100));
policy->ctx = ctx; policy->ctx = ctx;
return 0; return 0;
@ -68,8 +65,6 @@ ocf_error_t nhit_set_param(ocf_promotion_policy_t policy, uint8_t param_id,
{ {
struct nhit_policy_context *ctx = policy->ctx; struct nhit_policy_context *ctx = policy->ctx;
ocf_error_t result = 0; ocf_error_t result = 0;
uint64_t thr_clines;
uint32_t thr_percent;
switch (param_id) { switch (param_id) {
case ocf_nhit_insertion_threshold: case ocf_nhit_insertion_threshold:
@ -89,17 +84,10 @@ ocf_error_t nhit_set_param(ocf_promotion_policy_t policy, uint8_t param_id,
case ocf_nhit_trigger_threshold: case ocf_nhit_trigger_threshold:
if (param_value >= OCF_NHIT_MIN_TRIGGER && if (param_value >= OCF_NHIT_MIN_TRIGGER &&
param_value <= OCF_NHIT_MAX_TRIGGER) { param_value <= OCF_NHIT_MAX_TRIGGER) {
thr_clines = OCF_DIV_ROUND_UP((param_value * env_atomic_set(&ctx->trigger_threshold, param_value);
ocf_metadata_get_cachelines_count(policy->owner)),
100);
env_atomic64_set(&ctx->trigger_threshold, thr_clines);
thr_percent = OCF_DIV_ROUND_UP(thr_clines * 100,
ocf_metadata_get_cachelines_count(policy->owner));
ocf_cache_log(policy->owner, log_info, ocf_cache_log(policy->owner, log_info,
"Nhit PP trigger threshold value set to %u%% (%" "Nhit PP trigger threshold value set to %u%%\n",
ENV_PRIu64 "occupied cachelines)", param_value);
thr_percent, thr_clines);
} else { } else {
ocf_cache_log(policy->owner, log_err, "Invalid nhit " ocf_cache_log(policy->owner, log_err, "Invalid nhit "
"promotion policy insertion trigger " "promotion policy insertion trigger "
@ -133,10 +121,7 @@ ocf_error_t nhit_get_param(ocf_promotion_policy_t policy, uint8_t param_id,
*param_value = env_atomic_read(&ctx->insertion_threshold); *param_value = env_atomic_read(&ctx->insertion_threshold);
break; break;
case ocf_nhit_trigger_threshold: case ocf_nhit_trigger_threshold:
*param_value = OCF_DIV_ROUND_UP( *param_value = env_atomic_read(&ctx->trigger_threshold);
env_atomic64_read(&ctx->trigger_threshold) * 100,
ocf_metadata_get_cachelines_count(policy->owner)
);
break; break;
default: default:
ocf_cache_log(policy->owner, log_err, "Invalid nhit " ocf_cache_log(policy->owner, log_err, "Invalid nhit "
@ -199,7 +184,9 @@ bool nhit_req_should_promote(ocf_promotion_policy_t policy,
ocf_metadata_collision_table_entries(policy->owner) - ocf_metadata_collision_table_entries(policy->owner) -
ocf_freelist_num_free(policy->owner->freelist); ocf_freelist_num_free(policy->owner->freelist);
if (occupied_cachelines < env_atomic64_read(&ctx->trigger_threshold)) if (occupied_cachelines < OCF_DIV_ROUND_UP(
((uint64_t) env_atomic_read(&ctx->trigger_threshold) *
ocf_metadata_get_cachelines_count(policy->owner)), 100))
return true; return true;
for (i = 0, core_line = req->core_line_first; for (i = 0, core_line = req->core_line_first;