Remove eviction policy abstraction

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-06-15 20:39:09 +02:00
parent 31737ee0e7
commit 88e04a4204
33 changed files with 52 additions and 320 deletions

View File

@ -72,9 +72,6 @@ struct ocf_cache_info {
set as a result of reaching IO error threshold */ set as a result of reaching IO error threshold */
} fallback_pt; } fallback_pt;
ocf_eviction_t eviction_policy;
/*!< Eviction policy selected */
ocf_cleaning_t cleaning_policy; ocf_cleaning_t cleaning_policy;
/*!< Cleaning policy selected */ /*!< Cleaning policy selected */

View File

@ -199,20 +199,6 @@ typedef enum {
/*!< Default sequential cutoff policy*/ /*!< Default sequential cutoff policy*/
} ocf_seq_cutoff_policy; } ocf_seq_cutoff_policy;
/**
* OCF supported eviction policy types
*/
typedef enum {
ocf_eviction_lru = 0,
/*!< Last recently used eviction policy */
ocf_eviction_max,
/*!< Stopper of enumerator */
ocf_eviction_default = ocf_eviction_lru,
/*!< Default eviction policy */
} ocf_eviction_t;
/** /**
* OCF supported promotion policy types * OCF supported promotion policy types
*/ */

View File

@ -44,9 +44,6 @@ struct ocf_io_class_info {
* of ioclass's cachelines are evicted. * of ioclass's cachelines are evicted.
*/ */
uint8_t eviction_policy_type;
/*!< The type of eviction policy for given IO class */
ocf_cleaning_t cleaning_policy_type; ocf_cleaning_t cleaning_policy_type;
/*!< The type of cleaning policy for given IO class */ /*!< The type of cleaning policy for given IO class */
}; };

View File

@ -246,11 +246,6 @@ struct ocf_mngt_cache_config {
*/ */
ocf_cache_mode_t cache_mode; ocf_cache_mode_t cache_mode;
/**
* @brief Eviction policy type
*/
ocf_eviction_t eviction_policy;
/** /**
* @brief Promotion policy type * @brief Promotion policy type
*/ */
@ -307,7 +302,6 @@ static inline void ocf_mngt_cache_config_set_default(
struct ocf_mngt_cache_config *cfg) struct ocf_mngt_cache_config *cfg)
{ {
cfg->cache_mode = ocf_cache_mode_default; cfg->cache_mode = ocf_cache_mode_default;
cfg->eviction_policy = ocf_eviction_default;
cfg->promotion_policy = ocf_promotion_default; cfg->promotion_policy = ocf_promotion_default;
cfg->cache_line_size = ocf_cache_line_size_4; cfg->cache_line_size = ocf_cache_line_size_4;
cfg->metadata_layout = ocf_metadata_layout_default; cfg->metadata_layout = ocf_metadata_layout_default;

View File

@ -202,7 +202,7 @@ static void ocf_engine_set_hot(struct ocf_request *req)
if (status == LOOKUP_HIT) { if (status == LOOKUP_HIT) {
/* Update eviction (LRU) */ /* Update eviction (LRU) */
ocf_eviction_set_hot_cache_line(cache, entry->coll_idx); evp_lru_hot_cline(cache, entry->coll_idx);
} }
} }
} }
@ -518,7 +518,7 @@ int ocf_engine_prepare_clines(struct ocf_request *req)
ocf_hb_req_prot_unlock_wr(req); ocf_hb_req_prot_unlock_wr(req);
if (ocf_req_is_cleaning_required(req)) { if (ocf_req_is_cleaning_required(req)) {
ocf_lru_flush_dirty(req->cache, user_part, req->io_queue, evp_lru_clean(req->cache, user_part, req->io_queue,
128); 128);
} }

View File

