Skip to content

Commit

Permalink
linux-dpdk: pool: remove unused control path lock type selection
Browse files Browse the repository at this point in the history
Use always ticketlock for control path pool functions.

Signed-off-by: Matias Elo <[email protected]>
  • Loading branch information
MatiasElo committed Jan 8, 2025
1 parent 226984e commit e4b5eda
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 48 deletions.
18 changes: 1 addition & 17 deletions platform/linux-dpdk/include/odp_pool_internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2021-2023 Nokia
* Copyright (c) 2021-2025 Nokia
*/

/**
Expand Down Expand Up @@ -47,24 +47,8 @@ extern "C" {
#undef vector
#endif

/* Use ticketlock instead of spinlock */
#define POOL_USE_TICKETLOCK

/* Extra error checks */
/* #define POOL_ERROR_CHECK */

#ifdef POOL_USE_TICKETLOCK
#include <odp/api/ticketlock.h>
#else
#include <odp/api/spinlock.h>
#endif

typedef struct ODP_ALIGNED_CACHE {
#ifdef POOL_USE_TICKETLOCK
odp_ticketlock_t lock ODP_ALIGNED_CACHE;
#else
odp_spinlock_t lock ODP_ALIGNED_CACHE;
#endif
uint32_t pool_idx;

/* Everything under this mark is memset() to zero on pool create */
Expand Down
51 changes: 20 additions & 31 deletions platform/linux-dpdk/odp_pool.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2019-2023 Nokia
* Copyright (c) 2019-2025 Nokia
*/

#include <odp/api/align.h>
#include <odp/api/hints.h>
#include <odp/api/pool.h>
#include <odp/api/shared_memory.h>
#include <odp/api/std_types.h>
#include <odp/api/ticketlock.h>

#include <odp/api/plat/pool_inline_types.h>

Expand Down Expand Up @@ -41,18 +42,6 @@
#include <stdlib.h>
#include <string.h>

#ifdef POOL_USE_TICKETLOCK
#include <odp/api/ticketlock.h>
#define LOCK(a) odp_ticketlock_lock(a)
#define UNLOCK(a) odp_ticketlock_unlock(a)
#define LOCK_INIT(a) odp_ticketlock_init(a)
#else
#include <odp/api/spinlock.h>
#define LOCK(a) odp_spinlock_lock(a)
#define UNLOCK(a) odp_spinlock_unlock(a)
#define LOCK_INIT(a) odp_spinlock_init(a)
#endif

/* Pool name format */
#define POOL_NAME_FORMAT "%" PRIu64 "-%d-%s"

Expand Down Expand Up @@ -185,7 +174,7 @@ int _odp_pool_init_global(void)
for (i = 0; i < CONFIG_POOLS; i++) {
pool_t *pool = _odp_pool_entry_from_idx(i);

LOCK_INIT(&pool->lock);
odp_ticketlock_init(&pool->lock);
pool->pool_idx = i;
}

Expand Down Expand Up @@ -589,10 +578,10 @@ static pool_t *get_unused_pool(void)

for (int i = 0; i < CONFIG_POOLS; i++) {
pool = _odp_pool_entry_from_idx(i);
LOCK(&pool->lock);
odp_ticketlock_lock(&pool->lock);

if (pool->rte_mempool != NULL) {
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
continue;
}

Expand Down Expand Up @@ -733,7 +722,7 @@ odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,
priv_data.event_type = ODP_EVENT_PACKET_VECTOR;
break;
default:
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
_ODP_ERR("Bad pool type %i\n", params->type);
return ODP_POOL_INVALID;
}
Expand All @@ -743,7 +732,7 @@ odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,
pool->name, num, priv_size, align, data_size, seg_size, uarea_size);

if (priv_size > UINT16_MAX || data_size > UINT16_MAX) {
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
_ODP_ERR("Invalid element size(s), private: %u, data room: %u (max: %u)\n",
priv_size, data_size, UINT16_MAX);
return ODP_POOL_INVALID;
Expand All @@ -754,13 +743,13 @@ odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,
data_size, rte_socket_id());

if (mp == NULL) {
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
_ODP_ERR("Cannot init DPDK mbuf pool: %s\n", rte_strerror(rte_errno));
return ODP_POOL_INVALID;
}

if (reserve_uarea(pool, uarea_size, num)) {
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
_ODP_ERR("User area SHM reserve failed\n");
rte_mempool_free(mp);
return ODP_POOL_INVALID;
Expand All @@ -775,7 +764,7 @@ odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,

rte_mempool_obj_iter(mp, init_obj_priv_data, &priv_data);

UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
pool_hdl = _odp_pool_handle(pool);

return pool_hdl;
Expand All @@ -797,13 +786,13 @@ odp_pool_t odp_pool_lookup(const char *name)
for (i = 0; i < CONFIG_POOLS; i++) {
pool = _odp_pool_entry_from_idx(i);

LOCK(&pool->lock);
odp_ticketlock_lock(&pool->lock);
if (strcmp(name, pool->name) == 0) {
/* Found it */
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
return _odp_pool_handle(pool);
}
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
}

return ODP_POOL_INVALID;
Expand Down Expand Up @@ -883,10 +872,10 @@ void odp_pool_print_all(void)
for (i = 0; i < CONFIG_POOLS; i++) {
pool_t *pool = _odp_pool_entry_from_idx(i);

LOCK(&pool->lock);
odp_ticketlock_lock(&pool->lock);

if (pool->rte_mempool == NULL) {
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
continue;
}

Expand All @@ -899,7 +888,7 @@ void odp_pool_print_all(void)
type = pool->type;
elt_size = pool->rte_mempool->elt_size;

UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);

if (type == ODP_POOL_BUFFER || type == ODP_POOL_PACKET)
elt_len = elt_size;
Expand Down Expand Up @@ -1228,9 +1217,9 @@ odp_pool_t odp_pool_ext_create(const char *name,

pool = _odp_pool_entry_from_idx(i);

LOCK(&pool->lock);
odp_ticketlock_lock(&pool->lock);
if (pool->rte_mempool != NULL) {
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
continue;
}

Expand Down Expand Up @@ -1308,15 +1297,15 @@ odp_pool_t odp_pool_ext_create(const char *name,
mp->header_size, mp->elt_size, mp->trailer_size,
(unsigned long)((mp->header_size + mp->elt_size +
mp->trailer_size) * num));
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
pool_hdl = _odp_pool_handle(pool);
break;
}

return pool_hdl;

error:
UNLOCK(&pool->lock);
odp_ticketlock_unlock(&pool->lock);
return ODP_POOL_INVALID;
}

Expand Down

0 comments on commit e4b5eda

Please sign in to comment.