thread: Move threading abstraction code out of util

This makes more sense as a first class library.

Change-Id: Ibd5c578f8708bd8c7d83fe1629e97c9a3316b56b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/414698
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Madhu Pai <mpai@netapp.com>
This commit is contained in:
Ben Walker 2018-06-11 11:22:27 -07:00 committed by Jim Harris
parent 9f697e0fe2
commit 02d75f6237
37 changed files with 118 additions and 33 deletions

View File

@ -46,7 +46,7 @@ C_SRCS := iscsi_tgt.c
SPDK_LIB_LIST = event_bdev event_copy event_iscsi event_net event_scsi
SPDK_LIB_LIST += jsonrpc json rpc bdev_rpc bdev iscsi scsi copy trace conf
SPDK_LIB_LIST += util log log_rpc event app_rpc
SPDK_LIB_LIST += thread util log log_rpc event app_rpc
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd

View File

@ -41,7 +41,7 @@ APP = nvmf_tgt
C_SRCS := nvmf_main.c
SPDK_LIB_LIST = event_bdev event_copy event_nvmf
SPDK_LIB_LIST += nvmf event log trace conf util bdev copy rpc jsonrpc json
SPDK_LIB_LIST += nvmf event log trace conf thread util bdev copy rpc jsonrpc json
SPDK_LIB_LIST += app_rpc log_rpc bdev_rpc
ifeq ($(OS),Linux)

View File

@ -41,7 +41,7 @@ APP = spdk_tgt
C_SRCS := spdk_tgt.c
SPDK_LIB_LIST = event_bdev event_copy event_iscsi event_net event_scsi event_nvmf
SPDK_LIB_LIST += nvmf event log trace conf util bdev iscsi scsi copy rpc jsonrpc json
SPDK_LIB_LIST += nvmf event log trace conf thread util bdev iscsi scsi copy rpc jsonrpc json
SPDK_LIB_LIST += app_rpc log_rpc bdev_rpc
ifeq ($(OS),Linux)

View File

@ -42,7 +42,7 @@ C_SRCS := vhost.c
SPDK_LIB_LIST = event_bdev event_copy event_net event_scsi event_vhost
SPDK_LIB_LIST += jsonrpc json rpc bdev_rpc bdev scsi copy trace conf
SPDK_LIB_LIST += util log log_rpc event app_rpc
SPDK_LIB_LIST += thread util log log_rpc event app_rpc
SPDK_LIB_LIST += vhost rte_vhost event_nbd nbd
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \

View File

@ -65,7 +65,7 @@ fundamental libraries in SPDK, for instance, don't do any message passing on
their own and instead enumerate rules about when functions may be called in
their documentation (e.g. @ref nvme). Most libraries, however, depend on SPDK's
[io_channel](http://www.spdk.io/doc/io__channel_8h.html) infrastructure,
located in `libspdk_util.a`. The io_channel infrastructure is an abstraction
located in `libspdk_thread.a`. The io_channel infrastructure is an abstraction
around a basic message passing framework and defines a few key abstractions.
First, spdk_thread is an abstraction for a thread of execution and

View File

@ -43,7 +43,7 @@ C_SRCS = fio_plugin.c
CFLAGS += -I$(FIO_SOURCE_DIR)
LDFLAGS += -shared -rdynamic
SPDK_LIB_LIST += util bdev conf copy rpc jsonrpc json log
SPDK_LIB_LIST += thread util bdev conf copy rpc jsonrpc json log
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = hello_bdev
C_SRCS := hello_bdev.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += bdev copy event util conf trace log jsonrpc json rpc
SPDK_LIB_LIST += bdev copy event thread util conf trace log jsonrpc json rpc
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = blobcli
C_SRCS := blobcli.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event util conf trace \
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event thread util conf trace \
log jsonrpc json rpc
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_NO_LVOL_MODULES_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = hello_blob
C_SRCS := hello_blob.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event util conf trace \
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event thread util conf trace \
log jsonrpc json rpc
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = perf
C_SRCS := perf.c
SPDK_LIB_LIST = ioat util log
SPDK_LIB_LIST = ioat thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = verify
C_SRCS := verify.c
SPDK_LIB_LIST = ioat util log
SPDK_LIB_LIST = ioat thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y += bdev blob blobfs conf copy cunit event json jsonrpc \
log lvol net rpc trace util nvme nvmf scsi ioat \
log lvol net rpc thread trace util nvme nvmf scsi ioat \
ut_mock iscsi
ifeq ($(OS),Linux)
DIRS-y += nbd

View File

@ -55,7 +55,7 @@ endif
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += blobfs bdev copy event util conf trace \
log jsonrpc json rpc
log jsonrpc json rpc thread
AM_LINK += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS)
AM_LINK += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

40
lib/thread/Makefile Normal file
View File

@ -0,0 +1,40 @@
#
# 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.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
C_SRCS = thread.c
LIBNAME = thread
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk

View File

@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
C_SRCS = bit_array.c cpuset.c crc16.c crc32.c crc32c.c crc32_ieee.c fd.c io_channel.c strerror_tls.c string.c uuid.c
C_SRCS = bit_array.c cpuset.c crc16.c crc32.c crc32c.c crc32_ieee.c fd.c strerror_tls.c string.c uuid.c
LIBNAME = util
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk

View File

