mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
net/mlx5: DR, Allocate htbl from its own slab allocator
SW steering allocates/frees lots of htbl structs. Create a separate kmem_cache and allocate htbls from this allocator. Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Reviewed-by: Alex Vesker <valex@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
fd785e5213
commit
fb628b71fb
|
|
@ -68,11 +68,20 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
dmn->htbls_kmem_cache = kmem_cache_create("mlx5_dr_htbls",
|
||||
sizeof(struct mlx5dr_ste_htbl), 0,
|
||||
SLAB_HWCACHE_ALIGN, NULL);
|
||||
if (!dmn->htbls_kmem_cache) {
|
||||
mlx5dr_err(dmn, "Couldn't create hash tables kmem_cache\n");
|
||||
ret = -ENOMEM;
|
||||
goto free_chunks_kmem_cache;
|
||||
}
|
||||
|
||||
dmn->ste_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_STE);
|
||||
if (!dmn->ste_icm_pool) {
|
||||
mlx5dr_err(dmn, "Couldn't get icm memory\n");
|
||||
ret = -ENOMEM;
|
||||
goto free_chunks_kmem_cache;
|
||||
goto free_htbls_kmem_cache;
|
||||
}
|
||||
|
||||
dmn->action_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_MODIFY_ACTION);
|
||||
|
|
@ -94,6 +103,8 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
|
|||
mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
|
||||
free_ste_icm_pool:
|
||||
mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
|
||||
free_htbls_kmem_cache:
|
||||
kmem_cache_destroy(dmn->htbls_kmem_cache);
|
||||
free_chunks_kmem_cache:
|
||||
kmem_cache_destroy(dmn->chunks_kmem_cache);
|
||||
|
||||
|
|
@ -105,6 +116,7 @@ static void dr_domain_uninit_mem_resources(struct mlx5dr_domain *dmn)
|
|||
mlx5dr_send_info_pool_destroy(dmn);
|
||||
mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
|
||||
mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
|
||||
kmem_cache_destroy(dmn->htbls_kmem_cache);
|
||||
kmem_cache_destroy(dmn->chunks_kmem_cache);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -470,6 +470,16 @@ void mlx5dr_icm_free_chunk(struct mlx5dr_icm_chunk *chunk)
|
|||
mutex_unlock(&pool->mutex);
|
||||
}
|
||||
|
||||
struct mlx5dr_ste_htbl *mlx5dr_icm_pool_alloc_htbl(struct mlx5dr_icm_pool *pool)
|
||||
{
|
||||
return kmem_cache_alloc(pool->dmn->htbls_kmem_cache, GFP_KERNEL);
|
||||
}
|
||||
|
||||
void mlx5dr_icm_pool_free_htbl(struct mlx5dr_icm_pool *pool, struct mlx5dr_ste_htbl *htbl)
|
||||
{
|
||||
kmem_cache_free(pool->dmn->htbls_kmem_cache, htbl);
|
||||
}
|
||||
|
||||
struct mlx5dr_icm_pool *mlx5dr_icm_pool_create(struct mlx5dr_domain *dmn,
|
||||
enum mlx5dr_icm_type icm_type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
|
|||
u32 num_entries;
|
||||
int i;
|
||||
|
||||
htbl = kzalloc(sizeof(*htbl), GFP_KERNEL);
|
||||
htbl = mlx5dr_icm_pool_alloc_htbl(pool);
|
||||
if (!htbl)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -503,6 +503,9 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
|
|||
htbl->lu_type = lu_type;
|
||||
htbl->byte_mask = byte_mask;
|
||||
htbl->refcount = 0;
|
||||
htbl->pointing_ste = NULL;
|
||||
htbl->ctrl.num_of_valid_entries = 0;
|
||||
htbl->ctrl.num_of_collisions = 0;
|
||||
num_entries = mlx5dr_icm_pool_get_chunk_num_of_entries(chunk);
|
||||
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
|
|
@ -517,17 +520,20 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
|
|||
return htbl;
|
||||
|
||||
out_free_htbl:
|
||||
kfree(htbl);
|
||||
mlx5dr_icm_pool_free_htbl(pool, htbl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mlx5dr_ste_htbl_free(struct mlx5dr_ste_htbl *htbl)
|
||||
{
|
||||
struct mlx5dr_icm_pool *pool = htbl->chunk->buddy_mem->pool;
|
||||
|
||||
if (htbl->refcount)
|
||||
return -EBUSY;
|
||||
|
||||
mlx5dr_icm_free_chunk(htbl->chunk);
|
||||
kfree(htbl);
|
||||
mlx5dr_icm_pool_free_htbl(pool, htbl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -916,6 +916,7 @@ struct mlx5dr_domain {
|
|||
struct mlx5dr_send_info_pool *send_info_pool_rx;
|
||||
struct mlx5dr_send_info_pool *send_info_pool_tx;
|
||||
struct kmem_cache *chunks_kmem_cache;
|
||||
struct kmem_cache *htbls_kmem_cache;
|
||||
struct mlx5dr_send_ring *send_ring;
|
||||
struct mlx5dr_domain_info info;
|
||||
struct xarray csum_fts_xa;
|
||||
|
|
@ -1162,6 +1163,9 @@ u32 mlx5dr_icm_pool_get_chunk_num_of_entries(struct mlx5dr_icm_chunk *chunk);
|
|||
u32 mlx5dr_icm_pool_get_chunk_byte_size(struct mlx5dr_icm_chunk *chunk);
|
||||
u8 *mlx5dr_ste_get_hw_ste(struct mlx5dr_ste *ste);
|
||||
|
||||
struct mlx5dr_ste_htbl *mlx5dr_icm_pool_alloc_htbl(struct mlx5dr_icm_pool *pool);
|
||||
void mlx5dr_icm_pool_free_htbl(struct mlx5dr_icm_pool *pool, struct mlx5dr_ste_htbl *htbl);
|
||||
|
||||
static inline int
|
||||
mlx5dr_icm_pool_dm_type_to_entry_size(enum mlx5dr_icm_type icm_type)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user