Skip to content

Commit fd90e43

Browse files
committed
seq_cutoff: Split seq cutoff and seq detect
Move sequence detection functionality into a separate component that can be used by subsystems other than sequential cutoff. Signed-off-by: Robert Baldyga <robert.baldyga@unvertical.com>
1 parent 648a5cc commit fd90e43

19 files changed

Lines changed: 623 additions & 449 deletions

inc/ocf_core.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
33
* Copyright(c) 2024 Huawei Technologies
4+
* Copyright(c) 2026 Unvertical
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
67

@@ -111,23 +112,22 @@ uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core);
111112
ocf_seq_cutoff_policy ocf_core_get_seq_cutoff_policy(ocf_core_t core);
112113

113114
/**
114-
* @brief Get sequential cutoff stream promotion req count of given core object
115+
* @brief Get sequence detector stream promotion request count
115116
*
116117
* @param[in] core Core object
117118
*
118-
* @retval Sequential cutoff stream promotion request count
119+
* @retval Sequence detector stream promotion request count
119120
*/
120-
uint32_t ocf_core_get_seq_cutoff_promotion_count(ocf_core_t core);
121+
uint32_t ocf_core_get_seq_detect_promotion_count(ocf_core_t core);
121122

122123
/**
123-
* @brief Whether to promote sequential cutoff stream
124-
* to global structures when threshold is reached
124+
* @brief Get sequence detector stream promotion threshold (in bytes)
125125
*
126126
* @param[in] core Core object
127127
*
128-
* @retval Sequential cutoff stream promote_on_threshold switch value
128+
* @retval Sequence detector stream promotion threshold [B]
129129
*/
130-
bool ocf_core_get_seq_cutoff_promote_on_threshold(ocf_core_t core);
130+
uint32_t ocf_core_get_seq_detect_promotion_threshold(ocf_core_t core);
131131

132132
/**
133133
* @brief Get name of given core object

inc/ocf_debug.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
/*
22
* Copyright(c) 2012-2021 Intel Corporation
33
* Copyright(c) 2024 Huawei Technologies
4+
* Copyright(c) 2026 Unvertical
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
67

78
#ifndef __OCF_DEBUG_H__
89
#define __OCF_DEBUG_H__
910

10-
struct ocf_dbg_seq_cutoff_status {
11+
struct ocf_dbg_seq_detect_status {
1112
struct {
1213
uint64_t last;
1314
uint64_t bytes;
1415
uint32_t rw : 1;
1516
uint32_t active : 1;
16-
} streams[OCF_SEQ_CUTOFF_PERCORE_STREAMS];
17+
} streams[OCF_SEQ_DETECT_PERCORE_STREAMS];
1718
};
1819

19-
void ocf_dbg_get_seq_cutoff_status(ocf_core_t core,
20-
struct ocf_dbg_seq_cutoff_status *status);
20+
void ocf_dbg_get_seq_detect_status(ocf_core_t core,
21+
struct ocf_dbg_seq_detect_status *status);
2122

2223
bool ocf_dbg_cache_is_settled(ocf_cache_t cache);
2324

inc/ocf_def.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ typedef enum {
231231
/*!< Current cache mode of given cache instance */
232232
} ocf_cache_mode_t;
233233

234-
#define OCF_SEQ_CUTOFF_PERCORE_STREAMS 128
235-
#define OCF_SEQ_CUTOFF_PERQUEUE_STREAMS 64
236234
#define OCF_SEQ_CUTOFF_MIN_THRESHOLD 1
237235
#define OCF_SEQ_CUTOFF_MAX_THRESHOLD 4294841344
238-
#define OCF_SEQ_CUTOFF_MIN_PROMOTION_COUNT 1
239-
#define OCF_SEQ_CUTOFF_MAX_PROMOTION_COUNT 65535
236+
#define OCF_SEQ_DETECT_MIN_PROMOTION_COUNT 1
237+
#define OCF_SEQ_DETECT_MAX_PROMOTION_COUNT 65535
238+
#define OCF_SEQ_DETECT_MIN_PROMOTION_THRESHOLD 0
239+
#define OCF_SEQ_DETECT_MAX_PROMOTION_THRESHOLD 4294841344
240240