@ -38,7 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
C_SRCS = $(APP:%=%.c)
SPDK_LIB_LIST = nvme util log
SPDK_LIB_LIST = nvme thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -40,7 +40,7 @@ C_SRCS = $(TEST_FILE)
CFLAGS += -I$(SPDK_ROOT_DIR)/lib
CFLAGS += -I$(SPDK_ROOT_DIR)/test
SPDK_LIB_LIST += util log spdk_mock
SPDK_LIB_LIST += thread util log spdk_mock
LIBS += -lcunit $(SPDK_LIB_LINKER_ARGS)

View File

@ -41,7 +41,7 @@ APP = bdev_svc
C_SRCS := bdev_svc.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += nvmf event log trace conf util bdev copy rpc jsonrpc json
SPDK_LIB_LIST += nvmf event log trace conf thread util bdev copy rpc jsonrpc json
SPDK_LIB_LIST += app_rpc log_rpc bdev_rpc
ifeq ($(OS),Linux)

View File

@ -39,7 +39,7 @@ APP = histogram_perf
C_SRCS = histogram_perf.c
SPDK_LIB_LIST = util
SPDK_LIB_LIST = thread util
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = jsoncat
C_SRCS = jsoncat.c
SPDK_LIB_LIST = json util
SPDK_LIB_LIST = json thread util
LIBS += $(SPDK_LIB_LINKER_ARGS)

View File

@ -39,7 +39,7 @@ APP = stub
C_SRCS := stub.c
SPDK_LIB_LIST = event conf nvme log trace rpc jsonrpc json util
SPDK_LIB_LIST = event conf nvme log trace rpc jsonrpc json thread util
LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS += $(ENV_LINKER_ARGS)

View File

@ -41,7 +41,7 @@ APP = bdevio
C_SRCS := bdevio.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += bdev copy event trace log conf util rpc jsonrpc json
SPDK_LIB_LIST += bdev copy event trace log conf thread util rpc jsonrpc json
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS)

View File

@ -41,7 +41,7 @@ APP = bdevperf
C_SRCS := bdevperf.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += bdev copy event trace log conf util rpc jsonrpc json
SPDK_LIB_LIST += bdev copy event trace log conf thread util rpc jsonrpc json
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS)

View File

@ -41,7 +41,7 @@ APP = fuse
C_SRCS := fuse.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event util conf trace \
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event thread util conf trace \
log jsonrpc json rpc
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS)

View File

@ -41,7 +41,7 @@ APP = mkfs
C_SRCS := mkfs.c
SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event util conf trace \
SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event thread util conf trace \
log jsonrpc json rpc
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS)

View File

@ -38,7 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
APP = event_perf
C_SRCS := event_perf.c
SPDK_LIB_LIST = event trace conf util log rpc jsonrpc json
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -38,7 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
APP = reactor
C_SRCS := reactor.c
SPDK_LIB_LIST = event trace conf util log rpc jsonrpc json
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -38,7 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
APP = reactor_perf
C_SRCS := reactor_perf.c
SPDK_LIB_LIST = event trace conf util log rpc jsonrpc json
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)

View File

@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y = bdev blob blobfs event ioat iscsi json jsonrpc log lvol net nvme nvmf scsi util
DIRS-y = bdev blob blobfs event ioat iscsi json jsonrpc log lvol net nvme nvmf scsi thread util
ifeq ($(OS),Linux)
DIRS-$(CONFIG_VHOST) += vhost
endif

View File

@ -0,0 +1,44 @@
#
# 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.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y = thread.c
.PHONY: all clean $(DIRS-y)
all: $(DIRS-y)
clean: $(DIRS-y)
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk

View File

@ -0,0 +1 @@
thread_ut

View File

@ -36,6 +36,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
include $(SPDK_ROOT_DIR)/mk/spdk.mock.unittest.mk
TEST_FILE = io_channel_ut.c
TEST_FILE = thread_ut.c
include $(SPDK_ROOT_DIR)/mk/spdk.unittest.mk

View File

@ -35,7 +35,7 @@
#include "spdk_cunit.h"
#include "util/io_channel.c"
#include "thread/thread.c"
#include "common/lib/test_env.c"
#include "common/lib/ut_multithread.c"

View File

@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y = bit_array.c cpuset.c crc16.c crc32_ieee.c crc32c.c io_channel.c string.c
DIRS-y = bit_array.c cpuset.c crc16.c crc32_ieee.c crc32c.c string.c
.PHONY: all clean $(DIRS-y)

View File

@ -1 +0,0 @@
io_channel_ut

View File

@ -107,11 +107,12 @@ $valgrind $testdir/lib/iscsi/iscsi.c/iscsi_ut
$valgrind $testdir/lib/iscsi/init_grp.c/init_grp_ut $testdir/lib/iscsi/init_grp.c/init_grp.conf
$valgrind $testdir/lib/iscsi/portal_grp.c/portal_grp_ut $testdir/lib/iscsi/portal_grp.c/portal_grp.conf
$valgrind $testdir/lib/thread/thread.c/thread_ut
$valgrind $testdir/lib/util/bit_array.c/bit_array_ut
$valgrind $testdir/lib/util/crc16.c/crc16_ut
$valgrind $testdir/lib/util/crc32_ieee.c/crc32_ieee_ut
$valgrind $testdir/lib/util/crc32c.c/crc32c_ut
$valgrind $testdir/lib/util/io_channel.c/io_channel_ut
$valgrind $testdir/lib/util/string.c/string_ut
if [ $(uname -s) = Linux ]; then