From e26ca303995f9015ebaf03778a785f5084a07996 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 12 Nov 2020 02:55:08 -0500 Subject: [PATCH] Track explicit number of cachelines to be reparted Instead of redunant calculating number of cachlines to be reparted, keep this information in request's info Signed-off-by: Michal Mielewczyk --- src/engine/engine_common.c | 1 + src/engine/engine_common.h | 26 ++++++++++++++++++++++++++ src/ocf_request.h | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/engine/engine_common.c b/src/engine/engine_common.c index 9e8b0ee..492ee28 100644 --- a/src/engine/engine_common.c +++ b/src/engine/engine_common.c @@ -128,6 +128,7 @@ void ocf_engine_update_req_info(struct ocf_cache *cache, * Need to move this cache line into other partition */ _entry->re_part = req->info.re_part = true; + req->info.re_part_no++; } break; diff --git a/src/engine/engine_common.h b/src/engine/engine_common.h index 2557c64..8ec9d0c 100644 --- a/src/engine/engine_common.h +++ b/src/engine/engine_common.h @@ -47,6 +47,20 @@ static inline bool ocf_engine_is_hit(struct ocf_request *req) */ #define ocf_engine_is_miss(req) (!ocf_engine_is_hit(req)) +/** + * @brief Check if all the cache lines are assigned to a good partition + * + * @param req OCF request + * + * @retval true request's cache lines are assigned to a good partition + * @retval false some of the request's cache lines needs to be reassigned to + * a target partition + */ +static inline bool ocf_engine_needs_repart(struct ocf_request *req) +{ + return req->info.re_part_no > 0; +} + /** * @brief Check if all cache lines are mapped fully * @@ -98,6 +112,18 @@ static inline uint32_t ocf_engine_unmapped_count(struct ocf_request *req) return req->core_line_count - (req->info.hit_no + req->info.invalid_no); } +/** + * @brief Get number of cache lines to repart + * + * @param req OCF request + * + * @retval Number of cache lines to repart + */ +static inline uint32_t ocf_engine_repart_count(struct ocf_request *req) +{ + return req->info.re_part_no; +} + /** * @brief Get number of IOs to perform cache read or write * diff --git a/src/ocf_request.h b/src/ocf_request.h index 21885b2..4527901 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -13,9 +13,10 @@ struct ocf_req_allocator; struct ocf_req_info { - /* Number of hits, invalid, misses. */ + /* Number of hits, invalid, misses, reparts. */ unsigned int hit_no; unsigned int invalid_no; + unsigned int re_part_no; uint32_t dirty_all; /*!< Number of dirty line in request*/