Commit 16ae5879 authored by Ben Walker's avatar Ben Walker
Browse files

env: Move lcore functions into env layer.



They were previously in the event library.

Change-Id: I24ffd8f771e895ccf5395c8120423cd114893139
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 9ee30b87
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
	}
	if (numa_node >= 0) {
		/* Running subsystem and NVMe device is on the same socket or not */
		if (rte_lcore_to_socket_id(ctx->app_subsystem->lcore) != (unsigned)numa_node) {
		if (spdk_env_get_socket_id(ctx->app_subsystem->lcore) != (unsigned)numa_node) {
			SPDK_WARNLOG("Subsystem %s is configured to run on a CPU core %u belonging "
				     "to a different NUMA node than the associated NVMe device. "
				     "This may result in reduced performance.\n",
@@ -284,7 +284,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
				     ctx->app_subsystem->lcore);
			SPDK_WARNLOG("The NVMe device is on socket %u\n", numa_node);
			SPDK_WARNLOG("The Subsystem is on socket %u\n",
				     rte_lcore_to_socket_id(ctx->app_subsystem->lcore));
				     spdk_env_get_socket_id(ctx->app_subsystem->lcore));
		}
	}

@@ -515,7 +515,7 @@ spdk_nvmf_construct_subsystem(const char *name,
	/* Parse Listen sections */
	for (i = 0; i < num_listen_addresses; i++) {
		int nic_numa_node = spdk_get_ifaddr_numa_node(addresses[i].traddr);
		unsigned subsys_numa_node = rte_lcore_to_socket_id(app_subsys->lcore);
		unsigned subsys_numa_node = spdk_env_get_socket_id(app_subsys->lcore);

		if (nic_numa_node >= 0) {
			if (subsys_numa_node != (unsigned)nic_numa_node) {
+5 −5
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ nvmf_tgt_delete_subsystem(struct nvmf_tgt_subsystem *app_subsys)
	 * Unregister the poller - this starts a chain of events that will eventually free
	 * the subsystem's memory.
	 */
	event = spdk_event_allocate(spdk_app_get_current_core(), subsystem_delete_event,
	event = spdk_event_allocate(spdk_env_get_current_core(), subsystem_delete_event,
				    app_subsys, NULL);
	spdk_poller_unregister(&app_subsys->poller, event);
}
@@ -117,7 +117,7 @@ spdk_nvmf_shutdown_cb(void)
	fprintf(stdout, "   NVMF shutdown signal\n");
	fprintf(stdout, "=========================\n");

	event = spdk_event_allocate(spdk_app_get_current_core(), acceptor_poller_unregistered_event,
	event = spdk_event_allocate(spdk_env_get_current_core(), acceptor_poller_unregistered_event,
				    NULL, NULL);
	spdk_poller_unregister(&g_acceptor_poller, event);
}
@@ -173,7 +173,7 @@ _nvmf_tgt_start_subsystem(void *arg1, void *arg2)
{
	struct nvmf_tgt_subsystem *app_subsys = arg1;
	struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem;
	int lcore = spdk_app_get_current_core();
	int lcore = spdk_env_get_current_core();

	spdk_nvmf_subsystem_start(subsystem);

@@ -220,7 +220,7 @@ nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype,
	app_subsys->lcore = lcore;

	SPDK_NOTICELOG("allocated subsystem %s on lcore %u on socket %u\n", name, lcore,
		       rte_lcore_to_socket_id(lcore));
		       spdk_env_get_socket_id(lcore));

	TAILQ_INSERT_TAIL(&g_subsystems, app_subsys, tailq);

@@ -295,7 +295,7 @@ spdk_nvmf_startup(void *arg1, void *arg2)
			     g_spdk_nvmf_tgt_conf.acceptor_poll_rate);

	SPDK_NOTICELOG("Acceptor running on core %u on socket %u\n", g_spdk_nvmf_tgt_conf.acceptor_lcore,
		       rte_lcore_to_socket_id(g_spdk_nvmf_tgt_conf.acceptor_lcore));
		       spdk_env_get_socket_id(g_spdk_nvmf_tgt_conf.acceptor_lcore));

	if (getenv("MEMZONE_DUMP") != NULL) {
		spdk_memzone_dump(stdout);
+30 −0
Original line number Diff line number Diff line
@@ -156,6 +156,36 @@ void spdk_mempool_put(struct spdk_mempool *mp, void *ele);
 */
void spdk_mempool_put_bulk(struct spdk_mempool *mp, void *const *ele_arr, size_t count);

/**
 * \brief Return the number of dedicated CPU cores utilized by
 * 	  this env abstraction
 */
uint32_t spdk_env_get_core_count(void);

/**
 * \brief Return the CPU core index of the current thread. This
 *	  will only function when called from threads set up by
 *	  this environment abstraction.
 */
uint32_t spdk_env_get_current_core(void);

/**
 * \brief Return the index of the first dedicated CPU core for
 *	  this application.
 */
uint32_t spdk_env_get_first_core(void);

/**
 * \brief Return the index of the next dedicated CPU core for
 *	  this application.
 *        If there is no next core, return UINT32_MAX.
 */
uint32_t spdk_env_get_next_core(uint32_t prev_core);

/**
 * \brief Return the socket ID for the given core.
 */
uint32_t spdk_env_get_socket_id(uint32_t core);

/**
 * Return true if the calling process is primary process
+2 −2
Original line number Diff line number Diff line
@@ -151,12 +151,12 @@ uint64_t spdk_app_get_core_mask(void);
/**
 * \brief Return the number of CPU cores utilized by this application
 */
int spdk_app_get_core_count(void);
int spdk_app_get_core_count(void) __attribute__((deprecated));

/**
 * \brief Return the lcore of the current thread.
 */
uint32_t spdk_app_get_current_core(void);
uint32_t spdk_app_get_current_core(void) __attribute__((deprecated));

/**
 * \brief Allocate an event to be passed to \ref spdk_event_call
+2 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@

#include "spdk/bdev.h"
#include "spdk/conf.h"
#include "spdk/env.h"
#include "spdk/fd.h"
#include "spdk/io_channel.h"

@@ -304,7 +305,7 @@ blockdev_aio_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *
	}

	spdk_poller_register(&ch->poller, blockdev_aio_poll, ch,
			     spdk_app_get_current_core(), 0);
			     spdk_env_get_current_core(), 0);
	return 0;
}

Loading