General packing of structs

Get back some memory/cachelines by packing any leftover static fields together.

Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com>
This commit is contained in:
Kozlowski Mateusz 2021-03-15 14:45:59 +01:00
parent 642527d72a
commit fdd6b88cc4
16 changed files with 90 additions and 87 deletions

View File

@ -27,6 +27,9 @@ struct ocf_cache_info {
uint8_t volume_type; uint8_t volume_type;
/*!< Cache volume type */ /*!< Cache volume type */
uint8_t state;
/*!< Cache state (running/flushing/stopping etc...) */
uint32_t size; uint32_t size;
/*!< Actual cache size (in cache lines) */ /*!< Actual cache size (in cache lines) */
@ -69,9 +72,6 @@ struct ocf_cache_info {
set as a result of reaching IO error threshold */ set as a result of reaching IO error threshold */
} fallback_pt; } fallback_pt;
uint8_t state;
/*!< Cache state (running/flushing/stopping etc...) */
ocf_eviction_t eviction_policy; ocf_eviction_t eviction_policy;
/*!< Eviction policy selected */ /*!< Eviction policy selected */

View File

@ -83,16 +83,6 @@ struct ocf_io {
*/ */
ocf_start_io_t start; ocf_start_io_t start;
/**
* @brief OCF IO handle function
*/
ocf_handle_io_t handle;
/**
* @brief OCF IO completion function
*/
ocf_end_io_t end;
/** /**
* @brief OCF IO private 1 * @brief OCF IO private 1
*/ */
@ -102,6 +92,16 @@ struct ocf_io {
* @brief OCF IO private 2 * @brief OCF IO private 2
*/ */
void *priv2; void *priv2;
/**
* @brief OCF IO handle function
*/
ocf_handle_io_t handle;
/**
* @brief OCF IO completion function
*/
ocf_end_io_t end;
}; };
/** /**

View File

@ -851,25 +851,25 @@ struct ocf_mngt_io_class_config {
*/ */
uint32_t class_id; uint32_t class_id;
/**
* @brief IO class maximum size
*/
uint32_t max_size;
/** /**
* @brief IO class name * @brief IO class name
*/ */
const char *name; const char *name;
/**
* @brief IO class eviction priority
*/
int16_t prio;
/** /**
* @brief IO class cache mode * @brief IO class cache mode
*/ */
ocf_cache_mode_t cache_mode; ocf_cache_mode_t cache_mode;
/** /**
* @brief IO class maximum size * @brief IO class eviction priority
*/ */
uint32_t max_size; int16_t prio;
}; };
struct ocf_mngt_io_classes_config { struct ocf_mngt_io_classes_config {

View File

@ -101,6 +101,15 @@ struct ocf_volume_ops {
*/ */
void (*close)(ocf_volume_t volume); void (*close)(ocf_volume_t volume);
/**
* @brief Get volume length
*
* @param[in] volume Volume
*
* @return Volume length in bytes
*/
uint64_t (*get_length)(ocf_volume_t volume);
/** /**
* @brief Get maximum io size * @brief Get maximum io size
* *
@ -109,15 +118,6 @@ struct ocf_volume_ops {
* @return Maximum io size in bytes * @return Maximum io size in bytes
*/ */
unsigned int (*get_max_io_size)(ocf_volume_t volume); unsigned int (*get_max_io_size)(ocf_volume_t volume);
/**
* @brief Get volume length
*
* @param[in] volume Volume
*
* @return Volume lenght in bytes
*/
uint64_t (*get_length)(ocf_volume_t volume);
}; };
/** /**
@ -136,14 +136,14 @@ struct ocf_volume_properties {
struct ocf_volume_caps caps; struct ocf_volume_caps caps;
/*!< Volume capabilities */ /*!< Volume capabilities */
struct ocf_volume_ops ops;
/*!< Volume operations */
struct ocf_io_ops io_ops; struct ocf_io_ops io_ops;
/*!< IO operations */ /*!< IO operations */
void (*deinit)(void); void (*deinit)(void);
/*!< Deinitialize volume type */ /*!< Deinitialize volume type */
struct ocf_volume_ops ops;
/*!< Volume operations */
}; };
/** /**

View File

@ -37,8 +37,8 @@
struct __waiter { struct __waiter {
ocf_cache_line_t line; ocf_cache_line_t line;
void *ctx;
uint32_t ctx_id; uint32_t ctx_id;
void *ctx;
ocf_req_async_lock_cb cb; ocf_req_async_lock_cb cb;
struct list_head item; struct list_head item;
int rw; int rw;

View File

@ -199,8 +199,8 @@ struct ocf_metadata_load_properties {
enum ocf_metadata_shutdown_status shutdown_status; enum ocf_metadata_shutdown_status shutdown_status;
uint8_t dirty_flushed; uint8_t dirty_flushed;
ocf_metadata_layout_t layout; ocf_metadata_layout_t layout;
ocf_cache_line_size_t line_size;
ocf_cache_mode_t cache_mode; ocf_cache_mode_t cache_mode;
ocf_cache_line_size_t line_size;
char *cache_name; char *cache_name;
}; };

View File

@ -14,8 +14,6 @@ struct ocf_user_part_config {
char name[OCF_IO_CLASS_NAME_MAX]; char name[OCF_IO_CLASS_NAME_MAX];
uint32_t min_size; uint32_t min_size;
uint32_t max_size; uint32_t max_size;
int16_t priority;
ocf_cache_mode_t cache_mode;
struct { struct {
uint8_t valid : 1; uint8_t valid : 1;
uint8_t added : 1; uint8_t added : 1;
@ -24,6 +22,8 @@ struct ocf_user_part_config {
* and means that can evict from this partition * and means that can evict from this partition
*/ */
} flags; } flags;
int16_t priority;
ocf_cache_mode_t cache_mode;
}; };
struct ocf_user_part_runtime { struct ocf_user_part_runtime {
@ -40,12 +40,12 @@ typedef bool ( *_lru_hash_locked_pfn)(struct ocf_request *req,
in round robin order */ in round robin order */
struct ocf_lru_iter struct ocf_lru_iter
{ {
/* per-partition cacheline iterator */
ocf_cache_line_t curr_cline[OCF_NUM_EVICTION_LISTS];
/* cache object */ /* cache object */
ocf_cache_t cache; ocf_cache_t cache;
/* target partition */ /* target partition */
struct ocf_user_part *part; struct ocf_user_part *part;
/* per-partition cacheline iterator */
ocf_cache_line_t curr_cline[OCF_NUM_EVICTION_LISTS];
/* available (non-empty) eviction list bitmap rotated so that current /* available (non-empty) eviction list bitmap rotated so that current
@evp is on the most significant bit */ @evp is on the most significant bit */
unsigned long long next_avail_evp; unsigned long long next_avail_evp;

View File

@ -20,6 +20,10 @@ struct ocf_superblock_config {
* shouldn't change!! */ * shouldn't change!! */
uint8_t clean_shutdown; uint8_t clean_shutdown;
uint8_t dirty_flushed; uint8_t dirty_flushed;
/* Current core sequence number */
ocf_core_id_t curr_core_seq_no;
uint32_t magic_number; uint32_t magic_number;
uint32_t metadata_version; uint32_t metadata_version;
@ -47,9 +51,6 @@ struct ocf_superblock_config {
ocf_eviction_t eviction_policy_type; ocf_eviction_t eviction_policy_type;
/* Current core sequence number */
ocf_core_id_t curr_core_seq_no;
/* /*
* Checksum for each metadata region. * Checksum for each metadata region.
* This field has to be the last one! * This field has to be the last one!

View File

@ -39,8 +39,6 @@
* @brief Helpful struct to start cache * @brief Helpful struct to start cache
*/ */
struct ocf_cache_mngt_init_params { struct ocf_cache_mngt_init_params {
bool metadata_volatile;
ocf_ctx_t ctx; ocf_ctx_t ctx;
/*!< OCF context */ /*!< OCF context */
@ -50,6 +48,8 @@ struct ocf_cache_mngt_init_params {
uint8_t locked; uint8_t locked;
/*!< Keep cache locked */ /*!< Keep cache locked */
bool metadata_volatile;
/** /**
* @brief initialization state (in case of error, it is used to know * @brief initialization state (in case of error, it is used to know
* which assets have to be deallocated in premature exit from function * which assets have to be deallocated in premature exit from function

View File

@ -86,6 +86,7 @@ struct ocf_cache {
ocf_eviction_t eviction_policy_init; ocf_eviction_t eviction_policy_init;
uint32_t fallback_pt_error_threshold; uint32_t fallback_pt_error_threshold;
ocf_queue_t mngt_queue;
struct ocf_metadata metadata; struct ocf_metadata metadata;
@ -99,39 +100,32 @@ struct ocf_cache {
struct ocf_refcnt metadata __attribute__((aligned(64))); struct ocf_refcnt metadata __attribute__((aligned(64)));
} refcnt; } refcnt;
ocf_pipeline_t stop_pipeline;
struct ocf_core core[OCF_CORE_MAX]; struct ocf_core core[OCF_CORE_MAX];
ocf_pipeline_t stop_pipeline;
env_atomic fallback_pt_error_counter; env_atomic fallback_pt_error_counter;
env_atomic pending_read_misses_list_blocked; env_atomic pending_read_misses_list_blocked;
env_atomic pending_read_misses_list_count; env_atomic pending_read_misses_list_count;
env_atomic last_access_ms;
env_atomic pending_eviction_clines; env_atomic pending_eviction_clines;
env_atomic flush_in_progress; env_atomic flush_in_progress;
env_mutex flush_mutex;
struct list_head io_queues; struct ocf_metadata_updater metadata_updater;
ocf_queue_t mngt_queue;
struct ocf_cleaner cleaner; struct ocf_cleaner cleaner;
struct ocf_metadata_updater metadata_updater;
struct list_head io_queues;
ocf_promotion_policy_t promotion_policy; ocf_promotion_policy_t promotion_policy;
struct ocf_async_lock lock;
env_mutex flush_mutex;
struct { struct {
uint32_t max_queue_size; uint32_t max_queue_size;
uint32_t queue_unblock_size; uint32_t queue_unblock_size;
} backfill; } backfill;
struct ocf_trace trace;
void *priv; void *priv;
/* /*
@ -145,6 +139,12 @@ struct ocf_cache {
bool pt_unaligned_io; bool pt_unaligned_io;
bool use_submit_io_fast; bool use_submit_io_fast;
struct ocf_trace trace;
struct ocf_async_lock lock;
// This should be on it's own cacheline ideally
env_atomic last_access_ms;
}; };
static inline ocf_core_t ocf_cache_get_core(ocf_cache_t cache, static inline ocf_core_t ocf_cache_get_core(ocf_cache_t cache,

View File

@ -17,22 +17,25 @@
* @brief OCF main control structure * @brief OCF main control structure
*/ */
struct ocf_ctx { struct ocf_ctx {
const struct ocf_ctx_ops *ops;
const struct ocf_ctx_config *cfg;
struct ocf_logger logger;
struct ocf_volume_type *volume_type[OCF_VOLUME_TYPE_MAX]; struct ocf_volume_type *volume_type[OCF_VOLUME_TYPE_MAX];
env_atomic ref_count;
env_rmutex lock; env_rmutex lock;
struct ocf_logger logger;
const struct ocf_ctx_ops *ops;
struct {
struct env_mpool *req;
struct env_mpool *mio;
} resources;
struct list_head caches; struct list_head caches;
struct { struct {
struct list_head core_pool_head; struct list_head core_pool_head;
int core_pool_count; int core_pool_count;
} core_pool; } core_pool;
struct {
struct env_mpool *req; const struct ocf_ctx_config *cfg;
struct env_mpool *mio; env_atomic ref_count;
} resources;
}; };
#define ocf_log_prefix(ctx, lvl, prefix, fmt, ...) \ #define ocf_log_prefix(ctx, lvl, prefix, fmt, ...) \

View File

@ -11,12 +11,9 @@
struct ocf_queue { struct ocf_queue {
ocf_cache_t cache; ocf_cache_t cache;
env_atomic io_no; void *priv;
env_atomic ref_count;
struct list_head io_list; struct list_head io_list;
env_spinlock io_list_lock;
/* per-queue free running global metadata lock index */ /* per-queue free running global metadata lock index */
unsigned lock_idx; unsigned lock_idx;
@ -24,19 +21,21 @@ struct ocf_queue {
/* per-queue free running eviction list index */ /* per-queue free running eviction list index */
unsigned eviction_idx; unsigned eviction_idx;
/* Tracing reference counter */ struct ocf_seq_cutoff *seq_cutoff;
env_atomic64 trace_ref_cntr;
/* Tracing stop request */
env_atomic trace_stop;
struct list_head list; struct list_head list;
const struct ocf_queue_ops *ops; const struct ocf_queue_ops *ops;
struct ocf_seq_cutoff *seq_cutoff; /* Tracing reference counter */
env_atomic64 trace_ref_cntr;
void *priv; /* Tracing stop request */
env_atomic trace_stop;
env_atomic io_no;
env_atomic ref_count;
env_spinlock io_list_lock;
}; };
static inline void ocf_queue_kick(ocf_queue_t queue, bool allow_sync) static inline void ocf_queue_kick(ocf_queue_t queue, bool allow_sync)

View File

@ -106,9 +106,6 @@ struct ocf_request {
struct ocf_io_internal ioi; struct ocf_io_internal ioi;
/*!< OCF IO associated with request */ /*!< OCF IO associated with request */
const struct ocf_engine_callbacks *engine_cbs;
/*!< Engine owning the request */
env_atomic ref_count; env_atomic ref_count;
/*!< Reference usage count, once OCF request reaches zero it /*!< Reference usage count, once OCF request reaches zero it
* will be de-initialed. Get/Put method are intended to modify * will be de-initialed. Get/Put method are intended to modify
@ -128,6 +125,9 @@ struct ocf_request {
env_atomic master_remaining; env_atomic master_remaining;
/*!< Atomic counter for core device */ /*!< Atomic counter for core device */
const struct ocf_engine_callbacks *engine_cbs;
/*!< Engine owning the request */
ocf_cache_t cache; ocf_cache_t cache;
/*!< Handle to cache instance */ /*!< Handle to cache instance */

View File

@ -23,15 +23,15 @@ struct ocf_volume_type {
struct ocf_volume { struct ocf_volume {
ocf_volume_type_t type; ocf_volume_type_t type;
struct ocf_volume_uuid uuid; struct ocf_volume_uuid uuid;
struct {
unsigned discard_zeroes:1;
/* true if reading discarded pages returns 0 */
} features;
bool opened; bool opened;
bool uuid_copy; bool uuid_copy;
void *priv; void *priv;
ocf_cache_t cache; ocf_cache_t cache;
struct list_head core_pool_item; struct list_head core_pool_item;
struct {
unsigned discard_zeroes:1;
/* true if reading discarded pages returns 0 */
} features;
struct ocf_refcnt refcnt __attribute__((aligned(64))); struct ocf_refcnt refcnt __attribute__((aligned(64)));
} __attribute__((aligned(64))); } __attribute__((aligned(64)));

View File

@ -96,6 +96,7 @@ struct nhit_list_elem {
}; };
struct nhit_hash { struct nhit_hash {
env_spinlock rb_pointer_lock;
ocf_cache_line_t hash_entries; ocf_cache_line_t hash_entries;
uint64_t rb_entries; uint64_t rb_entries;
@ -104,7 +105,6 @@ struct nhit_hash {
struct nhit_list_elem *ring_buffer; struct nhit_list_elem *ring_buffer;
uint64_t rb_pointer; uint64_t rb_pointer;
env_spinlock rb_pointer_lock;
}; };
static uint64_t calculate_hash_buckets(uint64_t hash_size) static uint64_t calculate_hash_buckets(uint64_t hash_size)

View File

@ -41,13 +41,13 @@ typedef int (*ocf_mlst_cmp)(struct ocf_cache *cache,
struct ocf_lst { struct ocf_lst {
struct ocf_lst_entry *head; struct ocf_lst_entry *head;
ocf_cache_line_t invalid; ocf_cache_line_t invalid;
ocf_mlst_getter getter;
ocf_mlst_cmp cmp;
struct ocf_cache *cache;
struct { struct {
uint32_t active : 1; uint32_t active : 1;
} flags; } flags;
ocf_mlst_getter getter;
ocf_mlst_cmp cmp;
struct ocf_cache *cache;
}; };
static inline void ocf_lst_init_entry(struct ocf_lst *lst, static inline void ocf_lst_init_entry(struct ocf_lst *lst,