Skip to content

Commit

Permalink
casadm: add max_dirty_ratio' for alru'
Browse files Browse the repository at this point in the history
Signed-off-by: Qun Li <[email protected]>
  • Loading branch information
live4thee committed Oct 9, 2022
1 parent 416df4a commit d335cc5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions casadm/cas_main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2022 David Lee <[email protected]>
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -703,6 +704,9 @@ static struct cas_param cas_cache_params[] = {
[cache_param_cleaning_alru_activity_threshold] = {
.name = "Activity threshold [ms]" ,
},
[cache_param_cleaning_alru_max_dirty_ratio] = {
.name = "Maximum dirty ratio [percent]",
},

/* Cleaning policy ACP params */
[cache_param_cleaning_acp_wake_up_time] = {
Expand Down Expand Up @@ -747,6 +751,8 @@ static struct cas_param cas_cache_params[] = {
" <%d-%d> (default: %d)"
#define CLEANING_ALRU_ACTIVITY_THRESHOLD_DESC "Cache idle time before flushing thread can start <%d-%d>[ms]" \
" (default: %d ms)"
#define CLEANING_ALRU_MAX_DIRTY_RATIO_DESC "Maximum dirty ratio of the cache device" \
" <%d-%d> (default: %d)"

#define CLEANING_ACP_WAKE_UP_DESC "Time between ACP cleaning thread iterations <%d-%d>[ms] (default: %d ms)"
#define CLEANING_ACP_MAX_BUFFERS_DESC "Number of cache lines flushed in single ACP cleaning thread iteration" \
Expand Down Expand Up @@ -807,6 +813,10 @@ static cli_namespace set_param_namespace = {
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
OCF_ALRU_MIN_ACTIVITY_THRESHOLD, OCF_ALRU_MAX_ACTIVITY_THRESHOLD,
OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD},
{'d', "max-dirty-ratio", CLEANING_ALRU_MAX_DIRTY_RATIO_DESC, 1, "NUMBER",
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO,
OCF_ALRU_DEFAULT_MAX_DIRTY_RATIO},
CACHE_PARAMS_NS_END()

CACHE_PARAMS_NS_BEGIN("cleaning-acp", "Cleaning policy ACP parameters")
Expand Down Expand Up @@ -918,6 +928,14 @@ int set_param_cleaning_alru_handle_option(char *opt, const char **arg)

SET_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold,
strtoul(arg[0], NULL, 10));
} else if (!strcmp(opt, "max-dirty-ratio")) {
if (validate_str_num(arg[0], "max dirty ratio",
OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO)) {
return FAILURE;
}

SET_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio,
strtoul(arg[0], NULL, 10));
} else {
return FAILURE;
}
Expand Down Expand Up @@ -1098,6 +1116,7 @@ int get_param_namespace_handle_option(char *namespace, char *opt, const char **a
SELECT_CACHE_PARAM(cache_param_cleaning_alru_stale_buffer_time);
SELECT_CACHE_PARAM(cache_param_cleaning_alru_flush_max_buffers);
SELECT_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold);
SELECT_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio);
return cache_param_handle_option_generic(opt, arg,
get_param_handle_option);
} else if (!strcmp(namespace, "cleaning-acp")) {
Expand Down
11 changes: 11 additions & 0 deletions modules/cas_cache/layer_cache_management.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2022 David Lee <[email protected]>
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -3326,6 +3327,11 @@ int cache_mngt_set_cache_params(struct kcas_set_cache_param *info)
ocf_cleaning_alru, ocf_alru_activity_threshold,
info->param_value);
break;
case cache_param_cleaning_alru_max_dirty_ratio:
result = cache_mngt_set_cleaning_param(cache,
ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
info->param_value);
break;

case cache_param_cleaning_acp_wake_up_time:
result = cache_mngt_set_cleaning_param(cache,
Expand Down Expand Up @@ -3390,6 +3396,11 @@ int cache_mngt_get_cache_params(struct kcas_get_cache_param *info)
ocf_cleaning_alru, ocf_alru_activity_threshold,
&info->param_value);
break;
case cache_param_cleaning_alru_max_dirty_ratio:
result = cache_mngt_get_cleaning_param(cache,
ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
&info->param_value);
break;

case cache_param_cleaning_acp_wake_up_time:
result = cache_mngt_get_cleaning_param(cache,
Expand Down
2 changes: 2 additions & 0 deletions modules/include/cas_ioctl_codes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2022 David Lee <[email protected]>
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -331,6 +332,7 @@ enum kcas_cache_param_id {
cache_param_cleaning_alru_stale_buffer_time,
cache_param_cleaning_alru_flush_max_buffers,
cache_param_cleaning_alru_activity_threshold,
cache_param_cleaning_alru_max_dirty_ratio,
cache_param_cleaning_acp_wake_up_time,
cache_param_cleaning_acp_flush_max_buffers,
cache_param_promotion_policy_type,
Expand Down

0 comments on commit d335cc5

Please sign in to comment.