Skip to content

Commit 54013a9

Browse files
author
Adam Rutkowski
authored
Merge branch 'master' into sdl
2 parents 3a604b8 + 71e056e commit 54013a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2042
-805
lines changed

Diff for: doc/requirements/disable_cleaner

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
group: disable_cleaner
3+
---
4+
5+
Disabling cleaner is a feature that is intented to be used with read cache
6+
(Write-Thourgh and Write-Around modes), where no dirty data is produced, so
7+
the cleaning is not necessary. Its major benefit is metadata memory footprint
8+
reduction, which is result of not allocating "cleaning" metatada section,
9+
that constitutes about 20% of total metadata capacity.
10+
11+
While it is possible to use disable_cleaner option Write-Back and Write-Only
12+
modes, it may result in performance degradation due to necessity to perform
13+
cleaning on eviction.
14+
15+
--------------------------------------------------------------------------------
16+
--------------------------------------------------------------------------------
17+
title: Setting cleaner_disabled mode
18+
id: set_cleaner_disabled
19+
---
20+
21+
It shall be possible to select cleaner_disabled mode during cache attach
22+
operation by setting apropirate field in attach config.
23+
24+
--------------------------------------------------------------------------------
25+
--------------------------------------------------------------------------------
26+
title: Loading cache cleaner_disabled mode
27+
id: load_cleaner_disabled
28+
---
29+
30+
The cleaner_disabled setting should be preserved in cache metadata, i.e. on the
31+
cache load/recovery the setting should be restored to the value it had before
32+
the cache stop.
33+
34+
--------------------------------------------------------------------------------
35+
--------------------------------------------------------------------------------
36+
title: Metadata "cleaning" section allocation
37+
id: cleaning_section_alocation
38+
---
39+
40+
When disable_cleaner option is selected the "cleaning" section in OCF metadata
41+
shall not be allocated neither in DRAM nor on the cache drive.
42+
43+
--------------------------------------------------------------------------------
44+
--------------------------------------------------------------------------------
45+
title: Starting with NOP cleaning policy
46+
id: starting_with_nop_policy
47+
---
48+
49+
When attaching/loading cache with disable_cleaner option selected, the cleaning
50+
policy shall always be NOP.
51+
52+
--------------------------------------------------------------------------------
53+
--------------------------------------------------------------------------------
54+
title: NOP cleaning policy enforcement
55+
id: nop_enforcement
56+
---
57+
58+
When disable_cleaner option is selected it shall not be possible to change the
59+
cleaning policy to other than NOP.
60+
61+
--------------------------------------------------------------------------------
62+
--------------------------------------------------------------------------------
63+
title: Default setting
64+
id: default_setting
65+
---
66+
67+
By default the disable_cleaner option shall not be selected.

Diff for: env/posix/ocf_env.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2019-2021 Intel Corporation
2+
* Copyright(c) 2019-2022 Intel Corporation
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55

@@ -67,11 +67,13 @@ typedef uint64_t sector_t;
6767
#define ENV_MEM_ATOMIC 0
6868

6969
/* DEBUGING */
70+
void env_stack_trace(void);
71+
7072
#define ENV_WARN(cond, fmt...) printf(fmt)
7173
#define ENV_WARN_ON(cond) ;
7274
#define ENV_WARN_ONCE(cond, fmt...) ENV_WARN(cond, fmt)
7375

74-
#define ENV_BUG() assert(0)
76+
#define ENV_BUG() do {env_stack_trace(); assert(0);} while(0)
7577
#define ENV_BUG_ON(cond) do { if (cond) ENV_BUG(); } while (0)
7678
#define ENV_BUILD_BUG_ON(cond) _Static_assert(!(cond), "static "\
7779
"assertion failure")

Diff for: inc/ocf_err.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ typedef enum {
155155
/** Operation only allowed in standby mode **/
156156
OCF_ERR_CACHE_NOT_STANDBY,
157157

158-
OCF_ERR_MAX = OCF_ERR_CACHE_NOT_STANDBY,
158+
/** Operation not allowed when cleaner is disabled **/
159+
OCF_ERR_CLEANER_DISABLED,
160+
161+
OCF_ERR_MAX = OCF_ERR_CLEANER_DISABLED,
159162

160163
} ocf_error_t;
161164

