Remove eviction policy abstraction
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
]
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -15,7 +15,6 @@ from pyocf.types.cache import (
|
||||
Cache,
|
||||
CacheMode,
|
||||
MetadataLayout,
|
||||
EvictionPolicy,
|
||||
CleaningPolicy,
|
||||
)
|
||||
from pyocf.types.core import Core
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user