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

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

View File

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

View File

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

View File

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

View File

@@ -11,7 +11,7 @@ from itertools import count
import pytest
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.data import Data
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"]["cache_mode"] == CacheMode.DEFAULT
assert stats["conf"]["cache_line_size"] == CacheLineSize.DEFAULT
assert stats["conf"]["eviction_policy"] == EvictionPolicy.DEFAULT
core_stats = core.get_stats()
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()
assert stats["conf"]["cache_mode"] == mode, "Cache mode"
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"
# TODO: metadata_layout, metadata_volatile, max_queue_size,
# 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 pyocf.types.cache import CacheMode, EvictionPolicy, MetadataLayout, PromotionPolicy
from pyocf.types.cache import CacheMode, MetadataLayout, PromotionPolicy
from pyocf.types.shared import CacheLineSize
import pytest
@@ -77,13 +77,6 @@ def not_cache_line_size_randomize(request):
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(
params=RandomGenerator(DefaultRanges.UINT32).exclude_range(enum_range(PromotionPolicy))
)

View File

@@ -7,7 +7,7 @@ import logging
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.volume import Volume
from pyocf.utils import Size
@@ -73,25 +73,6 @@ def test_fuzzy_start_name(pyocf_ctx, string_randomize, cm, cls):
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.parametrize("cm", CacheMode)
@pytest.mark.parametrize("cls", CacheLineSize)

View File

@@ -18,7 +18,6 @@
#include "print_desc.h"
#include "eviction.h"
#include "ops.h"
#include "../utils/utils_user_part.h"
#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;
}
bool __wrap_ocf_eviction_can_evict(ocf_cache_t cache)
{
return true;
}
uint32_t __wrap_ocf_user_part_overflow_size(struct ocf_cache *cache,
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);
}
uint32_t __wrap_ocf_request_space(struct ocf_cache *cache,
ocf_queue_t io_queue, struct ocf_part *part,
uint32_t clines)
uint32_t __wrap_evp_lru_req_clines(struct ocf_request *req,
struct ocf_part *src_part, uint32_t cline_no)
{
struct test_cache *tcache = (struct test_cache *)cache;
struct test_cache *tcache = (struct test_cache *)req->cache;
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->evictable[part->id] -= clines;
tcache->req_unmapped -= clines;
tcache->overflow[src_part->id] -= overflown_consumed;
tcache->evictable[src_part->id] -= cline_no;
tcache->req_unmapped -= cline_no;
check_expected(part);
check_expected(clines);
check_expected(src_part);
check_expected(cline_no);
function_called();
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) \
do { \
expect_value(__wrap_ocf_request_space, part, &tcache.cache.user_parts[part_id].part); \
expect_value(__wrap_ocf_request_space, clines, req_count); \
expect_function_call(__wrap_ocf_request_space); \
will_return(__wrap_ocf_request_space, ret_count); \
expect_value(__wrap_evp_lru_req_clines, src_part, &tcache.cache.user_parts[part_id].part); \
expect_value(__wrap_evp_lru_req_clines, cline_no, req_count); \
expect_function_call(__wrap_evp_lru_req_clines); \
will_return(__wrap_evp_lru_req_clines, ret_count); \
} while (false);
static void ocf_remap_do_test01(void **state)

View File

@@ -28,7 +28,6 @@
#include "eviction.h"
#include "lru.h"
#include "ops.h"
#include "../utils/utils_cleaner.h"
#include "../utils/utils_cache_line.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_pipeline.h"
#include "../concurrency/ocf_concurrency.h"
#include "../eviction/ops.h"
#include "../eviction/lru.h"
#include "../ocf_ctx_priv.h"
#include "../cleaning/cleaning.h"

View File

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

View File

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