Diff for: inc/ocf_mngt.h

+16
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,21 @@ struct ocf_mngt_cache_attach_config {
424424
* @brief If set, cache device will be discarded on cache start
425425
*/
426426
bool discard_on_start;
427+
428+
/**
429+
* @brief If set, asynchronous cleaning will be disabled
430+
*
431+
* Has similar effect to setting cleaning policy to NOP, but
432+
* additionally prevents allocating "cleaning" metadata section,
433+
* which can reduce memory footprint by up to 20%.
434+
*
435+
* When this option is selected, any attempt to change the cleaning
436+
* policy will fail.
437+
*
438+
* @note This option is meaningful only with ocf_mngt_cache_attach().
439+
* When used with ocf_mngt_cache_load() it's ignored.
440+
*/
441+
bool disable_cleaner;
427442
};
428443

429444
/**
@@ -441,6 +456,7 @@ static inline void ocf_mngt_cache_attach_config_set_default(
441456
cfg->open_cores = true;
442457
cfg->force = false;
443458
cfg->discard_on_start = true;
459+
cfg->disable_cleaner = false;
444460
cfg->device.perform_test = true;
445461
cfg->device.volume_params = NULL;
446462
}

Diff for: src/cleaning/acp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2012-2021 Intel Corporation
2+
* Copyright(c) 2012-2022 Intel Corporation
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55

@@ -363,7 +363,7 @@ static int ocf_acp_recovery_handle(ocf_parallelize_t parallelize,
363363
ocf_core_id_t core_id;
364364
uint32_t step = 0;
365365

366-
portion = DIV_ROUND_UP((uint64_t)entries, shards_cnt);
366+
portion = OCF_DIV_ROUND_UP((uint64_t)entries, shards_cnt);
367367
begin = portion*shard_id;
368368
end = OCF_MIN(portion*(shard_id + 1), entries);
369369

Diff for: src/cleaning/alru.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2012-2021 Intel Corporation
2+
* Copyright(c) 2012-2022 Intel Corporation
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55

@@ -516,7 +516,7 @@ static int ocf_alru_recovery_handle(ocf_parallelize_t parallelize,
516516
uint32_t step = 0;
517517
int i;
518518

519-
portion = DIV_ROUND_UP((uint64_t)entries, shards_cnt);
519+
portion = OCF_DIV_ROUND_UP((uint64_t)entries, shards_cnt);
520520
begin = portion*shard_id;
521521
end = OCF_MIN((uint64_t)portion*(shard_id + 1), entries);
522522

Diff for: src/concurrency/ocf_cache_line_concurrency.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2012-2021 Intel Corporation
2+
* Copyright(c) 2012-2022 Intel Corporation
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55

@@ -141,9 +141,17 @@ static int ocf_cl_lock_line_slow(struct ocf_alock *alock,
141141
return ret;
142142
}
143143

144+
static uint32_t ocf_cl_lock_get_entries_count(struct ocf_alock *alock,
145+
struct ocf_request *req)
146+
{
147+
return req->core_line_count;
148+
}
149+
144150
static struct ocf_alock_lock_cbs ocf_cline_conc_cbs = {
145151
.lock_entries_fast = ocf_cl_lock_line_fast,
146-
.lock_entries_slow = ocf_cl_lock_line_slow
152+
.lock_entries_slow = ocf_cl_lock_line_slow,
153+
.get_entries_count = ocf_cl_lock_get_entries_count
154+
147155
};
148156

149157
bool ocf_cache_line_try_lock_rd(struct ocf_alock *alock,

Diff for: src/concurrency/ocf_mio_concurrency.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2021 Intel Corporation
2+
* Copyright(c) 2021-2022 Intel Corporation
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55

@@ -98,9 +98,16 @@ static int ocf_mio_lock_slow(struct ocf_alock *alock,
9898
return ret;
9999
}
100100

101+
static uint32_t ocf_mio_lock_get_entries_count(struct ocf_alock *alock,
102+
struct ocf_request *req)
103+
{
104+
return req->core_line_count;
105+
}
106+
101107
static struct ocf_alock_lock_cbs ocf_mio_conc_cbs = {
102108
.lock_entries_fast = ocf_mio_lock_fast,
103-
.lock_entries_slow = ocf_mio_lock_slow
109+
.lock_entries_slow = ocf_mio_lock_slow,
110+
.get_entries_count = ocf_mio_lock_get_entries_count
104111
};
105112

106113
int ocf_mio_async_lock(struct ocf_alock *alock,

Diff for: src/concurrency/ocf_pio_concurrency.c

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2021 Intel Corporation
2+
* Copyright(c) 2021-2022 Intel Corporation
33
* SPDX-License-Identifier: BSD-3-Clause
44
*/
55

