Skip to content

Commit 0a6952c

Browse files
live4theemmichal10
authored andcommitted
casadm: add max_dirty_ratio' for alru'
Signed-off-by: Qun Li <qun.li@zstack.io> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
1 parent 114b250 commit 0a6952c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

casadm/cas_main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3+
* Copyright(c) 2022 David Lee <live4thee@gmail.com>
34
* Copyright(c) 2024 Huawei Technologies
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
@@ -730,6 +731,9 @@ static struct cas_param cas_cache_params[] = {
730731
[cache_param_cleaning_alru_activity_threshold] = {
731732
.name = "Activity threshold [ms]" ,
732733
},
734+
[cache_param_cleaning_alru_max_dirty_ratio] = {
735+
.name = "Maximum dirty ratio [percent]",
736+
},
733737

734738
/* Cleaning policy ACP params */
735739
[cache_param_cleaning_acp_wake_up_time] = {
@@ -774,6 +778,8 @@ static struct cas_param cas_cache_params[] = {
774778
" <%d-%d> (default: %d)"
775779
#define CLEANING_ALRU_ACTIVITY_THRESHOLD_DESC "Cache idle time before flushing thread can start <%d-%d>[ms]" \
776780
" (default: %d ms)"
781+
#define CLEANING_ALRU_MAX_DIRTY_RATIO_DESC "Maximum dirty ratio of the cache device" \
782+
" <%d-%d> (default: %d)"
777783

778784
#define CLEANING_ACP_WAKE_UP_DESC "Time between ACP cleaning thread iterations <%d-%d>[ms] (default: %d ms)"
779785
#define CLEANING_ACP_MAX_BUFFERS_DESC "Number of cache lines flushed in single ACP cleaning thread iteration" \
@@ -834,6 +840,10 @@ static cli_namespace set_param_namespace = {
834840
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
835841
OCF_ALRU_MIN_ACTIVITY_THRESHOLD, OCF_ALRU_MAX_ACTIVITY_THRESHOLD,
836842
OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD},
843+
{'d', "max-dirty-ratio", CLEANING_ALRU_MAX_DIRTY_RATIO_DESC, 1, "NUMBER",
844+
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
845+
OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO,
846+
OCF_ALRU_DEFAULT_MAX_DIRTY_RATIO},
837847
CACHE_PARAMS_NS_END()
838848

839849
CACHE_PARAMS_NS_BEGIN("cleaning-acp", "Cleaning policy ACP parameters")
@@ -945,6 +955,14 @@ int set_param_cleaning_alru_handle_option(char *opt, const char **arg)
945955

946956
SET_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold,
947957
strtoul(arg[0], NULL, 10));
958+
} else if (!strcmp(opt, "max-dirty-ratio")) {
959+
if (validate_str_num(arg[0], "max dirty ratio",
960+
OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO)) {
961+
return FAILURE;
962+
}
963+
964+
SET_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio,
965+
strtoul(arg[0], NULL, 10));
948966
} else {
949967
return FAILURE;
950968
}
@@ -1125,6 +1143,7 @@ int get_param_namespace_handle_option(char *namespace, char *opt, const char **a
11251143
SELECT_CACHE_PARAM(cache_param_cleaning_alru_stale_buffer_time);
11261144
SELECT_CACHE_PARAM(cache_param_cleaning_alru_flush_max_buffers);
11271145
SELECT_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold);
1146+
SELECT_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio);
11281147
return cache_param_handle_option_generic(opt, arg,
11291148
get_param_handle_option);
11301149
} else if (!strcmp(namespace, "cleaning-acp")) {

modules/cas_cache/layer_cache_management.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3+
* Copyright(c) 2022 David Lee <live4thee@gmail.com>
34
* Copyright(c) 2024-2025 Huawei Technologies
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
@@ -3638,6 +3639,11 @@ int cache_mngt_set_cache_params(struct kcas_set_cache_param *info)
36383639
ocf_cleaning_alru, ocf_alru_activity_threshold,
36393640
info->param_value);
36403641
break;
3642+
case cache_param_cleaning_alru_max_dirty_ratio:
3643+
result = cache_mngt_set_cleaning_param(cache,
3644+
ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
3645+
info->param_value);
3646+
break;
36413647

36423648
case cache_param_cleaning_acp_wake_up_time:
36433649
result = cache_mngt_set_cleaning_param(cache,
@@ -3702,6 +3708,11 @@ int cache_mngt_get_cache_params(struct kcas_get_cache_param *info)
37023708
ocf_cleaning_alru, ocf_alru_activity_threshold,
37033709
&info->param_value);
37043710
break;
3711+
case cache_param_cleaning_alru_max_dirty_ratio:
3712+
result = cache_mngt_get_cleaning_param(cache,
3713+
ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
3714+
&info->param_value);
3715+
break;
37053716

37063717
case cache_param_cleaning_acp_wake_up_time:
37073718
result = cache_mngt_get_cleaning_param(cache,

modules/include/cas_ioctl_codes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3+
* Copyright(c) 2022 David Lee <live4thee@gmail.com>
34
* Copyright(c) 2024 Huawei Technologies
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
@@ -325,6 +326,7 @@ enum kcas_cache_param_id {
325326
cache_param_cleaning_alru_stale_buffer_time,
326327
cache_param_cleaning_alru_flush_max_buffers,
327328
cache_param_cleaning_alru_activity_threshold,
329+
cache_param_cleaning_alru_max_dirty_ratio,
328330
cache_param_cleaning_acp_wake_up_time,
329331
cache_param_cleaning_acp_flush_max_buffers,
330332
cache_param_promotion_policy_type,

0 commit comments

Comments
 (0)