diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 6a04c3c330..fa8afdb3a3 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -581,6 +581,16 @@ Known Issues 5. It MUST not be used by multi-producer/consumer pthreads, whose scheduling policies are SCHED_FIFO or SCHED_RR. + Alternatively, applications can use the lock-free stack mempool handler. When + considering this handler, note that: + + - It is currently limited to the x86_64 platform, because it uses an + instruction (16-byte compare-and-swap) that is not yet available on other + platforms. + - It has worse average-case performance than the non-preemptive rte_ring, but + software caching (e.g. the mempool cache) can mitigate this by reducing the + number of stack accesses. + + rte_timer Running ``rte_timer_manage()`` on a non-EAL pthread is not allowed. However, resetting/stopping the timer from a non-EAL pthread is allowed. diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst index ae55e54984..487928bedb 100644 --- a/doc/guides/rel_notes/release_19_05.rst +++ b/doc/guides/rel_notes/release_19_05.rst @@ -63,6 +63,11 @@ New Features The library supports two stack implementations: standard (lock-based) and lock-free. The lock-free implementation is currently limited to x86-64 platforms. +* **Added Lock-Free Stack Mempool Handler.** + + Added a new lock-free stack handler, which uses the newly added stack + library. + * **Updated KNI module and PMD.** Updated the KNI kernel module to set the max_mtu according to the given diff --git a/drivers/mempool/stack/rte_mempool_stack.c b/drivers/mempool/stack/rte_mempool_stack.c index 25ccdb9afc..7e85c8d6b6 100644 --- a/drivers/mempool/stack/rte_mempool_stack.c +++ b/drivers/mempool/stack/rte_mempool_stack.c @@ -7,7 +7,7 @@ #include static int -stack_alloc(struct rte_mempool *mp) +__stack_alloc(struct rte_mempool *mp, uint32_t flags) { char name[RTE_STACK_NAMESIZE]; struct rte_stack *s; @@ -20,7 +20,7 @@ stack_alloc(struct rte_mempool *mp) return -rte_errno; } - s = rte_stack_create(name, mp->size, mp->socket_id, 0); + s = rte_stack_create(name, mp->size, mp->socket_id, flags); if (s == NULL) return -rte_errno; @@ -29,6 +29,18 @@ stack_alloc(struct rte_mempool *mp) return 0; } +static int +stack_alloc(struct rte_mempool *mp) +{ + return __stack_alloc(mp, 0); +} + +static int +lf_stack_alloc(struct rte_mempool *mp) +{ + return __stack_alloc(mp, RTE_STACK_F_LF); +} + static int stack_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned int n) @@ -72,4 +84,14 @@ static struct rte_mempool_ops ops_stack = { .get_count = stack_get_count }; +static struct rte_mempool_ops ops_lf_stack = { + .name = "lf_stack", + .alloc = lf_stack_alloc, + .free = stack_free, + .enqueue = stack_enqueue, + .dequeue = stack_dequeue, + .get_count = stack_get_count +}; + MEMPOOL_REGISTER_OPS(ops_stack); +MEMPOOL_REGISTER_OPS(ops_lf_stack);