@ -4,24 +4,9 @@
*/ */
#include "eviction.h" #include "eviction.h"
#include "ops.h"
#include "../utils/utils_user_part.h" #include "../utils/utils_user_part.h"
#include "../engine/engine_common.h" #include "../engine/engine_common.h"
struct eviction_policy_ops evict_policy_ops[ocf_eviction_max] = {
[ocf_eviction_lru] = {
.init_cline = evp_lru_init_cline,
.rm_cline = evp_lru_rm_cline,
.req_clines = evp_lru_req_clines,
.hot_cline = evp_lru_hot_cline,
.init_evp = evp_lru_init_evp,
.dirty_cline = evp_lru_dirty_cline,
.clean_cline = evp_lru_clean_cline,
.flush_dirty = evp_lru_clean,
.name = "lru",
},
};
static uint32_t ocf_evict_calculate(ocf_cache_t cache, static uint32_t ocf_evict_calculate(ocf_cache_t cache,
struct ocf_user_part *user_part, uint32_t to_evict) struct ocf_user_part *user_part, uint32_t to_evict)
{ {
@ -49,9 +34,6 @@ static inline uint32_t ocf_evict_part_do(struct ocf_request *req,
uint32_t unmapped = ocf_engine_unmapped_count(req); uint32_t unmapped = ocf_engine_unmapped_count(req);
uint32_t to_evict = 0; uint32_t to_evict = 0;
if (!evp_lru_can_evict(req->cache))
return 0;
to_evict = ocf_evict_calculate(req->cache, user_part, unmapped); to_evict = ocf_evict_calculate(req->cache, user_part, unmapped);
if (to_evict < unmapped) { if (to_evict < unmapped) {
@ -60,8 +42,7 @@ static inline uint32_t ocf_evict_part_do(struct ocf_request *req,
return 0; return 0;
} }
return ocf_request_space(req->cache, req, &user_part->part, return evp_lru_req_clines(req, &user_part->part, to_evict);
to_evict);
} }
static inline uint32_t ocf_evict_user_partitions(ocf_cache_t cache, static inline uint32_t ocf_evict_user_partitions(ocf_cache_t cache,
@ -75,9 +56,6 @@ static inline uint32_t ocf_evict_user_partitions(ocf_cache_t cache,
/* For each partition from the lowest priority to highest one */ /* For each partition from the lowest priority to highest one */
for_each_user_part(cache, user_part, part_id) { for_each_user_part(cache, user_part, part_id) {
if (!ocf_eviction_can_evict(cache))
goto out;
/* /*
* Check stop and continue conditions * Check stop and continue conditions
*/ */
@ -111,8 +89,7 @@ static inline uint32_t ocf_evict_user_partitions(ocf_cache_t cache,
if (overflown_only) if (overflown_only)
to_evict = OCF_MIN(to_evict, overflow_size); to_evict = OCF_MIN(to_evict, overflow_size);
evicted += ocf_request_space(cache, req, &user_part->part, evicted += evp_lru_req_clines(req, &user_part->part, to_evict);
to_evict);
if (evicted >= evict_cline_no) { if (evicted >= evict_cline_no) {
/* Evicted requested number of cache line, stop /* Evicted requested number of cache line, stop
@ -135,10 +112,9 @@ static inline uint32_t ocf_remap_do(struct ocf_request *req)
uint32_t remapped = 0; uint32_t remapped = 0;
/* First attempt to map from freelist */ /* First attempt to map from freelist */
if (ocf_lru_num_free(cache) > 0) { if (ocf_lru_num_free(cache) > 0)
remapped = ocf_request_space(cache, req, &cache->free, remapped = evp_lru_req_clines(req, &cache->free, remap_cline_no);
remap_cline_no);
}
if (remapped >= remap_cline_no) if (remapped >= remap_cline_no)
return remapped; return remapped;

View File

@ -31,32 +31,6 @@ union eviction_policy_meta {
struct lru_eviction_policy_meta lru; struct lru_eviction_policy_meta lru;
} __attribute__((packed)); } __attribute__((packed));
/* the caller must hold the metadata lock for all operations
*
* For range operations the caller can:
* set core_id to -1 to purge the whole cache device
* set core_id to -2 to purge the whole cache partition
*/
struct eviction_policy_ops {
void (*init_cline)(ocf_cache_t cache, ocf_cache_line_t cline);
void (*rm_cline)(ocf_cache_t cache,
ocf_cache_line_t cline);
bool (*can_evict)(ocf_cache_t cache);
uint32_t (*req_clines)(struct ocf_request *req, struct ocf_part *part,
uint32_t cline_no);
void (*hot_cline)(ocf_cache_t cache, ocf_cache_line_t cline);
void (*init_evp)(ocf_cache_t cache, struct ocf_part *part);
void (*dirty_cline)(ocf_cache_t cache, struct ocf_part *part,
ocf_cache_line_t cline);
void (*clean_cline)(ocf_cache_t cache, struct ocf_part *part,
ocf_cache_line_t cline);
void (*flush_dirty)(ocf_cache_t cache, struct ocf_user_part *user_part,
ocf_queue_t io_queue, uint32_t count);
const char *name;
};
extern struct eviction_policy_ops evict_policy_ops[ocf_eviction_max];
/* /*
* Deallocates space according to eviction priorities. * Deallocates space according to eviction priorities.
* *
@ -68,8 +42,6 @@ int ocf_space_managment_remap_do(struct ocf_request *req);
int space_management_free(ocf_cache_t cache, uint32_t count); int space_management_free(ocf_cache_t cache, uint32_t count);
void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines);
typedef void (*ocf_metadata_actor_t)(struct ocf_cache *cache, typedef void (*ocf_metadata_actor_t)(struct ocf_cache *cache,
ocf_cache_line_t cache_line); ocf_cache_line_t cache_line);
@ -77,10 +49,4 @@ int ocf_metadata_actor(struct ocf_cache *cache,
ocf_part_id_t part_id, ocf_core_id_t core_id, ocf_part_id_t part_id, ocf_core_id_t core_id,
uint64_t start_byte, uint64_t end_byte, uint64_t start_byte, uint64_t end_byte,
ocf_metadata_actor_t actor); ocf_metadata_actor_t actor);
void ocf_lru_repart(ocf_cache_t cache, ocf_cache_line_t cline,
struct ocf_part *src_upart, struct ocf_part *dst_upart);
uint32_t ocf_lru_num_free(ocf_cache_t cache);
#endif #endif

View File

@ -5,7 +5,6 @@
#include "eviction.h" #include "eviction.h"
#include "lru.h" #include "lru.h"
#include "ops.h"
#include "../utils/utils_cleaner.h" #include "../utils/utils_cleaner.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../concurrency/ocf_concurrency.h" #include "../concurrency/ocf_concurrency.h"

View File

@ -14,7 +14,7 @@ struct ocf_part_runtime;
struct ocf_part_cleaning_ctx; struct ocf_part_cleaning_ctx;
struct ocf_request; struct ocf_request;
void evp_lru_init_cline(struct ocf_cache *cache, ocf_cache_line_t cline); void evp_lru_init_cline(ocf_cache_t cache, ocf_cache_line_t cline);
void evp_lru_rm_cline(struct ocf_cache *cache, ocf_cache_line_t cline); void evp_lru_rm_cline(struct ocf_cache *cache, ocf_cache_line_t cline);
bool evp_lru_can_evict(struct ocf_cache *cache); bool evp_lru_can_evict(struct ocf_cache *cache);
uint32_t evp_lru_req_clines(struct ocf_request *req, uint32_t evp_lru_req_clines(struct ocf_request *req,
@ -27,4 +27,9 @@ void evp_lru_clean_cline(struct ocf_cache *cache, struct ocf_part *part,
ocf_cache_line_t cline); ocf_cache_line_t cline);
void evp_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part, void evp_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part,
ocf_queue_t io_queue, uint32_t count); ocf_queue_t io_queue, uint32_t count);
void ocf_lru_repart(ocf_cache_t cache, ocf_cache_line_t cline,
struct ocf_part *src_upart, struct ocf_part *dst_upart);
uint32_t ocf_lru_num_free(ocf_cache_t cache);
void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines);
#endif #endif

View File

@ -1,108 +0,0 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef LAYER_EVICTION_POLICY_OPS_H_
#define LAYER_EVICTION_POLICY_OPS_H_
#include "eviction.h"
#include "../metadata/metadata.h"
#include "../concurrency/ocf_metadata_concurrency.h"
/**
* @brief Initialize cache line before adding it into eviction
*
* @note This operation is called under WR metadata lock
*/
static inline void ocf_eviction_init_cache_line(struct ocf_cache *cache,
ocf_cache_line_t line)
{
uint8_t type;
type = cache->conf_meta->eviction_policy_type;
ENV_BUG_ON(type >= ocf_eviction_max);
if (likely(evict_policy_ops[type].init_cline))
evict_policy_ops[type].init_cline(cache, line);
}
static inline void ocf_eviction_purge_cache_line(
struct ocf_cache *cache, ocf_cache_line_t line)
{
uint8_t type = cache->conf_meta->eviction_policy_type;
ENV_BUG_ON(type >= ocf_eviction_max);
if (likely(evict_policy_ops[type].rm_cline)) {
evict_policy_ops[type].rm_cline(cache, line);
}
}
static inline bool ocf_eviction_can_evict(struct ocf_cache *cache)
{
uint8_t type = cache->conf_meta->eviction_policy_type;
if (likely(evict_policy_ops[type].can_evict))
return evict_policy_ops[type].can_evict(cache);
return true;
}
static inline uint32_t ocf_request_space(ocf_cache_t cache,
struct ocf_request *req, struct ocf_part *part,
uint32_t clines)
{
uint8_t type;
uint32_t result = 0;
type = cache->conf_meta->eviction_policy_type;
ENV_BUG_ON(type >= ocf_eviction_max);
if (likely(evict_policy_ops[type].req_clines))
result = evict_policy_ops[type].req_clines(req, part, clines);
return result;
}
static inline void ocf_eviction_set_hot_cache_line(
struct ocf_cache *cache, ocf_cache_line_t line)
{
uint8_t type = cache->conf_meta->eviction_policy_type;
ENV_BUG_ON(type >= ocf_eviction_max);
if (likely(evict_policy_ops[type].hot_cline)) {
evict_policy_ops[type].hot_cline(cache, line);
}
}
static inline void ocf_eviction_initialize(struct ocf_cache *cache,
struct ocf_part *part)
{
uint8_t type = cache->conf_meta->eviction_policy_type;
ENV_BUG_ON(type >= ocf_eviction_max);
if (likely(evict_policy_ops[type].init_evp)) {
evict_policy_ops[type].init_evp(cache, part);
}
}
static inline void ocf_lru_flush_dirty(ocf_cache_t cache,
struct ocf_user_part *user_part, ocf_queue_t io_queue,
uint32_t count)
{
uint8_t type = cache->conf_meta->eviction_policy_type;
ENV_BUG_ON(type >= ocf_eviction_max);
if (likely(evict_policy_ops[type].flush_dirty)) {
evict_policy_ops[type].flush_dirty(cache, user_part, io_queue,
count);
}
}
#endif /* LAYER_EVICTION_POLICY_OPS_H_ */

View File

@ -1167,9 +1167,9 @@ static void _recovery_rebuild_cline_metadata(ocf_cache_t cache,
ocf_metadata_add_to_collision(cache, core_id, core_line, hash_index, ocf_metadata_add_to_collision(cache, core_id, core_line, hash_index,
cache_line); cache_line);
ocf_eviction_init_cache_line(cache, cache_line); evp_lru_init_cline(cache, cache_line);
ocf_eviction_set_hot_cache_line(cache, cache_line); evp_lru_hot_cline(cache, cache_line);
env_atomic_inc(&core->runtime_meta->cached_clines); env_atomic_inc(&core->runtime_meta->cached_clines);
env_atomic_inc(&core->runtime_meta-> env_atomic_inc(&core->runtime_meta->

View File

@ -49,8 +49,6 @@ struct ocf_superblock_config {
ocf_promotion_t promotion_policy_type; ocf_promotion_t promotion_policy_type;
struct promotion_policy_config promotion[PROMOTION_POLICY_TYPE_MAX]; struct promotion_policy_config promotion[PROMOTION_POLICY_TYPE_MAX];
ocf_eviction_t eviction_policy_type;
/* /*
* Checksum for each metadata region. * Checksum for each metadata region.
* This field has to be the last one! * This field has to be the last one!

View File

@ -21,7 +21,7 @@
#include "../utils/utils_refcnt.h" #include "../utils/utils_refcnt.h"
#include "../utils/utils_async_lock.h" #include "../utils/utils_async_lock.h"
#include "../concurrency/ocf_concurrency.h" #include "../concurrency/ocf_concurrency.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "../ocf_ctx_priv.h" #include "../ocf_ctx_priv.h"
#include "../cleaning/cleaning.h" #include "../cleaning/cleaning.h"
#include "../promotion/ops.h" #include "../promotion/ops.h"
@ -185,9 +185,9 @@ static void __init_parts_attached(ocf_cache_t cache)
ocf_part_id_t part_id; ocf_part_id_t part_id;
for (part_id = 0; part_id < OCF_USER_IO_CLASS_MAX; part_id++) for (part_id = 0; part_id < OCF_USER_IO_CLASS_MAX; part_id++)
ocf_eviction_initialize(cache, &cache->user_parts[part_id].part); evp_lru_init_evp(cache, &cache->user_parts[part_id].part);
ocf_eviction_initialize(cache, &cache->free); evp_lru_init_evp(cache, &cache->free);
} }
static void __init_free(ocf_cache_t cache) static void __init_free(ocf_cache_t cache)
@ -227,14 +227,6 @@ static void __deinit_cleaning_policy(ocf_cache_t cache)
cleaning_policy_ops[cleaning_policy].deinitialize(cache); cleaning_policy_ops[cleaning_policy].deinitialize(cache);
} }
static void __init_eviction_policy(ocf_cache_t cache,
ocf_eviction_t eviction)
{
ENV_BUG_ON(eviction < 0 || eviction >= ocf_eviction_max);
cache->conf_meta->eviction_policy_type = eviction;
}
static void __setup_promotion_policy(ocf_cache_t cache) static void __setup_promotion_policy(ocf_cache_t cache)
{ {
int i; int i;
@ -286,8 +278,7 @@ static void __reset_stats(ocf_cache_t cache)
} }
} }
static ocf_error_t init_attached_data_structures(ocf_cache_t cache, static ocf_error_t init_attached_data_structures(ocf_cache_t cache)
ocf_eviction_t eviction_policy)
{ {
ocf_error_t result; ocf_error_t result;
@ -305,7 +296,6 @@ static ocf_error_t init_attached_data_structures(ocf_cache_t cache,
return result; return result;
} }
__init_eviction_policy(cache, eviction_policy);
__setup_promotion_policy(cache); __setup_promotion_policy(cache);
return 0; return 0;
@ -680,7 +670,6 @@ static int _ocf_mngt_init_prepare_cache(struct ocf_cache_mngt_init_params *param
cache->pt_unaligned_io = cfg->pt_unaligned_io; cache->pt_unaligned_io = cfg->pt_unaligned_io;
cache->use_submit_io_fast = cfg->use_submit_io_fast; cache->use_submit_io_fast = cfg->use_submit_io_fast;
cache->eviction_policy_init = cfg->eviction_policy;
cache->metadata.is_volatile = cfg->metadata_volatile; cache->metadata.is_volatile = cfg->metadata_volatile;
out: out:
@ -1010,7 +999,7 @@ static void _ocf_mngt_attach_init_instance(ocf_pipeline_t pipeline,
ocf_cache_t cache = context->cache; ocf_cache_t cache = context->cache;
ocf_error_t result; ocf_error_t result;
result = init_attached_data_structures(cache, cache->eviction_policy_init); result = init_attached_data_structures(cache);
if (result) if (result)
OCF_PL_FINISH_RET(pipeline, result); OCF_PL_FINISH_RET(pipeline, result);
@ -1872,11 +1861,6 @@ static int _ocf_mngt_cache_validate_cfg(struct ocf_mngt_cache_config *cfg)
if (!ocf_cache_mode_is_valid(cfg->cache_mode)) if (!ocf_cache_mode_is_valid(cfg->cache_mode))
return -OCF_ERR_INVALID_CACHE_MODE; return -OCF_ERR_INVALID_CACHE_MODE;
if (cfg->eviction_policy >= ocf_eviction_max ||
cfg->eviction_policy < 0) {
return -OCF_ERR_INVAL;
}
if (cfg->promotion_policy >= ocf_promotion_max || if (cfg->promotion_policy >= ocf_promotion_max ||
cfg->promotion_policy < 0 ) { cfg->promotion_policy < 0 ) {
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
@ -2077,15 +2061,12 @@ static int _ocf_mngt_cache_load_core_log(ocf_core_t core, void *cntx)
static void _ocf_mngt_cache_load_log(ocf_cache_t cache) static void _ocf_mngt_cache_load_log(ocf_cache_t cache)
{ {
ocf_cache_mode_t cache_mode = ocf_cache_get_mode(cache); ocf_cache_mode_t cache_mode = ocf_cache_get_mode(cache);
ocf_eviction_t eviction_type = cache->conf_meta->eviction_policy_type;
ocf_cleaning_t cleaning_type = cache->conf_meta->cleaning_policy_type; ocf_cleaning_t cleaning_type = cache->conf_meta->cleaning_policy_type;
ocf_promotion_t promotion_type = cache->conf_meta->promotion_policy_type; ocf_promotion_t promotion_type = cache->conf_meta->promotion_policy_type;
ocf_cache_log(cache, log_info, "Successfully loaded\n"); ocf_cache_log(cache, log_info, "Successfully loaded\n");
ocf_cache_log(cache, log_info, "Cache mode : %s\n", ocf_cache_log(cache, log_info, "Cache mode : %s\n",
_ocf_cache_mode_get_name(cache_mode)); _ocf_cache_mode_get_name(cache_mode));
ocf_cache_log(cache, log_info, "Eviction policy : %s\n",
evict_policy_ops[eviction_type].name);
ocf_cache_log(cache, log_info, "Cleaning policy : %s\n", ocf_cache_log(cache, log_info, "Cleaning policy : %s\n",
cleaning_policy_ops[cleaning_type].name); cleaning_policy_ops[cleaning_type].name);
ocf_cache_log(cache, log_info, "Promotion policy : %s\n", ocf_cache_log(cache, log_info, "Promotion policy : %s\n",

View File

@ -11,7 +11,7 @@
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../ocf_request.h" #include "../ocf_request.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "../ocf_logger_priv.h" #include "../ocf_logger_priv.h"
#include "../ocf_queue_priv.h" #include "../ocf_queue_priv.h"
#include "../engine/engine_common.h" #include "../engine/engine_common.h"

View File

@ -9,7 +9,7 @@
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../utils/utils_user_part.h" #include "../utils/utils_user_part.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "ocf_env.h" #include "ocf_env.h"
static uint64_t _ocf_mngt_count_user_parts_min_size(struct ocf_cache *cache) static uint64_t _ocf_mngt_count_user_parts_min_size(struct ocf_cache *cache)

View File

@ -170,7 +170,6 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
info->fallback_pt.error_counter = info->fallback_pt.error_counter =
env_atomic_read(&cache->fallback_pt_error_counter); env_atomic_read(&cache->fallback_pt_error_counter);
info->eviction_policy = cache->conf_meta->eviction_policy_type;
info->cleaning_policy = cache->conf_meta->cleaning_policy_type; info->cleaning_policy = cache->conf_meta->cleaning_policy_type;
info->promotion_policy = cache->conf_meta->promotion_policy_type; info->promotion_policy = cache->conf_meta->promotion_policy_type;
info->metadata_footprint = ocf_cache_is_device_attached(cache) ? info->metadata_footprint = ocf_cache_is_device_attached(cache) ?

View File

@ -81,8 +81,6 @@ struct ocf_cache {
struct ocf_part free; struct ocf_part free;
ocf_eviction_t eviction_policy_init;
uint32_t fallback_pt_error_threshold; uint32_t fallback_pt_error_threshold;
ocf_queue_t mngt_queue; ocf_queue_t mngt_queue;

View File

@ -42,7 +42,6 @@ int ocf_cache_io_class_get_info(ocf_cache_t cache, uint32_t io_class,
info->min_size = cache->user_parts[part_id].config->min_size; info->min_size = cache->user_parts[part_id].config->min_size;
info->max_size = cache->user_parts[part_id].config->max_size; info->max_size = cache->user_parts[part_id].config->max_size;
info->eviction_policy_type = cache->conf_meta->eviction_policy_type;
info->cleaning_policy_type = cache->conf_meta->cleaning_policy_type; info->cleaning_policy_type = cache->conf_meta->cleaning_policy_type;
info->cache_mode = cache->user_parts[part_id].config->cache_mode; info->cache_mode = cache->user_parts[part_id].config->cache_mode;

View File

@ -103,9 +103,11 @@ void set_cache_line_clean(struct ocf_cache *cache, uint8_t start_bit,
ocf_cache_line_t line = req->map[map_idx].coll_idx; ocf_cache_line_t line = req->map[map_idx].coll_idx;
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache, line); ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache, line);
struct ocf_part *part = &cache->user_parts[part_id].part; struct ocf_part *part = &cache->user_parts[part_id].part;
uint8_t evp_type = cache->conf_meta->eviction_policy_type;
bool line_is_clean; bool line_is_clean;
ENV_BUG_ON(part_id > OCF_USER_IO_CLASS_MAX);
part = &cache->user_parts[part_id].part;
if (metadata_clear_dirty_sec_changed(cache, line, start_bit, end_bit, if (metadata_clear_dirty_sec_changed(cache, line, start_bit, end_bit,
&line_is_clean)) { &line_is_clean)) {
ocf_metadata_flush_mark(cache, req, map_idx, CLEAN, start_bit, ocf_metadata_flush_mark(cache, req, map_idx, CLEAN, start_bit,
@ -130,12 +132,7 @@ void set_cache_line_clean(struct ocf_cache *cache, uint8_t start_bit,
*/ */
env_atomic_dec(&req->core->runtime_meta-> env_atomic_dec(&req->core->runtime_meta->
part_counters[part_id].dirty_clines); part_counters[part_id].dirty_clines);
evp_lru_clean_cline(cache, part, line);
if (likely(evict_policy_ops[evp_type].clean_cline)) {
evict_policy_ops[evp_type].clean_cline(cache,
part, line);
}
ocf_purge_cleaning_policy(cache, line); ocf_purge_cleaning_policy(cache, line);
} }
} }
@ -147,10 +144,12 @@ void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
{ {
ocf_cache_line_t line = req->map[map_idx].coll_idx; ocf_cache_line_t line = req->map[map_idx].coll_idx;
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache, line); ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache, line);
struct ocf_part *part = &cache->user_parts[part_id].part; struct ocf_part *part;
uint8_t evp_type = cache->conf_meta->eviction_policy_type;
bool line_was_dirty; bool line_was_dirty;
ENV_BUG_ON(part_id > OCF_USER_IO_CLASS_MAX);
part = &cache->user_parts[part_id].part;
if (metadata_set_dirty_sec_changed(cache, line, start_bit, end_bit, if (metadata_set_dirty_sec_changed(cache, line, start_bit, end_bit,
&line_was_dirty)) { &line_was_dirty)) {
ocf_metadata_flush_mark(cache, req, map_idx, DIRTY, start_bit, ocf_metadata_flush_mark(cache, req, map_idx, DIRTY, start_bit,
@ -175,11 +174,7 @@ void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
*/ */
env_atomic_inc(&req->core->runtime_meta-> env_atomic_inc(&req->core->runtime_meta->
part_counters[part_id].dirty_clines); part_counters[part_id].dirty_clines);
evp_lru_dirty_cline(cache, part, line);
if (likely(evict_policy_ops[evp_type].dirty_cline)) {
evict_policy_ops[evp_type].dirty_cline(cache,
part, line);
}
} }
} }

View File

@ -9,7 +9,6 @@
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../concurrency/ocf_cache_line_concurrency.h" #include "../concurrency/ocf_cache_line_concurrency.h"
#include "../eviction/eviction.h" #include "../eviction/eviction.h"
#include "../eviction/ops.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../ocf_request.h" #include "../ocf_request.h"
#include "../ocf_def_priv.h" #include "../ocf_def_priv.h"
@ -180,7 +179,7 @@ static inline void ocf_purge_cleaning_policy(struct ocf_cache *cache,
static inline void ocf_purge_eviction_policy(struct ocf_cache *cache, static inline void ocf_purge_eviction_policy(struct ocf_cache *cache,
ocf_cache_line_t line) ocf_cache_line_t line)
{ {
ocf_eviction_purge_cache_line(cache, line); evp_lru_rm_cline(cache, line);
} }
/** /**

View File

@ -8,7 +8,7 @@
#include "../ocf_request.h" #include "../ocf_request.h"
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "utils_user_part.h" #include "utils_user_part.h"
static struct ocf_lst_entry *ocf_user_part_lst_getter_valid( static struct ocf_lst_entry *ocf_user_part_lst_getter_valid(

View File

@ -48,7 +48,6 @@ class CacheConfig(Structure):
_fields_ = [ _fields_ = [
("_name", c_char * MAX_CACHE_NAME_SIZE), ("_name", c_char * MAX_CACHE_NAME_SIZE),
("_cache_mode", c_uint32), ("_cache_mode", c_uint32),
("_eviction_policy", c_uint32),
("_promotion_policy", c_uint32), ("_promotion_policy", c_uint32),
("_cache_line_size", c_uint64), ("_cache_line_size", c_uint64),
("_metadata_layout", c_uint32), ("_metadata_layout", c_uint32),
@ -115,11 +114,6 @@ class CacheMode(IntEnum):
return self.value not in [CacheMode.PT, CacheMode.WO] return self.value not in [CacheMode.PT, CacheMode.WO]
class EvictionPolicy(IntEnum):
LRU = 0
DEFAULT = LRU
class PromotionPolicy(IntEnum): class PromotionPolicy(IntEnum):
ALWAYS = 0 ALWAYS = 0
NHIT = 1 NHIT = 1
@ -167,7 +161,6 @@ class Cache:
owner, owner,
name: str = "cache", name: str = "cache",
cache_mode: CacheMode = CacheMode.DEFAULT, cache_mode: CacheMode = CacheMode.DEFAULT,
eviction_policy: EvictionPolicy = EvictionPolicy.DEFAULT,
promotion_policy: PromotionPolicy = PromotionPolicy.DEFAULT, promotion_policy: PromotionPolicy = PromotionPolicy.DEFAULT,
cache_line_size: CacheLineSize = CacheLineSize.DEFAULT, cache_line_size: CacheLineSize = CacheLineSize.DEFAULT,
metadata_layout: MetadataLayout = MetadataLayout.DEFAULT, metadata_layout: MetadataLayout = MetadataLayout.DEFAULT,
@ -186,7 +179,6 @@ class Cache:
self.cfg = CacheConfig( self.cfg = CacheConfig(
_name=name.encode("ascii"), _name=name.encode("ascii"),
_cache_mode=cache_mode, _cache_mode=cache_mode,
_eviction_policy=eviction_policy,
_promotion_policy=promotion_policy, _promotion_policy=promotion_policy,
_cache_line_size=cache_line_size, _cache_line_size=cache_line_size,
_metadata_layout=metadata_layout, _metadata_layout=metadata_layout,
@ -351,7 +343,6 @@ class Cache:
"_curr_size": (ioclass_info._curr_size), "_curr_size": (ioclass_info._curr_size),
"_min_size": int(ioclass_info._min_size), "_min_size": int(ioclass_info._min_size),
"_max_size": int(ioclass_info._max_size), "_max_size": int(ioclass_info._max_size),
"_eviction_policy_type": int(ioclass_info._eviction_policy_type),
"_cleaning_policy_type": int(ioclass_info._cleaning_policy_type), "_cleaning_policy_type": int(ioclass_info._cleaning_policy_type),
} }
@ -625,7 +616,6 @@ class Cache:
"status": cache_info.fallback_pt.status, "status": cache_info.fallback_pt.status,
}, },
"state": cache_info.state, "state": cache_info.state,
"eviction_policy": EvictionPolicy(cache_info.eviction_policy),
"cleaning_policy": CleaningPolicy(cache_info.cleaning_policy), "cleaning_policy": CleaningPolicy(cache_info.cleaning_policy),
"promotion_policy": PromotionPolicy(cache_info.promotion_policy), "promotion_policy": PromotionPolicy(cache_info.promotion_policy),
"cache_line_size": line_size, "cache_line_size": line_size,

View File

@ -15,7 +15,6 @@ class IoClassInfo(Structure):
("_curr_size", c_uint32), ("_curr_size", c_uint32),
("_min_size", c_uint32), ("_min_size", c_uint32),
("_max_size", c_uint32), ("_max_size", c_uint32),
("_eviction_policy_type", c_uint8),
("_cleaning_policy_type", c_int), ("_cleaning_policy_type", c_int),
] ]

View File

@ -28,7 +28,6 @@ class CacheInfo(Structure):
("dirty_for", c_uint64), ("dirty_for", c_uint64),
("cache_mode", c_uint32), ("cache_mode", c_uint32),
("fallback_pt", _FallbackPt), ("fallback_pt", _FallbackPt),
("eviction_policy", c_uint32),
("cleaning_policy", c_uint32), ("cleaning_policy", c_uint32),
("promotion_policy", c_uint32), ("promotion_policy", c_uint32),
("cache_line_size", c_uint64), ("cache_line_size", c_uint64),

View File

@ -15,7 +15,6 @@ from pyocf.types.cache import (
Cache, Cache,
CacheMode, CacheMode,
MetadataLayout, MetadataLayout,
EvictionPolicy,
CleaningPolicy, CleaningPolicy,
) )
from pyocf.types.core import Core from pyocf.types.core import Core

View File

@ -11,7 +11,7 @@ from itertools import count
import pytest import pytest
from pyocf.ocf import OcfLib from pyocf.ocf import OcfLib
from pyocf.types.cache import Cache, CacheMode, MetadataLayout, EvictionPolicy, CleaningPolicy from pyocf.types.cache import Cache, CacheMode, MetadataLayout, CleaningPolicy
from pyocf.types.core import Core from pyocf.types.core import Core
from pyocf.types.data import Data from pyocf.types.data import Data
from pyocf.types.io import IoDir from pyocf.types.io import IoDir
@ -38,7 +38,6 @@ def test_start_check_default(pyocf_ctx):
assert stats["conf"]["cleaning_policy"] == CleaningPolicy.DEFAULT assert stats["conf"]["cleaning_policy"] == CleaningPolicy.DEFAULT
assert stats["conf"]["cache_mode"] == CacheMode.DEFAULT assert stats["conf"]["cache_mode"] == CacheMode.DEFAULT
assert stats["conf"]["cache_line_size"] == CacheLineSize.DEFAULT assert stats["conf"]["cache_line_size"] == CacheLineSize.DEFAULT
assert stats["conf"]["eviction_policy"] == EvictionPolicy.DEFAULT
core_stats = core.get_stats() core_stats = core.get_stats()
assert core_stats["seq_cutoff_policy"] == SeqCutOffPolicy.DEFAULT assert core_stats["seq_cutoff_policy"] == SeqCutOffPolicy.DEFAULT
@ -156,7 +155,6 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
stats = cache.get_stats() stats = cache.get_stats()
assert stats["conf"]["cache_mode"] == mode, "Cache mode" assert stats["conf"]["cache_mode"] == mode, "Cache mode"
assert stats["conf"]["cache_line_size"] == cls, "Cache line size" assert stats["conf"]["cache_line_size"] == cls, "Cache line size"
assert stats["conf"]["eviction_policy"] == EvictionPolicy.DEFAULT, "Eviction policy"
assert cache.get_name() == name, "Cache name" assert cache.get_name() == name, "Cache name"
# TODO: metadata_layout, metadata_volatile, max_queue_size, # TODO: metadata_layout, metadata_volatile, max_queue_size,
# queue_unblock_size, pt_unaligned_io, use_submit_fast # queue_unblock_size, pt_unaligned_io, use_submit_fast

View File

@ -13,7 +13,7 @@ from ctypes import (
) )
from tests.utils.random import RandomStringGenerator, RandomGenerator, DefaultRanges, Range from tests.utils.random import RandomStringGenerator, RandomGenerator, DefaultRanges, Range
from pyocf.types.cache import CacheMode, EvictionPolicy, MetadataLayout, PromotionPolicy from pyocf.types.cache import CacheMode, MetadataLayout, PromotionPolicy
from pyocf.types.shared import CacheLineSize from pyocf.types.shared import CacheLineSize
import pytest import pytest
@ -77,13 +77,6 @@ def not_cache_line_size_randomize(request):
return request.param return request.param
@pytest.fixture(
params=RandomGenerator(DefaultRanges.UINT32).exclude_range(enum_range(EvictionPolicy))
)
def not_eviction_policy_randomize(request):
return request.param
@pytest.fixture( @pytest.fixture(
params=RandomGenerator(DefaultRanges.UINT32).exclude_range(enum_range(PromotionPolicy)) params=RandomGenerator(DefaultRanges.UINT32).exclude_range(enum_range(PromotionPolicy))
) )

View File

@ -7,7 +7,7 @@ import logging
import pytest import pytest
from pyocf.types.cache import Cache, CacheMode, EvictionPolicy, MetadataLayout, PromotionPolicy from pyocf.types.cache import Cache, CacheMode, MetadataLayout, PromotionPolicy
from pyocf.types.shared import OcfError, CacheLineSize from pyocf.types.shared import OcfError, CacheLineSize
from pyocf.types.volume import Volume from pyocf.types.volume import Volume
from pyocf.utils import Size from pyocf.utils import Size
@ -73,25 +73,6 @@ def test_fuzzy_start_name(pyocf_ctx, string_randomize, cm, cls):
cache.stop() cache.stop()
@pytest.mark.security
@pytest.mark.parametrize("cm", CacheMode)
@pytest.mark.parametrize("cls", CacheLineSize)
def test_fuzzy_start_eviction_policy(pyocf_ctx, not_eviction_policy_randomize, cm, cls):
"""
Test whether it is impossible to start cache with invalid eviction policy value.
:param pyocf_ctx: basic pyocf context fixture
:param c_uint32_randomize: eviction policy enum value to start cache with
:param cm: cache mode value to start cache with
:param cls: cache line size value to start cache with
"""
with pytest.raises(OcfError, match="OCF_ERR_INVAL"):
try_start_cache(
eviction_policy=not_eviction_policy_randomize,
cache_mode=cm,
cache_line_size=cls
)
@pytest.mark.security @pytest.mark.security
@pytest.mark.parametrize("cm", CacheMode) @pytest.mark.parametrize("cm", CacheMode)
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)

View File

@ -18,7 +18,6 @@
#include "print_desc.h" #include "print_desc.h"
#include "eviction.h" #include "eviction.h"
#include "ops.h"
#include "../utils/utils_user_part.h" #include "../utils/utils_user_part.h"
#include "eviction/eviction.c/eviction_generated_wraps.c" #include "eviction/eviction.c/eviction_generated_wraps.c"
@ -38,11 +37,6 @@ uint32_t __wrap_ocf_lru_num_free(ocf_cache_t cache)
return 0; return 0;
} }
bool __wrap_ocf_eviction_can_evict(ocf_cache_t cache)
{
return true;
}
uint32_t __wrap_ocf_user_part_overflow_size(struct ocf_cache *cache, uint32_t __wrap_ocf_user_part_overflow_size(struct ocf_cache *cache,
struct ocf_user_part *user_part) struct ocf_user_part *user_part)
{ {
@ -59,21 +53,20 @@ uint32_t __wrap_ocf_evict_calculate(ocf_cache_t cache,
return min(tcache->evictable[user_part->part.id], to_evict); return min(tcache->evictable[user_part->part.id], to_evict);
} }
uint32_t __wrap_ocf_request_space(struct ocf_cache *cache, uint32_t __wrap_evp_lru_req_clines(struct ocf_request *req,
ocf_queue_t io_queue, struct ocf_part *part, struct ocf_part *src_part, uint32_t cline_no)
uint32_t clines)
{ {
struct test_cache *tcache = (struct test_cache *)cache; struct test_cache *tcache = (struct test_cache *)req->cache;
unsigned overflown_consumed; unsigned overflown_consumed;
overflown_consumed = min(clines, tcache->overflow[part->id]); overflown_consumed = min(cline_no, tcache->overflow[src_part->id]);
tcache->overflow[part->id] -= overflown_consumed; tcache->overflow[src_part->id] -= overflown_consumed;
tcache->evictable[part->id] -= clines; tcache->evictable[src_part->id] -= cline_no;
tcache->req_unmapped -= clines; tcache->req_unmapped -= cline_no;
check_expected(part); check_expected(src_part);
check_expected(clines); check_expected(cline_no);
function_called(); function_called();
return mock(); return mock();
@ -200,10 +193,10 @@ uint32_t __wrap_ocf_engine_unmapped_count(struct ocf_request *req)
#define _expect_evict_call(tcache, part_id, req_count, ret_count) \ #define _expect_evict_call(tcache, part_id, req_count, ret_count) \
do { \ do { \
expect_value(__wrap_ocf_request_space, part, &tcache.cache.user_parts[part_id].part); \ expect_value(__wrap_evp_lru_req_clines, src_part, &tcache.cache.user_parts[part_id].part); \
expect_value(__wrap_ocf_request_space, clines, req_count); \ expect_value(__wrap_evp_lru_req_clines, cline_no, req_count); \
expect_function_call(__wrap_ocf_request_space); \ expect_function_call(__wrap_evp_lru_req_clines); \
will_return(__wrap_ocf_request_space, ret_count); \ will_return(__wrap_evp_lru_req_clines, ret_count); \
} while (false); } while (false);
static void ocf_remap_do_test01(void **state) static void ocf_remap_do_test01(void **state)

View File

@ -28,7 +28,6 @@
#include "eviction.h" #include "eviction.h"
#include "lru.h" #include "lru.h"
#include "ops.h"
#include "../utils/utils_cleaner.h" #include "../utils/utils_cleaner.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../concurrency/ocf_concurrency.h" #include "../concurrency/ocf_concurrency.h"

View File

@ -36,7 +36,7 @@ ocf_mngt_cache_mode_has_lazy_write
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_pipeline.h" #include "../utils/utils_pipeline.h"
#include "../concurrency/ocf_concurrency.h" #include "../concurrency/ocf_concurrency.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "../ocf_ctx_priv.h" #include "../ocf_ctx_priv.h"
#include "../cleaning/cleaning.h" #include "../cleaning/cleaning.h"

View File

@ -30,7 +30,7 @@
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_pipeline.h" #include "../utils/utils_pipeline.h"
#include "../concurrency/ocf_concurrency.h" #include "../concurrency/ocf_concurrency.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "../ocf_ctx_priv.h" #include "../ocf_ctx_priv.h"
#include "../cleaning/cleaning.h" #include "../cleaning/cleaning.h"

View File

@ -32,7 +32,7 @@
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../utils/utils_user_part.h" #include "../utils/utils_user_part.h"
#include "../eviction/ops.h" #include "../eviction/lru.h"
#include "ocf_env.h" #include "ocf_env.h"
#include "mngt/ocf_mngt_io_class.c/ocf_mngt_io_class_generated_wraps.c" #include "mngt/ocf_mngt_io_class.c/ocf_mngt_io_class_generated_wraps.c"