Add promotion policy API and use it in I/O path

Promotion policy is supposed to perform ALRU noise filtering by
eliminating one-hit wonders being added to cache and polluting it.

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial
2019-07-11 12:19:29 +02:00
parent 999f3f7245
commit 917cbd859a
20 changed files with 409 additions and 21 deletions

View File

@@ -15,6 +15,7 @@
#include "../utils/utils_cleaner.h"
#include "../metadata/metadata.h"
#include "../eviction/eviction.h"
#include "../promotion/promotion.h"
void ocf_engine_error(struct ocf_request *req,
bool stop_cache, const char *msg)
@@ -171,6 +172,7 @@ void ocf_engine_traverse(struct ocf_request *req)
if (entry->status != LOOKUP_HIT) {
req->info.seq_req = false;
/* There is miss then lookup for next map entry */
OCF_DEBUG_PARAM(cache, "Miss, core line = %llu",
entry->core_line);
@@ -249,7 +251,7 @@ static void ocf_engine_map_cache_line(struct ocf_request *req,
ocf_cleaning_t clean_policy_type;
if (cache->device->freelist_part->curr_size == 0) {
req->info.eviction_error = 1;
req->info.mapping_error = 1;
return;
}
@@ -320,11 +322,16 @@ void ocf_engine_map(struct ocf_request *req)
int status = LOOKUP_MAPPED;
ocf_core_id_t core_id = ocf_core_get_id(req->core);
if (!ocf_promotion_req_should_promote(cache->promotion_policy, req)) {
req->info.mapping_error = 1;
return;
}
if (ocf_engine_unmapped_count(req))
status = space_managment_evict_do(cache, req,
ocf_engine_unmapped_count(req));
if (req->info.eviction_error)
if (req->info.mapping_error)
return;
ocf_req_clear_info(req);
@@ -342,7 +349,7 @@ void ocf_engine_map(struct ocf_request *req)
ocf_engine_map_cache_line(req, entry->core_line,
entry->hash_key, &entry->coll_idx);
if (req->info.eviction_error) {
if (req->info.mapping_error) {
/*
* Eviction error (mapping error), need to
* clean, return and do pass through
@@ -364,6 +371,12 @@ void ocf_engine_map(struct ocf_request *req)
}
if (!req->info.mapping_error) {
/* request has been inserted into cache - purge it from promotion
* policy */
ocf_promotion_req_purge(cache->promotion_policy, req);
}
OCF_DEBUG_PARAM(req->cache, "Sequential - %s", req->info.seq_req ?
"Yes" : "No");
}

View File

@@ -60,6 +60,8 @@ static void _ocf_discard_core_complete(struct ocf_io *io, int error)
OCF_DEBUG_RQ(req, "Core DISCARD Completion");
ocf_promotion_req_purge(req->cache->promotion_policy, req);
_ocf_discard_complete_req(req, error);
ocf_io_put(io);

View File

@@ -269,7 +269,7 @@ int ocf_read_generic(struct ocf_request *req)
*/
ocf_engine_map(req);
if (!req->info.eviction_error) {
if (!req->info.mapping_error) {
if (ocf_engine_is_hit(req)) {
/* After mapping turns out there is hit,
* so lock OCF request for read access
@@ -287,7 +287,7 @@ int ocf_read_generic(struct ocf_request *req)
/*- END Metadata WR access -----------------------------------*/
}
if (!req->info.eviction_error) {
if (!req->info.mapping_error) {
if (lock >= 0) {
if (lock != OCF_LOCK_ACQUIRED) {
/* Lock was not acquired, need to wait for resume */

View File

@@ -204,7 +204,7 @@ int ocf_write_wb(struct ocf_request *req)
*/
ocf_engine_map(req);
if (!req->info.eviction_error) {
if (!req->info.mapping_error) {
/* Lock request for WRITE access */
lock = ocf_req_trylock_wr(req);
}
@@ -212,7 +212,7 @@ int ocf_write_wb(struct ocf_request *req)
OCF_METADATA_UNLOCK_WR(); /*- END Metadata WR access ---------*/
}
if (!req->info.eviction_error) {
if (!req->info.mapping_error) {
if (lock >= 0) {
if (lock != OCF_LOCK_ACQUIRED) {
/* WR lock was not acquired, need to wait for resume */

View File

@@ -197,7 +197,7 @@ int ocf_write_wt(struct ocf_request *req)
*/
ocf_engine_map(req);
if (!req->info.eviction_error) {
if (!req->info.mapping_error) {
/* Lock request for WRITE access */
lock = ocf_req_trylock_wr(req);
}
@@ -205,7 +205,7 @@ int ocf_write_wt(struct ocf_request *req)
OCF_METADATA_UNLOCK_WR(); /*- END Metadata WR access ---------*/
}
if (!req->info.eviction_error) {
if (!req->info.mapping_error) {
if (lock >= 0) {
if (lock != OCF_LOCK_ACQUIRED) {
/* WR lock was not acquired, need to wait for resume */