Skip to content

Commit 88fc20e

Browse files
committed
Configurable dirty ratio hysteresis
Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
1 parent 98c9161 commit 88fc20e

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

inc/cleaning/alru.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enum ocf_cleaning_alru_parameters {
1818
ocf_alru_flush_max_buffers,
1919
ocf_alru_activity_threshold,
2020
ocf_alru_dirty_ratio_threshold,
21+
ocf_alru_dirty_ratio_inertia,
2122
};
2223

2324
/**
@@ -70,17 +71,28 @@ enum ocf_cleaning_alru_parameters {
7071
#define OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD 10000
7172

7273
/**
73-
* ALRU dirty ratio based cleaning trigger for a cache device
74+
* ALRU dirty ratio based cleaning trigger threshold for a cache device
7475
*/
7576

76-
/** Minimum dirty ratio threshold value */
77+
/** Minimum dirty ratio trigger threshold value */
7778
#define OCF_ALRU_MIN_DIRTY_RATIO_THRESHOLD 0
78-
/** Maximum dirty ratio threshold value */
79+
/** Maximum dirty ratio trigger threshold value */
7980
#define OCF_ALRU_MAX_DIRTY_RATIO_THRESHOLD 100
80-
/** Default dirty ratio threshold value */
81+
/** Default dirty ratio trigger threshold value */
8182
#define OCF_ALRU_DEFAULT_DIRTY_RATIO_THRESHOLD \
8283
OCF_ALRU_MAX_DIRTY_RATIO_THRESHOLD
83-
/** Default dirty ratio threshold inertia */
84+
85+
/**
86+
* ALRU dirty ratio based cleaning trigger inertia for a cache device
87+
* Cleaning triggered by exceeding dirty ratio threshold will stop
88+
* when dirty ratio drops below (threshold - inertia).
89+
*/
90+
91+
/** Minimum dirty ratio trigger inertia value */
92+
#define OCF_ALRU_MIN_DIRTY_RATIO_INERTIA 0
93+
/** Maximum dirty ratio trigger inertia value */
94+
#define OCF_ALRU_MAX_DIRTY_RATIO_INERTIA 100
95+
/** Default dirty ratio trigger inertia value */
8496
#define OCF_ALRU_DEFAULT_DIRTY_RATIO_INERTIA 5
8597
/**
8698
* @}

src/cleaning/alru.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,16 @@ int cleaning_policy_alru_set_cleaning_param(ocf_cache_t cache,
775775
"dirty ratio trigger threshold: %d\n",
776776
config->dirty_ratio_threshold);
777777
break;
778+
case ocf_alru_dirty_ratio_inertia:
779+
OCF_CLEANING_CHECK_PARAM(cache, param_value,
780+
OCF_ALRU_MIN_DIRTY_RATIO_INERTIA,
781+
OCF_ALRU_MAX_DIRTY_RATIO_INERTIA,
782+
"dirty_ratio_inertia");
783+
config->dirty_ratio_inertia = param_value;
784+
ocf_cache_log(cache, log_info, "Write-back flush thread "
785+
"dirty ratio trigger inertia: %d\n",
786+
config->dirty_ratio_inertia);
787+
break;
778788
default:
779789
return -OCF_ERR_INVAL;
780790
}
@@ -805,6 +815,9 @@ int cleaning_policy_alru_get_cleaning_param(ocf_cache_t cache,
805815
case ocf_alru_dirty_ratio_threshold:
806816
*param_value = config->dirty_ratio_threshold;
807817
break;
818+
case ocf_alru_dirty_ratio_inertia:
819+
*param_value = config->dirty_ratio_inertia;
820+
break;
808821
default:
809822
return -OCF_ERR_INVAL;
810823
}
@@ -858,7 +871,8 @@ static bool check_for_dirty_ratio(ocf_cache_t cache,
858871
struct alru_context *ctx;
859872
uint32_t threshold;
860873

861-
if (config->dirty_ratio_threshold == OCF_ALRU_MAX_DIRTY_RATIO_THRESHOLD)
874+
if (config->dirty_ratio_threshold
875+
== OCF_ALRU_MAX_DIRTY_RATIO_THRESHOLD)
862876
return false;
863877

864878
if (ocf_cache_get_info(cache, &info))

0 commit comments

Comments
 (0)