@@ -68,7 +68,7 @@ static int ocf_pio_lock_fast(struct ocf_alock *alock,
6868

6969
for (i = 0; i < req->core_line_count; i++) {
7070
entry = ocf_pio_lock_get_entry(alock, req, i);
71-
if (entry == OUT_OF_RANGE)
71+
if (unlikely(entry == OUT_OF_RANGE))
7272
continue;
7373

7474
ENV_BUG_ON(ocf_alock_is_index_locked(alock, req, i));
@@ -87,7 +87,7 @@ static int ocf_pio_lock_fast(struct ocf_alock *alock,
8787
/* Request is not locked, discard acquired locks */
8888
for (; i >= 0; i--) {
8989
entry = ocf_pio_lock_get_entry(alock, req, i);
90-
if (entry == OUT_OF_RANGE)
90+
if (unlikely(entry == OUT_OF_RANGE))
9191
continue;
9292

9393
if (ocf_alock_is_index_locked(alock, req, i)) {
@@ -109,7 +109,7 @@ static int ocf_pio_lock_slow(struct ocf_alock *alock,
109109

110110
for (i = 0; i < req->core_line_count; i++) {
111111
entry = ocf_pio_lock_get_entry(alock, req, i);
112-
if (entry == OUT_OF_RANGE)
112+
if (unlikely(entry == OUT_OF_RANGE))
113113
continue;
114114

115115
ENV_BUG_ON(ocf_alock_is_index_locked(alock, req, i));
@@ -127,7 +127,7 @@ static int ocf_pio_lock_slow(struct ocf_alock *alock,
127127
err:
128128
for (; i >= 0; i--) {
129129
entry = ocf_pio_lock_get_entry(alock, req, i);
130-
if (entry == OUT_OF_RANGE)
130+
if (unlikely(entry == OUT_OF_RANGE))
131131
continue;
132132

133133
ocf_alock_waitlist_remove_entry(alock, req, i, entry, OCF_WRITE);
@@ -136,9 +136,26 @@ static int ocf_pio_lock_slow(struct ocf_alock *alock,
136136
return ret;
137137
}
138138

139+
static uint32_t ocf_pio_lock_get_entries_count(struct ocf_alock *alock,
140+
struct ocf_request *req)
141+
{
142+
uint32_t i, count = 0;
143+
ocf_cache_line_t entry;
144+
145+
for (i = 0; i < req->core_line_count; i++) {
146+
entry = ocf_pio_lock_get_entry(alock, req, i);
147+
if (unlikely(entry == OUT_OF_RANGE))
148+
continue;
149+
count++;
150+
}
151+
152+
return count;
153+
}
154+
139155
static struct ocf_alock_lock_cbs ocf_pio_conc_cbs = {
140156
.lock_entries_fast = ocf_pio_lock_fast,
141-
.lock_entries_slow = ocf_pio_lock_slow
157+
.lock_entries_slow = ocf_pio_lock_slow,
158+
.get_entries_count = ocf_pio_lock_get_entries_count
142159
};
143160

144161
int ocf_pio_async_lock(struct ocf_alock *alock, struct ocf_request *req,
@@ -157,7 +174,7 @@ void ocf_pio_async_unlock(struct ocf_alock *alock, struct ocf_request *req)
157174
continue;
158175

159176
entry = ocf_pio_lock_get_entry(alock, req, i);
160-
if (entry == OUT_OF_RANGE)
177+
if (unlikely(entry == OUT_OF_RANGE))
161178
continue;
162179

163180
ocf_alock_unlock_one_wr(alock, entry);

Diff for: src/metadata/metadata.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ static void ocf_metadata_flush_unlock_collision_page(
638638
* Initialize hash metadata interface
639639
*/
640640
int ocf_metadata_init_variable_size(struct ocf_cache *cache,
641-
uint64_t device_size, ocf_cache_line_size_t line_size)
641+
uint64_t device_size, ocf_cache_line_size_t line_size,
642+
bool cleaner_disabled)
642643
{
643644
int result = 0;
644645
uint32_t i = 0;
@@ -688,6 +689,12 @@ int ocf_metadata_init_variable_size(struct ocf_cache *cache,
688689
raw->raw_type = metadata_raw_type_atomic;
689690
}
690691

692+
if (i == metadata_segment_cleaning && cleaner_disabled) {
693+
raw->entry_size = 0;
694+
raw->entries_in_page = 1;
695+
continue;
696+
}
697+
691698
/* Entry size configuration */
692699
raw->entry_size
693700
= ocf_metadata_get_element_size(i, line_size);
@@ -715,6 +722,9 @@ int ocf_metadata_init_variable_size(struct ocf_cache *cache,
715722
*/
716723
for (i = metadata_segment_variable_size_start;
717724
i < metadata_segment_max; i++) {
725+
if (i == metadata_segment_cleaning && cleaner_disabled)
726+
continue;
727+
718728
if (i == metadata_segment_collision) {
719729
lock_page =
720730
ocf_metadata_flush_lock_collision_page;
@@ -779,6 +789,7 @@ int ocf_metadata_init_variable_size(struct ocf_cache *cache,
779789

780790
cache->conf_meta->cachelines = ctrl->cachelines;
781791
cache->conf_meta->line_size = line_size;
792+
cache->conf_meta->cleaner_disabled = cleaner_disabled;
782793

783794
ocf_metadata_raw_info(cache, ctrl);
784795

@@ -1620,6 +1631,7 @@ static void ocf_metadata_load_properties_cmpl(
16201631
properties.shutdown_status = superblock->clean_shutdown;
16211632
properties.dirty_flushed = superblock->dirty_flushed;
16221633
properties.cache_name = superblock->name;
1634+
properties.cleaner_disabled = superblock->cleaner_disabled;
16231635

16241636
OCF_CMPL_RET(priv, 0, &properties);
16251637
}

Diff for: src/metadata/metadata.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ int ocf_metadata_init(struct ocf_cache *cache,
4141
* @param cache - Cache instance
4242
* @param device_size - Device size in bytes
4343
* @param cache_line_size Cache line size
44+
* @param cleaner_disabled Cleaner is disabled
4445
* @return 0 - Operation success otherwise failure
4546
*/
4647
int ocf_metadata_init_variable_size(struct ocf_cache *cache,
47-
uint64_t device_size, ocf_cache_line_size_t cache_line_size);
48+
uint64_t device_size, ocf_cache_line_size_t line_size,
49+
bool cleaner_disabled);
4850

4951
/**
5052
* @brief Initialize collision table
@@ -201,6 +203,7 @@ struct ocf_metadata_load_properties {
201203
ocf_cache_mode_t cache_mode;
202204
ocf_cache_line_size_t line_size;
203205
char *cache_name;
206+
bool cleaner_disabled;
204207
};
205208

206209
typedef void (*ocf_metadata_load_properties_end_t)(void *priv, int error,

Diff for: src/metadata/metadata_cleaning_policy.c

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ ocf_metadata_get_cleaning_policy(struct ocf_cache *cache,
1818
struct ocf_metadata_ctrl *ctrl
1919
= (struct ocf_metadata_ctrl *) cache->metadata.priv;
2020

21+
ENV_BUG_ON(cache->conf_meta->cleaner_disabled);
22+
2123
return ocf_metadata_raw_wr_access(cache,
2224
&(ctrl->raw_desc[metadata_segment_cleaning]), line);
2325
}

0 commit comments

Comments
 (0)