Rename "evict" to "remap" across the entire repo
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
4f217b91a5
commit
fac35d34a2
@ -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;
|
||||
|
||||
status = space_managment_evict_do(req);
|
||||
status = ocf_space_managment_remap_do(req);
|
||||
if (status == LOOKUP_MISS) {
|
||||
/* mark error */
|
||||
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),
|
||||
req);
|
||||
|
||||
/* request cleaning */
|
||||
ocf_req_set_clean_eviction(req);
|
||||
ocf_req_set_cleaning_required(req);
|
||||
|
||||
/* unmap inserted and replaced cachelines */
|
||||
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_engine_evict(req);
|
||||
ocf_engine_remap(req);
|
||||
|
||||
if (!ocf_req_test_mapping_error(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);
|
||||
|
||||
if (ocf_req_test_clean_eviction(req)) {
|
||||
ocf_eviction_flush_dirty(req->cache, user_part, req->io_queue,
|
||||
if (ocf_req_is_cleaning_required(req)) {
|
||||
ocf_lru_flush_dirty(req->cache, user_part, req->io_queue,
|
||||
128);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,8 @@ static inline uint32_t ocf_evict_part_do(struct ocf_request *req,
|
||||
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,
|
||||
@ -110,8 +111,8 @@ static inline uint32_t ocf_evict_user_partitions(ocf_cache_t cache,
|
||||
if (overflown_only)
|
||||
to_evict = OCF_MIN(to_evict, overflow_size);
|
||||
|
||||
evicted += ocf_eviction_need_space(cache, req,
|
||||
&user_part->part, to_evict);
|
||||
evicted += ocf_request_space(cache, req, &user_part->part,
|
||||
to_evict);
|
||||
|
||||
if (evicted >= evict_cline_no) {
|
||||
/* Evicted requested number of cache line, stop
|
||||
@ -125,55 +126,55 @@ out:
|
||||
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_part_id_t target_part_id = req->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 evicted = 0;
|
||||
uint32_t remap_cline_no = ocf_engine_unmapped_count(req);
|
||||
uint32_t remapped = 0;
|
||||
|
||||
/* First attempt to map from freelist */
|
||||
if (ocf_lru_num_free(cache) > 0) {
|
||||
evicted = ocf_eviction_need_space(cache, req, &cache->free,
|
||||
evict_cline_no);
|
||||
remapped = ocf_request_space(cache, req, &cache->free,
|
||||
remap_cline_no);
|
||||
}
|
||||
if (evicted >= evict_cline_no)
|
||||
return evicted;
|
||||
if (remapped >= remap_cline_no)
|
||||
return remapped;
|
||||
|
||||
/* Attempt to evict overflown partitions in order to
|
||||
* achieve configured maximum size. Ignoring partitions
|
||||
* priority in this case, as overflown partitions should
|
||||
* free its cachelines regardless of destination partition
|
||||
* 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);
|
||||
if (evicted >= evict_cline_no)
|
||||
return evicted;
|
||||
if (remapped >= remap_cline_no)
|
||||
return remapped;
|
||||
|
||||
/* Not enough cachelines in overflown partitions. Go through
|
||||
* partitions with priority <= target partition and attempt
|
||||
* to evict from those. */
|
||||
evict_cline_no -= evicted;
|
||||
evicted += ocf_evict_user_partitions(cache, req, evict_cline_no,
|
||||
remap_cline_no -= remapped;
|
||||
remapped += ocf_evict_user_partitions(cache, req, remap_cline_no,
|
||||
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 evicted;
|
||||
uint32_t remapped;
|
||||
struct ocf_user_part *req_part = &req->cache->user_parts[req->part_id];
|
||||
|
||||
if (ocf_req_part_evict(req)) {
|
||||
evicted = ocf_evict_part_do(req, req_part);
|
||||
remapped = ocf_evict_part_do(req, req_part);
|
||||
} else {
|
||||
evicted = ocf_evict_do(req);
|
||||
remapped = ocf_remap_do(req);
|
||||
}
|
||||
|
||||
if (needed <= evicted)
|
||||
if (needed <= remapped)
|
||||
return LOOKUP_REMAPPED;
|
||||
|
||||
return LOOKUP_MISS;
|
||||
|
@ -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_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);
|
||||
|
||||
|
@ -52,7 +52,7 @@ static inline bool ocf_eviction_can_evict(struct ocf_cache *cache)
|
||||
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,
|
||||
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,
|
||||
uint32_t count)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ struct ocf_req_info {
|
||||
uint32_t mapping_error : 1;
|
||||
/*!< 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 */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@
|
||||
* <tested_function>ocf_prepare_clines_miss</tested_function>
|
||||
* <functions_to_leave>
|
||||
* ocf_prepare_clines_evict
|
||||
* ocf_engine_evict
|
||||
* ocf_engine_remap
|
||||
* ocf_req_set_mapping_error
|
||||
* ocf_req_test_mapping_error
|
||||
* 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();
|
||||
return mock();
|
||||
@ -89,8 +89,8 @@ static void ocf_prepare_clines_miss_test01(void **state)
|
||||
print_test_description("\tEviction success\n");
|
||||
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED);
|
||||
expect_function_call(__wrap_ocf_space_managment_remap_do);
|
||||
will_return_always(__wrap_ocf_space_managment_remap_do, LOOKUP_REMAPPED);
|
||||
|
||||
ocf_prepare_clines_miss(&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);
|
||||
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
|
||||
expect_function_call(__wrap_ocf_space_managment_remap_do);
|
||||
will_return(__wrap_ocf_space_managment_remap_do, LOOKUP_MISS);
|
||||
|
||||
ocf_prepare_clines_miss(&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");
|
||||
|
||||
will_return_always(__wrap_ocf_user_part_has_space, true);
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED);
|
||||
expect_function_call(__wrap_ocf_space_managment_remap_do);
|
||||
will_return_always(__wrap_ocf_space_managment_remap_do, LOOKUP_REMAPPED);
|
||||
|
||||
ocf_prepare_clines_miss(&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);
|
||||
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
|
||||
expect_function_call(__wrap_ocf_space_managment_remap_do);
|
||||
will_return(__wrap_ocf_space_managment_remap_do, LOOKUP_MISS);
|
||||
|
||||
ocf_prepare_clines_miss(&req);
|
||||
assert(ocf_req_test_mapping_error(&req));
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* <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>
|
||||
ocf_evict_user_partitions
|
||||
* </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);
|
||||
}
|
||||
|
||||
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,
|
||||
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) \
|
||||
do { \
|
||||
expect_value(__wrap_ocf_eviction_need_space, part, &tcache.cache.user_parts[part_id].part); \
|
||||
expect_value(__wrap_ocf_eviction_need_space, clines, req_count); \
|
||||
expect_function_call(__wrap_ocf_eviction_need_space); \
|
||||
will_return(__wrap_ocf_eviction_need_space, ret_count); \
|
||||
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); \
|
||||
} while (false);
|
||||
|
||||
static void ocf_evict_do_test01(void **state)
|
||||
static void ocf_remap_do_test01(void **state)
|
||||
{
|
||||
struct test_cache tcache = {};
|
||||
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;
|
||||
|
||||
_expect_evict_call(tcache, 10, 50, 50);
|
||||
evicted = ocf_evict_do(&req);
|
||||
evicted = ocf_remap_do(&req);
|
||||
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 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);
|
||||
|
||||
evicted = ocf_evict_do(&req);
|
||||
evicted = ocf_remap_do(&req);
|
||||
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 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, 17, 50, 50);
|
||||
|
||||
evicted = ocf_evict_do(&req);
|
||||
evicted = ocf_remap_do(&req);
|
||||
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 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, 17, 80, 80);
|
||||
|
||||
evicted = ocf_evict_do(&req);
|
||||
evicted = ocf_remap_do(&req);
|
||||
assert_int_equal(evicted, 580);
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(ocf_evict_do_test01),
|
||||
cmocka_unit_test(ocf_evict_do_test02),
|
||||
cmocka_unit_test(ocf_evict_do_test03),
|
||||
cmocka_unit_test(ocf_evict_do_test04)
|
||||
cmocka_unit_test(ocf_remap_do_test01),
|
||||
cmocka_unit_test(ocf_remap_do_test02),
|
||||
cmocka_unit_test(ocf_remap_do_test03),
|
||||
cmocka_unit_test(ocf_remap_do_test04)
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user