2019-04-03 23:20:13 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright(c) 2019 Intel Corporation
|
|
|
|
|
|
|
|
include $(RTE_SDK)/mk/rte.vars.mk
|
|
|
|
|
|
|
|
# library name
|
|
|
|
LIB = librte_stack.a
|
|
|
|
|
|
|
|
CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
|
|
|
|
LDLIBS += -lrte_eal
|
|
|
|
|
|
|
|
EXPORT_MAP := rte_stack_version.map
|
|
|
|
|
|
|
|
# all source are stored in SRCS-y
|
|
|
|
SRCS-$(CONFIG_RTE_LIBRTE_STACK) := rte_stack.c \
|
stack: add lock-free implementation
This commit adds support for a lock-free (linked list based) stack to the
stack API. This behavior is selected through a new rte_stack_create() flag,
RTE_STACK_F_LF.
The stack consists of a linked list of elements, each containing a data
pointer and a next pointer, and an atomic stack depth counter.
The lock-free push operation enqueues a linked list of pointers by pointing
the tail of the list to the current stack head, and using a CAS to swing
the stack head pointer to the head of the list. The operation retries if it
is unsuccessful (i.e. the list changed between reading the head and
modifying it), else it adjusts the stack length and returns.
The lock-free pop operation first reserves num elements by adjusting the
stack length, to ensure the dequeue operation will succeed without
blocking. It then dequeues pointers by walking the list -- starting from
the head -- then swinging the head pointer (using a CAS as well). While
walking the list, the data pointers are recorded in an object table.
This algorithm stack uses a 128-bit compare-and-swap instruction, which
atomically updates the stack top pointer and a modification counter, to
protect against the ABA problem.
The linked list elements themselves are maintained in a lock-free LIFO
list, and are allocated before stack pushes and freed after stack pops.
Since the stack has a fixed maximum depth, these elements do not need to be
dynamically created.
Signed-off-by: Gage Eads <gage.eads@intel.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
2019-04-03 23:20:17 +00:00
|
|
|
rte_stack_std.c \
|
|
|
|
rte_stack_lf.c
|
2019-04-03 23:20:13 +00:00
|
|
|
|
|
|
|
# install includes
|
|
|
|
SYMLINK-$(CONFIG_RTE_LIBRTE_STACK)-include := rte_stack.h \
|
stack: add lock-free implementation
This commit adds support for a lock-free (linked list based) stack to the
stack API. This behavior is selected through a new rte_stack_create() flag,
RTE_STACK_F_LF.
The stack consists of a linked list of elements, each containing a data
pointer and a next pointer, and an atomic stack depth counter.
The lock-free push operation enqueues a linked list of pointers by pointing
the tail of the list to the current stack head, and using a CAS to swing
the stack head pointer to the head of the list. The operation retries if it
is unsuccessful (i.e. the list changed between reading the head and
modifying it), else it adjusts the stack length and returns.
The lock-free pop operation first reserves num elements by adjusting the
stack length, to ensure the dequeue operation will succeed without
blocking. It then dequeues pointers by walking the list -- starting from
the head -- then swinging the head pointer (using a CAS as well). While
walking the list, the data pointers are recorded in an object table.
This algorithm stack uses a 128-bit compare-and-swap instruction, which
atomically updates the stack top pointer and a modification counter, to
protect against the ABA problem.
The linked list elements themselves are maintained in a lock-free LIFO
list, and are allocated before stack pushes and freed after stack pops.
Since the stack has a fixed maximum depth, these elements do not need to be
dynamically created.
Signed-off-by: Gage Eads <gage.eads@intel.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
2019-04-03 23:20:17 +00:00
|
|
|
rte_stack_std.h \
|
|
|
|
rte_stack_lf.h \
|
2019-04-03 23:20:18 +00:00
|
|
|
rte_stack_lf_generic.h \
|
2019-10-18 11:21:30 +00:00
|
|
|
rte_stack_lf_c11.h \
|
|
|
|
rte_stack_lf_stubs.h
|
2019-04-03 23:20:13 +00:00
|
|
|
|
|
|
|
include $(RTE_SDK)/mk/rte.lib.mk
|