Change cacheline concurrency constructor params
Provide number of cachelines as the cacheline concurrency construtor param instead of reading it from cache. The purpose of this change is to improve testability. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
cf5f82b253
commit
c7fc4fff39
@ -69,14 +69,12 @@ struct ocf_cache_line_concurrency {
|
||||
#define ALLOCATOR_NAME_MAX (sizeof(ALLOCATOR_NAME_FMT) + OCF_CACHE_NAME_SIZE)
|
||||
|
||||
int ocf_cache_line_concurrency_init(struct ocf_cache_line_concurrency **self,
|
||||
ocf_cache_t cache)
|
||||
unsigned num_clines, ocf_cache_t cache)
|
||||
{
|
||||
uint32_t i;
|
||||
int error = 0;
|
||||
struct ocf_cache_line_concurrency *c;
|
||||
char name[ALLOCATOR_NAME_MAX];
|
||||
ocf_cache_line_t line_entries = ocf_metadata_collision_table_entries(
|
||||
cache);
|
||||
|
||||
OCF_DEBUG_TRACE(cache);
|
||||
|
||||
@ -87,7 +85,7 @@ int ocf_cache_line_concurrency_init(struct ocf_cache_line_concurrency **self,
|
||||
}
|
||||
|
||||
c->cache = cache;
|
||||
c->num_clines = line_entries;
|
||||
c->num_clines = num_clines;
|
||||
|
||||
error = env_mutex_init(&c->lock);
|
||||
if (error) {
|
||||
@ -96,7 +94,7 @@ int ocf_cache_line_concurrency_init(struct ocf_cache_line_concurrency **self,
|
||||
}
|
||||
|
||||
OCF_REALLOC_INIT(&c->access, &c->access_limit);
|
||||
OCF_REALLOC_CP(&c->access, sizeof(c->access[0]), line_entries,
|
||||
OCF_REALLOC_CP(&c->access, sizeof(c->access[0]), num_clines,
|
||||
&c->access_limit);
|
||||
|
||||
if (!c->access) {
|
||||
|
@ -20,12 +20,13 @@ struct ocf_cache_line_concurrency;
|
||||
* @brief Initialize OCF cache concurrency module
|
||||
*
|
||||
* @param self - cacheline concurrency private data
|
||||
* @param num_clines - cachelines count
|
||||
* @param cache - OCF cache instance
|
||||
|
||||
* @return 0 - Initialization successful, otherwise ERROR
|
||||
*/
|
||||
int ocf_cache_line_concurrency_init(struct ocf_cache_line_concurrency **self,
|
||||
struct ocf_cache *cache);
|
||||
unsigned num_clines, struct ocf_cache *cache);
|
||||
|
||||
/**
|
||||
* @biref De-Initialize OCF cache concurrency module
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "ocf_concurrency.h"
|
||||
#include "../metadata/metadata.h"
|
||||
|
||||
int ocf_concurrency_init(struct ocf_cache *cache)
|
||||
{
|
||||
@ -11,6 +12,7 @@ int ocf_concurrency_init(struct ocf_cache *cache)
|
||||
|
||||
result = ocf_cache_line_concurrency_init(
|
||||
&cache->device->concurrency.cache_line,
|
||||
ocf_metadata_collision_table_entries(cache),
|
||||
cache);
|
||||
|
||||
if (result)
|
||||
@ -23,6 +25,5 @@ void ocf_concurrency_deinit(struct ocf_cache *cache)
|
||||
{
|
||||
ocf_cache_line_concurrency_deinit(
|
||||
&cache->device->concurrency.cache_line);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user