Rename "evict" to "remap" across the entire repo

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-05-25 20:21:01 +02:00
parent 4f217b91a5
commit fac35d34a2
7 changed files with 65 additions and 64 deletions

View File

@ -385,21 +385,21 @@ static void _ocf_engine_clean_end(void *private_data, int error)
} }
} }
static void ocf_engine_evict(struct ocf_request *req) static void ocf_engine_remap(struct ocf_request *req)
{ {
int status; int status;
status = space_managment_evict_do(req); status = ocf_space_managment_remap_do(req);
if (status == LOOKUP_MISS) { if (status == LOOKUP_MISS) {
/* mark error */ /* mark error */
ocf_req_set_mapping_error(req); ocf_req_set_mapping_error(req);
/* unlock cachelines locked during eviction */ /* unlock cachelines locked during remapping */
ocf_req_unlock(ocf_cache_line_concurrency(req->cache), ocf_req_unlock(ocf_cache_line_concurrency(req->cache),
req); req);
/* request cleaning */ /* request cleaning */
ocf_req_set_clean_eviction(req); ocf_req_set_cleaning_required(req);
/* unmap inserted and replaced cachelines */ /* unmap inserted and replaced cachelines */
ocf_engine_map_hndl_error(req->cache, req); ocf_engine_map_hndl_error(req->cache, req);
@ -439,7 +439,7 @@ static inline void ocf_prepare_clines_miss(struct ocf_request *req)
ocf_req_clear_part_evict(req); ocf_req_clear_part_evict(req);
} }
ocf_engine_evict(req); ocf_engine_remap(req);
if (!ocf_req_test_mapping_error(req)) if (!ocf_req_test_mapping_error(req))
ocf_promotion_req_purge(req->cache->promotion_policy, req); ocf_promotion_req_purge(req->cache->promotion_policy, req);
@ -517,8 +517,8 @@ 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_test_clean_eviction(req)) { if (ocf_req_is_cleaning_required(req)) {
ocf_eviction_flush_dirty(req->cache, user_part, req->io_queue, ocf_lru_flush_dirty(req->cache, user_part, req->io_queue,
128); 128);
} }

View File

@ -60,7 +60,8 @@ static inline uint32_t ocf_evict_part_do(struct ocf_request *req,
return 0; return 0;
} }
return ocf_eviction_need_space(req->cache, req, &user_part->part, to_evict); return ocf_request_space(req->cache, req, &user_part->part,
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,
@ -110,8 +111,8 @@ 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_eviction_need_space(cache, req, evicted += ocf_request_space(cache, req, &user_part->part,
&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
@ -125,55 +126,55 @@ out:
return evicted; return evicted;
} }
static inline uint32_t ocf_evict_do(struct ocf_request *req) static inline uint32_t ocf_remap_do(struct ocf_request *req)
{ {
ocf_cache_t cache = req->cache; ocf_cache_t cache = req->cache;
ocf_part_id_t target_part_id = req->part_id; ocf_part_id_t target_part_id = req->part_id;
struct ocf_user_part *target_part = &cache->user_parts[target_part_id]; struct ocf_user_part *target_part = &cache->user_parts[target_part_id];
uint32_t evict_cline_no = ocf_engine_unmapped_count(req); uint32_t remap_cline_no = ocf_engine_unmapped_count(req);
uint32_t evicted = 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) {
evicted = ocf_eviction_need_space(cache, req, &cache->free, remapped = ocf_request_space(cache, req, &cache->free,
evict_cline_no); remap_cline_no);
} }
if (evicted >= evict_cline_no) if (remapped >= remap_cline_no)
return evicted; return remapped;
/* Attempt to evict overflown partitions in order to /* Attempt to evict overflown partitions in order to
* achieve configured maximum size. Ignoring partitions * achieve configured maximum size. Ignoring partitions
* priority in this case, as overflown partitions should * priority in this case, as overflown partitions should
* free its cachelines regardless of destination partition * free its cachelines regardless of destination partition
* priority. */ * priority. */
evicted += ocf_evict_user_partitions(cache, req, evict_cline_no, remapped += ocf_evict_user_partitions(cache, req, remap_cline_no,
true, OCF_IO_CLASS_PRIO_PINNED); true, OCF_IO_CLASS_PRIO_PINNED);
if (evicted >= evict_cline_no) if (remapped >= remap_cline_no)
return evicted; return remapped;
/* Not enough cachelines in overflown partitions. Go through /* Not enough cachelines in overflown partitions. Go through
* partitions with priority <= target partition and attempt * partitions with priority <= target partition and attempt
* to evict from those. */ * to evict from those. */
evict_cline_no -= evicted; remap_cline_no -= remapped;
evicted += ocf_evict_user_partitions(cache, req, evict_cline_no, remapped += ocf_evict_user_partitions(cache, req, remap_cline_no,
false, target_part->config->priority); false, target_part->config->priority);
return evicted; return remapped;
} }
int space_managment_evict_do(struct ocf_request *req) int ocf_space_managment_remap_do(struct ocf_request *req)
{ {
uint32_t needed = ocf_engine_unmapped_count(req); uint32_t needed = ocf_engine_unmapped_count(req);
uint32_t evicted; uint32_t remapped;
struct ocf_user_part *req_part = &req->cache->user_parts[req->part_id]; struct ocf_user_part *req_part = &req->cache->user_parts[req->part_id];
if (ocf_req_part_evict(req)) { if (ocf_req_part_evict(req)) {
evicted = ocf_evict_part_do(req, req_part); remapped = ocf_evict_part_do(req, req_part);
} else { } else {
evicted = ocf_evict_do(req); remapped = ocf_remap_do(req);
} }
if (needed <= evicted) if (needed <= remapped)
return LOOKUP_REMAPPED; return LOOKUP_REMAPPED;
return LOOKUP_MISS; return LOOKUP_MISS;

View File

@ -64,7 +64,7 @@ extern struct eviction_policy_ops evict_policy_ops[ocf_eviction_max];
* 'LOOKUP_HIT' if evicted enough cachelines to serve @req * 'LOOKUP_HIT' if evicted enough cachelines to serve @req
* 'LOOKUP_MISS' otherwise * 'LOOKUP_MISS' otherwise
*/ */
int space_managment_evict_do(struct ocf_request *req); 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);

View File

@ -52,7 +52,7 @@ static inline bool ocf_eviction_can_evict(struct ocf_cache *cache)
return true; return true;
} }
static inline uint32_t ocf_eviction_need_space(ocf_cache_t cache, static inline uint32_t ocf_request_space(ocf_cache_t cache,
struct ocf_request *req, struct ocf_part *part, struct ocf_request *req, struct ocf_part *part,
uint32_t clines) uint32_t clines)
{ {
@ -93,7 +93,7 @@ static inline void ocf_eviction_initialize(struct ocf_cache *cache,
} }
} }
static inline void ocf_eviction_flush_dirty(ocf_cache_t cache, static inline void ocf_lru_flush_dirty(ocf_cache_t cache,
struct ocf_user_part *user_part, ocf_queue_t io_queue, struct ocf_user_part *user_part, ocf_queue_t io_queue,
uint32_t count) uint32_t count)
{ {

View File

@ -33,7 +33,7 @@ struct ocf_req_info {
uint32_t mapping_error : 1; uint32_t mapping_error : 1;
/*!< Core lines in this request were not mapped into cache */ /*!< Core lines in this request were not mapped into cache */
uint32_t clean_eviction : 1; uint32_t cleaning_required : 1;
/*!< Eviction failed, need to request cleaning */ /*!< Eviction failed, need to request cleaning */
uint32_t core_error : 1; uint32_t core_error : 1;
@ -403,14 +403,14 @@ static inline bool ocf_req_test_mapping_error(struct ocf_request *req)
return req->info.mapping_error; return req->info.mapping_error;
} }
static inline void ocf_req_set_clean_eviction(struct ocf_request *req) static inline void ocf_req_set_cleaning_required(struct ocf_request *req)
{ {
req->info.clean_eviction = true; req->info.cleaning_required = true;
} }
static inline bool ocf_req_test_clean_eviction(struct ocf_request *req) static inline bool ocf_req_is_cleaning_required(struct ocf_request *req)
{ {
return req->info.clean_eviction; return req->info.cleaning_required;
} }
/** /**

View File

@ -3,7 +3,7 @@
* <tested_function>ocf_prepare_clines_miss</tested_function> * <tested_function>ocf_prepare_clines_miss</tested_function>
* <functions_to_leave> * <functions_to_leave>
* ocf_prepare_clines_evict * ocf_prepare_clines_evict
* ocf_engine_evict * ocf_engine_remap
* ocf_req_set_mapping_error * ocf_req_set_mapping_error
* ocf_req_test_mapping_error * ocf_req_test_mapping_error
* ocf_req_set_part_evict * ocf_req_set_part_evict
@ -74,7 +74,7 @@ void __wrap_ocf_metadata_end_exclusive_access(
{ {
} }
int __wrap_space_managment_evict_do(struct ocf_request *req) int __wrap_ocf_space_managment_remap_do(struct ocf_request *req)
{ {
function_called(); function_called();
return mock(); return mock();
@ -89,8 +89,8 @@ static void ocf_prepare_clines_miss_test01(void **state)
print_test_description("\tEviction success\n"); print_test_description("\tEviction success\n");
will_return_always(__wrap_ocf_user_part_has_space, false); will_return_always(__wrap_ocf_user_part_has_space, false);
expect_function_call(__wrap_space_managment_evict_do); expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED); will_return_always(__wrap_ocf_space_managment_remap_do, LOOKUP_REMAPPED);
ocf_prepare_clines_miss(&req); ocf_prepare_clines_miss(&req);
assert(!ocf_req_test_mapping_error(&req)); assert(!ocf_req_test_mapping_error(&req));
@ -107,8 +107,8 @@ static void ocf_prepare_clines_miss_test02(void **state)
will_return_always(__wrap_ocf_user_part_has_space, false); will_return_always(__wrap_ocf_user_part_has_space, false);
expect_function_call(__wrap_space_managment_evict_do); expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS); will_return(__wrap_ocf_space_managment_remap_do, LOOKUP_MISS);
ocf_prepare_clines_miss(&req); ocf_prepare_clines_miss(&req);
assert(ocf_req_test_mapping_error(&req)); assert(ocf_req_test_mapping_error(&req));
@ -124,8 +124,8 @@ static void ocf_prepare_clines_miss_test03(void **state)
print_test_description("\tEviction success\n"); print_test_description("\tEviction success\n");
will_return_always(__wrap_ocf_user_part_has_space, true); will_return_always(__wrap_ocf_user_part_has_space, true);
expect_function_call(__wrap_space_managment_evict_do); expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED); will_return_always(__wrap_ocf_space_managment_remap_do, LOOKUP_REMAPPED);
ocf_prepare_clines_miss(&req); ocf_prepare_clines_miss(&req);
assert(!ocf_req_test_mapping_error(&req)); assert(!ocf_req_test_mapping_error(&req));
@ -142,8 +142,8 @@ static void ocf_prepare_clines_miss_test04(void **state)
will_return_always(__wrap_ocf_user_part_has_space, true); will_return_always(__wrap_ocf_user_part_has_space, true);
expect_function_call(__wrap_space_managment_evict_do); expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS); will_return(__wrap_ocf_space_managment_remap_do, LOOKUP_MISS);
ocf_prepare_clines_miss(&req); ocf_prepare_clines_miss(&req);
assert(ocf_req_test_mapping_error(&req)); assert(ocf_req_test_mapping_error(&req));

View File

@ -1,6 +1,6 @@
/* /*
* <tested_file_path>src/eviction/eviction.c</tested_file_path> * <tested_file_path>src/eviction/eviction.c</tested_file_path>
* <tested_function>ocf_evict_do</tested_function> * <tested_function>ocf_remap_do</tested_function>
* <functions_to_leave> * <functions_to_leave>
ocf_evict_user_partitions ocf_evict_user_partitions
* </functions_to_leave> * </functions_to_leave>
@ -59,7 +59,7 @@ 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_eviction_need_space(struct ocf_cache *cache, uint32_t __wrap_ocf_request_space(struct ocf_cache *cache,
ocf_queue_t io_queue, struct ocf_part *part, ocf_queue_t io_queue, struct ocf_part *part,
uint32_t clines) uint32_t clines)
{ {
@ -200,13 +200,13 @@ 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_eviction_need_space, part, &tcache.cache.user_parts[part_id].part); \ expect_value(__wrap_ocf_request_space, part, &tcache.cache.user_parts[part_id].part); \
expect_value(__wrap_ocf_eviction_need_space, clines, req_count); \ expect_value(__wrap_ocf_request_space, clines, req_count); \
expect_function_call(__wrap_ocf_eviction_need_space); \ expect_function_call(__wrap_ocf_request_space); \
will_return(__wrap_ocf_eviction_need_space, ret_count); \ will_return(__wrap_ocf_request_space, ret_count); \
} while (false); } while (false);
static void ocf_evict_do_test01(void **state) static void ocf_remap_do_test01(void **state)
{ {
struct test_cache tcache = {}; struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 }; struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@ -220,11 +220,11 @@ static void ocf_evict_do_test01(void **state)
tcache.req_unmapped = 50; tcache.req_unmapped = 50;
_expect_evict_call(tcache, 10, 50, 50); _expect_evict_call(tcache, 10, 50, 50);
evicted = ocf_evict_do(&req); evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 50); assert_int_equal(evicted, 50);
} }
static void ocf_evict_do_test02(void **state) static void ocf_remap_do_test02(void **state)
{ {
struct test_cache tcache = {}; struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 }; struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@ -241,11 +241,11 @@ static void ocf_evict_do_test02(void **state)
_expect_evict_call(tcache, 10, 50, 50); _expect_evict_call(tcache, 10, 50, 50);
evicted = ocf_evict_do(&req); evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 50); assert_int_equal(evicted, 50);
} }
static void ocf_evict_do_test03(void **state) static void ocf_remap_do_test03(void **state)
{ {
struct test_cache tcache = {}; struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 }; struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@ -267,11 +267,11 @@ static void ocf_evict_do_test03(void **state)
_expect_evict_call(tcache, 16, 100, 100); _expect_evict_call(tcache, 16, 100, 100);
_expect_evict_call(tcache, 17, 50, 50); _expect_evict_call(tcache, 17, 50, 50);
evicted = ocf_evict_do(&req); evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 350); assert_int_equal(evicted, 350);
} }
static void ocf_evict_do_test04(void **state) static void ocf_remap_do_test04(void **state)
{ {
struct test_cache tcache = {}; struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 }; struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@ -301,16 +301,16 @@ static void ocf_evict_do_test04(void **state)
_expect_evict_call(tcache, 16, 100, 100); _expect_evict_call(tcache, 16, 100, 100);
_expect_evict_call(tcache, 17, 80, 80); _expect_evict_call(tcache, 17, 80, 80);
evicted = ocf_evict_do(&req); evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 580); assert_int_equal(evicted, 580);
} }
int main(void) int main(void)
{ {
const struct CMUnitTest tests[] = { const struct CMUnitTest tests[] = {
cmocka_unit_test(ocf_evict_do_test01), cmocka_unit_test(ocf_remap_do_test01),
cmocka_unit_test(ocf_evict_do_test02), cmocka_unit_test(ocf_remap_do_test02),
cmocka_unit_test(ocf_evict_do_test03), cmocka_unit_test(ocf_remap_do_test03),
cmocka_unit_test(ocf_evict_do_test04) cmocka_unit_test(ocf_remap_do_test04)
}; };
return cmocka_run_group_tests(tests, NULL, NULL); return cmocka_run_group_tests(tests, NULL, NULL);