From 40dd3c29a4e35c35338732e6f127aae18bbd94e8 Mon Sep 17 00:00:00 2001 From: GangCao Date: Mon, 6 Nov 2017 17:40:49 -0500 Subject: [PATCH] event: create the ring on other available sockets There may have the situation that associated socket does not have enough memory for the event pool and the related ring buffer. As the event pool will be created at any available socket, this will be same for the ring. The basic idea is to first allocate the memory for the core associated socket and then try other available sockects before terminating. Change-Id: I52c240289899c136b607629c12c0250ad859c8ac Signed-off-by: GangCao Reviewed-on: https://review.gerrithub.io/385972 Tested-by: SPDK Automated Test System Reviewed-by: Ziye Yang Reviewed-by: Changpeng Liu Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- lib/event/reactor.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 72bbec19a..991ccb8b1 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -473,6 +473,13 @@ spdk_reactor_construct(struct spdk_reactor *reactor, uint32_t lcore, uint64_t ma TAILQ_INIT(&reactor->timer_pollers); reactor->events = spdk_ring_create(SPDK_RING_TYPE_MP_SC, 65536, reactor->socket_id); + if (!reactor->events) { + SPDK_NOTICELOG("Ring creation failed on preferred socket %d. Try other sockets.\n", + reactor->socket_id); + + reactor->events = spdk_ring_create(SPDK_RING_TYPE_MP_SC, 65536, + SPDK_ENV_SOCKET_ID_ANY); + } assert(reactor->events != NULL); reactor->event_mempool = g_spdk_event_mempool[reactor->socket_id]; @@ -617,7 +624,7 @@ spdk_reactors_init(unsigned int max_delay_us) SPDK_MEMPOOL_DEFAULT_CACHE_SIZE, i); if (g_spdk_event_mempool[i] == NULL) { - SPDK_ERRLOG("spdk_event_mempool creation failed on socket %d\n", i); + SPDK_NOTICELOG("Event_mempool creation failed on preferred socket %d.\n", i); /* * Instead of failing the operation directly, try to create