event: adopt static scheduler to the new API
Move current scheduler to it's own module and make use of new API. Change-Id: I4928aed82603d51de01194c9650709e814f7f61b Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4054 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
0d8a4af849
commit
7148f33360
@ -245,7 +245,7 @@ void _spdk_scheduler_period_set(uint32_t period);
|
||||
#define SPDK_SCHEDULER_REGISTER(scheduler) \
|
||||
static void __attribute__((constructor)) _spdk_scheduler_register_##name(void) \
|
||||
{ \
|
||||
spdk_scheduler_list_add(scheduler); \
|
||||
_spdk_scheduler_list_add(scheduler); \
|
||||
} \
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ SO_MINOR := 0
|
||||
|
||||
LIBNAME = event
|
||||
C_SRCS = app.c reactor.c rpc.c subsystem.c json_config.c log_rpc.c \
|
||||
app_rpc.c subsystem_rpc.c
|
||||
app_rpc.c subsystem_rpc.c scheduler_static.c
|
||||
|
||||
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_event.map)
|
||||
|
||||
|
@ -92,9 +92,14 @@ _spdk_scheduler_set(char *name)
|
||||
|
||||
scheduler = _scheduler_find(name);
|
||||
if (scheduler == NULL) {
|
||||
SPDK_ERRLOG("Requested scheduler is missing\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (scheduler->init != NULL) {
|
||||
scheduler->init();
|
||||
}
|
||||
|
||||
g_scheduler = scheduler;
|
||||
return 0;
|
||||
}
|
||||
@ -163,6 +168,12 @@ spdk_reactors_init(void)
|
||||
uint32_t i, last_core;
|
||||
char mempool_name[32];
|
||||
|
||||
rc = _spdk_scheduler_set("static");
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Failed setting up scheduler\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
snprintf(mempool_name, sizeof(mempool_name), "evtpool_%d", getpid());
|
||||
g_spdk_event_mempool = spdk_mempool_create(mempool_name,
|
||||
262144 - 1, /* Power of 2 minus 1 is optimal for memory consumption */
|
||||
@ -210,6 +221,10 @@ spdk_reactors_fini(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_scheduler->deinit != NULL) {
|
||||
g_scheduler->deinit();
|
||||
}
|
||||
|
||||
spdk_thread_lib_fini();
|
||||
|
||||
SPDK_ENV_FOREACH_CORE(i) {
|
||||
|
48
lib/event/scheduler_static.c
Normal file
48
lib/event/scheduler_static.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
#include "spdk/likely.h"
|
||||
#include "spdk/event.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include "spdk_internal/event.h"
|
||||
|
||||
static struct spdk_scheduler scheduler = {
|
||||
.name = "static",
|
||||
.init = NULL,
|
||||
.deinit = NULL,
|
||||
.balance = NULL,
|
||||
};
|
||||
SPDK_SCHEDULER_REGISTER(&scheduler);
|
@ -37,6 +37,7 @@
|
||||
#include "common/lib/test_env.c"
|
||||
#include "event/reactor.c"
|
||||
#include "spdk_internal/thread.h"
|
||||
#include "event/scheduler_static.c"
|
||||
|
||||
static void
|
||||
test_create_reactor(void)
|
||||
|
Loading…
Reference in New Issue
Block a user