Skip to content

Commit e6e01fe

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

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
@@ -642,6 +642,16 @@ int cleaning_policy_alru_set_cleaning_param(ocf_cache_t cache,
642642
"dirty ratio trigger threshold: %d\n",
643643
config->dirty_ratio_threshold);
644644
break;
645+
case ocf_alru_dirty_ratio_inertia:
646+
OCF_CLEANING_CHECK_PARAM(cache, param_value,
647+
OCF_ALRU_MIN_DIRTY_RATIO_INERTIA,
648+
OCF_ALRU_MAX_DIRTY_RATIO_INERTIA,
649+
"dirty_ratio_inertia");
650+
config->dirty_ratio_inertia = param_value;
651+
ocf_cache_log(cache, log_info, "Write-back flush thread "
652+
"dirty ratio trigger inertia: %d\n",
653+
config->dirty_ratio_inertia);
654+
break;
645655
default:
646656
return -OCF_ERR_INVAL;
647657
}
@@ -672,6 +682,9 @@ int cleaning_policy_alru_get_cleaning_param(ocf_cache_t cache,
672682
case ocf_alru_dirty_ratio_threshold:
673683
*param_value = config->dirty_ratio_threshold;
674684
break;
685+
case ocf_alru_dirty_ratio_inertia:
686+
*param_value = config->dirty_ratio_inertia;
687+
break;
675688
default:
676689
return -OCF_ERR_INVAL;
677690
}
@@ -725,7 +738,8 @@ static bool check_for_dirty_ratio(ocf_cache_t cache,
725738
struct alru_context *ctx;
726739
uint32_t threshold;
727740

728-
if (config->dirty_ratio_threshold == OCF_ALRU_MAX_DIRTY_RATIO_THRESHOLD)
741+
if (config->dirty_ratio_threshold
742+
== OCF_ALRU_MAX_DIRTY_RATIO_THRESHOLD)
729743
return false;
730744

731745
if (ocf_cache_get_info(cache, &info))

0 commit comments

Comments
 (0)