accel: make number of tasks/seqs/bufs configurable
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I07ebf37ff31ddb888e68e98cf7b9b425c7a4d128 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17318 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
c812fe0948
commit
1ac6963542
@ -1954,6 +1954,9 @@ Name | Optional | Type | Description
|
||||
----------------------- |----------| ----------- | -----------------
|
||||
small_cache_size | Optional | number | Size of the small iobuf cache
|
||||
large_cache_size | Optional | number | Size of the large iobuf cache
|
||||
task_count | Optional | number | Maximum number of tasks per IO channel
|
||||
sequence_count | Optional | number | Maximum number of sequences per IO channel
|
||||
buf_count | Optional | number | Maximum number of accel buffers per IO channel
|
||||
|
||||
#### Example
|
||||
|
||||
|
@ -646,6 +646,12 @@ struct spdk_accel_opts {
|
||||
uint32_t small_cache_size;
|
||||
/** Size of the large iobuf cache */
|
||||
uint32_t large_cache_size;
|
||||
/** Maximum number of tasks per IO channel */
|
||||
uint32_t task_count;
|
||||
/** Maximum number of sequences per IO channel */
|
||||
uint32_t sequence_count;
|
||||
/** Maximum number of accel buffers per IO channel */
|
||||
uint32_t buf_count;
|
||||
} __attribute__((packed));
|
||||
|
||||
/**
|
||||
|
@ -65,6 +65,9 @@ static struct spdk_accel_driver *g_accel_driver;
|
||||
static struct spdk_accel_opts g_opts = {
|
||||
.small_cache_size = ACCEL_SMALL_CACHE_SIZE,
|
||||
.large_cache_size = ACCEL_LARGE_CACHE_SIZE,
|
||||
.task_count = MAX_TASKS_PER_CHANNEL,
|
||||
.sequence_count = MAX_TASKS_PER_CHANNEL,
|
||||
.buf_count = MAX_TASKS_PER_CHANNEL,
|
||||
};
|
||||
static struct accel_stats g_stats;
|
||||
static struct spdk_spinlock g_stats_lock;
|
||||
@ -2100,19 +2103,20 @@ accel_create_channel(void *io_device, void *ctx_buf)
|
||||
struct spdk_accel_sequence *seq;
|
||||
struct accel_buffer *buf;
|
||||
uint8_t *task_mem;
|
||||
int i = 0, j, rc;
|
||||
uint32_t i = 0, j;
|
||||
int rc;
|
||||
|
||||
accel_ch->task_pool_base = calloc(MAX_TASKS_PER_CHANNEL, g_max_accel_module_size);
|
||||
accel_ch->task_pool_base = calloc(g_opts.task_count, g_max_accel_module_size);
|
||||
if (accel_ch->task_pool_base == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_ch->seq_pool_base = calloc(MAX_TASKS_PER_CHANNEL, sizeof(struct spdk_accel_sequence));
|
||||
accel_ch->seq_pool_base = calloc(g_opts.sequence_count, sizeof(struct spdk_accel_sequence));
|
||||
if (accel_ch->seq_pool_base == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
accel_ch->buf_pool_base = calloc(MAX_TASKS_PER_CHANNEL, sizeof(struct accel_buffer));
|
||||
accel_ch->buf_pool_base = calloc(g_opts.buf_count, sizeof(struct accel_buffer));
|
||||
if (accel_ch->buf_pool_base == NULL) {
|
||||
goto err;
|
||||
}
|
||||
@ -2120,16 +2124,21 @@ accel_create_channel(void *io_device, void *ctx_buf)
|
||||
TAILQ_INIT(&accel_ch->task_pool);
|
||||
TAILQ_INIT(&accel_ch->seq_pool);
|
||||
TAILQ_INIT(&accel_ch->buf_pool);
|
||||
|
||||
task_mem = accel_ch->task_pool_base;
|
||||
for (i = 0 ; i < MAX_TASKS_PER_CHANNEL; i++) {
|
||||
for (i = 0; i < g_opts.task_count; i++) {
|
||||
accel_task = (struct spdk_accel_task *)task_mem;
|
||||
seq = &accel_ch->seq_pool_base[i];
|
||||
buf = &accel_ch->buf_pool_base[i];
|
||||
TAILQ_INSERT_TAIL(&accel_ch->task_pool, accel_task, link);
|
||||
TAILQ_INSERT_TAIL(&accel_ch->seq_pool, seq, link);
|
||||
TAILQ_INSERT_TAIL(&accel_ch->buf_pool, buf, link);
|
||||
task_mem += g_max_accel_module_size;
|
||||
}
|
||||
for (i = 0; i < g_opts.sequence_count; i++) {
|
||||
seq = &accel_ch->seq_pool_base[i];
|
||||
TAILQ_INSERT_TAIL(&accel_ch->seq_pool, seq, link);
|
||||
}
|
||||
for (i = 0; i < g_opts.buf_count; i++) {
|
||||
buf = &accel_ch->buf_pool_base[i];
|
||||
TAILQ_INSERT_TAIL(&accel_ch->buf_pool, buf, link);
|
||||
}
|
||||
|
||||
/* Assign modules and get IO channels for each */
|
||||
for (i = 0; i < ACCEL_OPC_LAST; i++) {
|
||||
@ -2372,6 +2381,9 @@ accel_write_options(struct spdk_json_write_ctx *w)
|
||||
spdk_json_write_named_object_begin(w, "params");
|
||||
spdk_json_write_named_uint32(w, "small_cache_size", g_opts.small_cache_size);
|
||||
spdk_json_write_named_uint32(w, "large_cache_size", g_opts.large_cache_size);
|
||||
spdk_json_write_named_uint32(w, "task_count", g_opts.task_count);
|
||||
spdk_json_write_named_uint32(w, "sequence_count", g_opts.sequence_count);
|
||||
spdk_json_write_named_uint32(w, "buf_count", g_opts.buf_count);
|
||||
spdk_json_write_object_end(w);
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
@ -358,11 +358,17 @@ SPDK_RPC_REGISTER("accel_set_driver", rpc_accel_set_driver, SPDK_RPC_STARTUP)
|
||||
struct rpc_accel_opts {
|
||||
uint32_t small_cache_size;
|
||||
uint32_t large_cache_size;
|
||||
uint32_t task_count;
|
||||
uint32_t sequence_count;
|
||||
uint32_t buf_count;
|
||||
};
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_accel_set_options_decoders[] = {
|
||||
{"small_cache_size", offsetof(struct rpc_accel_opts, small_cache_size), spdk_json_decode_uint32, true},
|
||||
{"large_cache_size", offsetof(struct rpc_accel_opts, large_cache_size), spdk_json_decode_uint32, true},
|
||||
{"task_count", offsetof(struct rpc_accel_opts, task_count), spdk_json_decode_uint32, true},
|
||||
{"sequence_count", offsetof(struct rpc_accel_opts, sequence_count), spdk_json_decode_uint32, true},
|
||||
{"buf_count", offsetof(struct rpc_accel_opts, buf_count), spdk_json_decode_uint32, true},
|
||||
};
|
||||
|
||||
static void
|
||||
@ -377,6 +383,9 @@ rpc_accel_set_options(struct spdk_jsonrpc_request *request, const struct spdk_js
|
||||
spdk_accel_get_opts(&opts);
|
||||
rpc_opts.small_cache_size = opts.small_cache_size;
|
||||
rpc_opts.large_cache_size = opts.large_cache_size;
|
||||
rpc_opts.task_count = opts.task_count;
|
||||
rpc_opts.sequence_count = opts.sequence_count;
|
||||
rpc_opts.buf_count = opts.buf_count;
|
||||
|
||||
if (spdk_json_decode_object(params, rpc_accel_set_options_decoders,
|
||||
SPDK_COUNTOF(rpc_accel_set_options_decoders), &rpc_opts)) {
|
||||
@ -387,6 +396,9 @@ rpc_accel_set_options(struct spdk_jsonrpc_request *request, const struct spdk_js
|
||||
|
||||
opts.small_cache_size = rpc_opts.small_cache_size;
|
||||
opts.large_cache_size = rpc_opts.large_cache_size;
|
||||
opts.task_count = rpc_opts.task_count;
|
||||
opts.sequence_count = rpc_opts.sequence_count;
|
||||
opts.buf_count = rpc_opts.buf_count;
|
||||
|
||||
rc = spdk_accel_set_opts(&opts);
|
||||
if (rc != 0) {
|
||||
|
@ -90,7 +90,8 @@ def accel_set_driver(client, name):
|
||||
return client.call('accel_set_driver', {'name': name})
|
||||
|
||||
|
||||
def accel_set_options(client, small_cache_size, large_cache_size):
|
||||
def accel_set_options(client, small_cache_size, large_cache_size,
|
||||
task_count, sequence_count, buf_count):
|
||||
"""Set accel framework's options."""
|
||||
params = {}
|
||||
|
||||
@ -98,6 +99,12 @@ def accel_set_options(client, small_cache_size, large_cache_size):
|
||||
params['small_cache_size'] = small_cache_size
|
||||
if large_cache_size is not None:
|
||||
params['large_cache_size'] = large_cache_size
|
||||
if task_count is not None:
|
||||
params['task_count'] = task_count
|
||||
if sequence_count is not None:
|
||||
params['sequence_count'] = sequence_count
|
||||
if buf_count is not None:
|
||||
params['buf_count'] = buf_count
|
||||
|
||||
return client.call('accel_set_options', params)
|
||||
|
||||
|
@ -2867,11 +2867,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
p.set_defaults(func=accel_set_driver)
|
||||
|
||||
def accel_set_options(args):
|
||||
rpc.accel.accel_set_options(args.client, args.small_cache_size, args.large_cache_size)
|
||||
rpc.accel.accel_set_options(args.client, args.small_cache_size, args.large_cache_size,
|
||||
args.task_count, args.sequence_count, args.buf_count)
|
||||
|
||||
p = subparsers.add_parser('accel_set_options', help='Set accel framework\'s options')
|
||||
p.add_argument('--small-cache-size', type=int, help='Size of the small iobuf cache')
|
||||
p.add_argument('--large-cache-size', type=int, help='Size of the large iobuf cache')
|
||||
p.add_argument('--task-count', type=int, help='Maximum number of tasks per IO channel')
|
||||
p.add_argument('--sequence-count', type=int, help='Maximum number of sequences per IO channel')
|
||||
p.add_argument('--buf-count', type=int, help='Maximum number of buffers per IO channel')
|
||||
p.set_defaults(func=accel_set_options)
|
||||
|
||||
def accel_get_stats(args):
|
||||
|
Loading…
Reference in New Issue
Block a user