ocf/inc/cleaning/alru.h
David Lee 6184ad7759 alru: add parameter `max_dirty_ratio'
With a high dirty ratio and occupancy, OCF might unable to map cache lines
for new requests, thus pass-through the I/O to core devices.  IOPS will
drop afterwards.  We need to control the dirty ratio.

Existing `alru' policy gives user the chance to control the stale buffer
time, activity threshold etc.  They can affect the dirty ratio of the cache
device, but in an empirical manner, more or less.  Introducing
`max_dirty_ratio' can make it explicit.

At first glance, it might be better to implement a dedicated cleaner policy
directly targeting dirty ratio goal, so that the `alru' parameters remains
orthogonal.  But one the other hand, we still need to flush dirty cache
lines periodically, instead of just keeping a watermark of dirty ratio.
It indicates that existing `alru' parameters are still required if we
develop a new policy, and it seems reasonable to make it a parameter.

To sum up, this patch does the following:
- added a 'max_dirty_ratio' parameter with default value 100;
- with default value 100, `alru' cleaner is identical to what is was;
- with value N less than 100, the cleaner (when waken up) will active
  brought dirty ratio to N, regardless of staleness time.

Signed-off-by: David Lee <live4thee@gmail.com>
2022-10-01 17:48:14 +08:00

86 lines
2.1 KiB
C

/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __OCF_CLEANING_ALRU_H__
#define __OCF_CLEANING_ALRU_H__
/**
* @file
* @brief ALRU cleaning policy API
*/
enum ocf_cleaning_alru_parameters {
ocf_alru_wake_up_time,
ocf_alru_stale_buffer_time,
ocf_alru_flush_max_buffers,
ocf_alru_activity_threshold,
ocf_alru_max_dirty_ratio,
};
/**
* @name ALRU cleaning policy parameters
* @{
*/
/**
* ALRU cleaning thread wake up time
*/
/** Wake up time minimum value */
#define OCF_ALRU_MIN_WAKE_UP 0
/** Wake up time maximum value */
#define OCF_ALRU_MAX_WAKE_UP 3600
/** Wake up time default value */
#define OCF_ALRU_DEFAULT_WAKE_UP 20
/**
* ALRU cleaning thread staleness time
*/
/** Staleness time minimum value */
#define OCF_ALRU_MIN_STALENESS_TIME 1
/** Staleness time maximum value */
#define OCF_ALRU_MAX_STALENESS_TIME 3600
/** Staleness time default value*/
#define OCF_ALRU_DEFAULT_STALENESS_TIME 120
/**
* ALRU cleaning thread number of dirty cache lines to be flushed in one cycle
*/
/** Dirty cache lines to be flushed in one cycle minimum value */
#define OCF_ALRU_MIN_FLUSH_MAX_BUFFERS 1
/** Dirty cache lines to be flushed in one cycle maximum value */
#define OCF_ALRU_MAX_FLUSH_MAX_BUFFERS 10000
/** Dirty cache lines to be flushed in one cycle default value */
#define OCF_ALRU_DEFAULT_FLUSH_MAX_BUFFERS 100
/**
* ALRU cleaning thread cache idle time before flushing thread can start
*/
/** Idle time before flushing thread can start minimum value */
#define OCF_ALRU_MIN_ACTIVITY_THRESHOLD 0
/** Idle time before flushing thread can start maximum value */
#define OCF_ALRU_MAX_ACTIVITY_THRESHOLD 1000000
/** Idle time before flushing thread can start default value */
#define OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD 10000
/**
* ALRU max dirty ratio for a cache device
*/
/** Minimum dirty ratio value */
#define OCF_ALRU_MIN_MAX_DIRTY_RATIO 0
/** Maximum dirty ratio value */
#define OCF_ALRU_MAX_MAX_DIRTY_RATIO 100
/** Default dirty ratio value */
#define OCF_ALRU_DEFAULT_MAX_DIRTY_RATIO OCF_ALRU_MAX_MAX_DIRTY_RATIO
/**
* @}
*/
#endif /* __OCF_CLEANING_ALRU_H__ */