241241
typedef enum {
242242
ocf_seq_cutoff_policy_always = 0,

inc/ocf_mngt.h

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ struct ocf_mngt_core_config {
5050
uint32_t seq_cutoff_threshold;
5151
/*!< Sequential cutoff threshold (in bytes) */
5252

53-
uint32_t seq_cutoff_promotion_count;
54-
/*!< Sequential cutoff promotion request count */
53+
uint32_t seq_detect_promotion_count;
54+
/*!< Sequence detector stream promotion request count */
5555

56-
bool seq_cutoff_promote_on_threshold;
57-
/*!< Sequential cutoff promote on threshold */
56+
uint32_t seq_detect_promotion_threshold;
57+
/*!< Sequence detector stream promotion threshold (in bytes) */
5858

5959
struct {
6060
void *data;
@@ -75,8 +75,8 @@ static inline void ocf_mngt_core_config_set_default(
7575
{
7676
cfg->try_add = false;
7777
cfg->seq_cutoff_threshold = 1024;
78-
cfg->seq_cutoff_promotion_count = 8;
79-
cfg->seq_cutoff_promote_on_threshold = false;
78+
cfg->seq_detect_promotion_count = 8;
79+
cfg->seq_detect_promotion_threshold = 0;
8080
cfg->user_metadata.data = NULL;
8181
cfg->user_metadata.size = 0;
8282
}
@@ -1189,79 +1189,77 @@ int ocf_mngt_core_get_seq_cutoff_policy(ocf_core_t core,
11891189
* @retval 0 Sequential cutoff promotion requets count has been set successfully
11901190
* @retval Non-zero Error occured and request count hasn't been updated
11911191
*/
1192-
int ocf_mngt_core_set_seq_cutoff_promotion_count(ocf_core_t core,
1192+
int ocf_mngt_core_set_seq_detect_promotion_count(ocf_core_t core,
11931193
uint32_t count);
11941194

11951195
/**
1196-
* @brief Set sequential cutoff promotion request count for all cores in cache
1196+
* @brief Set sequence detector promotion request count for all cores in cache
11971197
*
11981198
* @attention This changes only runtime state. To make changes persistent
11991199
* use function ocf_mngt_cache_save().
12001200
*
12011201
* @param[in] cache Cache handle
12021202
* @param[in] count promotion request count
12031203
*
1204-
* @retval 0 Sequential cutoff promotion request count has been set successfully
1204+
* @retval 0 Promotion request count has been set successfully
12051205
* @retval Non-zero Error occured and request count hasn't been updated
12061206
*/
1207-
int ocf_mngt_core_set_seq_cutoff_promotion_count_all(ocf_cache_t cache,
1207+
int ocf_mngt_core_set_seq_detect_promotion_count_all(ocf_cache_t cache,
12081208
uint32_t count);
12091209

12101210
/**
1211-
* @brief Get core sequential cutoff promotion threshold
1211+
* @brief Get sequence detector promotion request count
12121212
*
12131213
* @param[in] core Core handle
12141214
* @param[out] count promotion request count
12151215
*
1216-
* @retval 0 Sequential cutoff promotion request count has been get successfully
1216+
* @retval 0 Promotion request count has been retrieved successfully
12171217
* @retval Non-zero Error occured
12181218
*/
1219-
int ocf_mngt_core_get_seq_cutoff_promotion_count(ocf_core_t core,
1219+
int ocf_mngt_core_get_seq_detect_promotion_count(ocf_core_t core,
12201220
uint32_t *count);
12211221

12221222
/**
1223-
* @brief Set whether to promote core sequential cutoff stream
1224-
* to global structures when threshold is reached
1223+
* @brief Set sequence detector stream promotion threshold
12251224
*
12261225
* @attention This changes only runtime state. To make changes persistent
12271226
* use function ocf_mngt_cache_save().
12281227
*
12291228
* @param[in] core Core handle
1230-
* @param[in] promote Whether to promote or not
1229+
* @param[in] threshold Promotion threshold (in bytes)
12311230
*
1232-
* @retval 0 Sequential cutoff promote on threshold has been set successfully
1233-
* @retval Non-zero Error occured and promote on threshold hasn't been updated
1231+
* @retval 0 Promotion threshold has been set successfully
1232+
* @retval Non-zero Error occurred and threshold hasn't been updated
12341233
*/
1235-
int ocf_mngt_core_set_seq_cutoff_promote_on_threshold(ocf_core_t core,
1236-
bool promote);
1234+
int ocf_mngt_core_set_seq_detect_promotion_threshold(ocf_core_t core,
1235+
uint32_t threshold);
12371236

12381237
/**
1239-
* @brief Set whether to promote sequential cutoff stream
1240-
* to global structures when threshold is reached for all cores in cache
1238+
* @brief Set sequence detector stream promotion threshold for all cores
12411239
*
12421240
* @attention This changes only runtime state. To make changes persistent
12431241
* use function ocf_mngt_cache_save().
12441242
*
12451243
* @param[in] cache Cache handle
1246-
* @param[in] promote Whether to promote or not
1244+
* @param[in] threshold Promotion threshold (in bytes)
12471245
*
1248-
* @retval 0 Sequential cutoff promote on threshold has been set successfully
1249-
* @retval Non-zero Error occured and promote on threshold hasn't been updated
1246+
* @retval 0 Promotion threshold has been set successfully
1247+
* @retval Non-zero Error occurred and threshold hasn't been updated
12501248
*/
1251-
int ocf_mngt_core_set_seq_cutoff_promote_on_threshold_all(ocf_cache_t cache,
1252-
bool promote);
1249+
int ocf_mngt_core_set_seq_detect_promotion_threshold_all(ocf_cache_t cache,
1250+
uint32_t threshold);
12531251

12541252
/**
1255-
* @brief Get core sequential cutoff promote on threshold switch value
1253+
* @brief Get sequence detector stream promotion threshold
12561254
*
12571255
* @param[in] core Core handle
1258-
* @param[out] promote Promote on threshold
1256+
* @param[out] threshold Promotion threshold (in bytes)
12591257
*
1260-
* @retval 0 Sequential cutoff promote on threshold retrieved successfully
1258+
* @retval 0 Promotion threshold retrieved successfully
12611259
* @retval Non-zero Error occured and value could not be retrieved
12621260
*/
1263-
int ocf_mngt_core_get_seq_cutoff_promote_on_threshold(ocf_core_t core,
1264-
bool *promote);
1261+
int ocf_mngt_core_get_seq_detect_promotion_threshold(ocf_core_t core,
1262+
uint32_t *threshold);
12651263

12661264
/**
12671265
* @brief Set cache fallback Pass Through error threshold

src/mngt/ocf_mngt_cache.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "../cleaning/cleaning.h"
3434
#include "../promotion/ops.h"
3535
#include "../concurrency/ocf_pio_concurrency.h"
36+
#include "../ocf_seq_cutoff.h"
3637

3738
#define OCF_ASSERT_PLUGGED(cache) ENV_BUG_ON(!(cache)->device)
3839

@@ -392,8 +393,8 @@ static void _ocf_mngt_deinit_added_cores(
392393
ocf_volume_deinit(&core->front_volume);
393394
}
394395

395-
if (core->seq_cutoff)
396-
ocf_core_seq_cutoff_deinit(core);
396+
ocf_core_seq_cutoff_deinit(core);
397+
ocf_core_seq_detect_deinit(core);
397398

398399
env_free(core->counters);
399400
core->counters = NULL;
@@ -479,10 +480,11 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
479480
if (!core->counters)
480481
goto err;
481482

482-
ret = ocf_core_seq_cutoff_init(core);
483+
ret = ocf_core_seq_detect_init(core);
483484
if (ret < 0)
484485
goto err;
485486

487+
ocf_core_seq_cutoff_init(core);
486488
if (!core->opened) {
487489
env_bit_set(ocf_cache_state_incomplete,
488490
&cache->cache_state);

src/mngt/ocf_mngt_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "../ocf_logger_priv.h"
1919
#include "../ocf_queue_priv.h"
2020
#include "../engine/engine_common.h"
21+
#include "../ocf_seq_cutoff.h"
2122

2223
/* Close if opened */
2324
void cache_mngt_core_deinit(ocf_core_t core)
@@ -132,6 +133,7 @@ void cache_mngt_core_remove_from_cache(ocf_core_t core)
132133
ocf_cache_t cache = ocf_core_get_cache(core);
133134

134135
ocf_core_seq_cutoff_deinit(core);
136+
ocf_core_seq_detect_deinit(core);
135137
env_free(core->counters);
136138
core->counters = NULL;
137139
core->added = false;

0 commit comments

Comments
 (0)