Skip to content

Commit 6a57189

Browse files
tititiou36kuba-moo
authored andcommitted
xdp: Remove usage of the deprecated ida_simple_xx() API
ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove(). Note that the upper limit of ida_simple_get() is exclusive, but the one of ida_alloc_range() is inclusive. So a -1 has been added when needed. Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/8e889d18a6c881b09db4650d4b30a62d76f4fe77.1705734073.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 047a7d2 commit 6a57189

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/xdp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void __xdp_mem_allocator_rcu_free(struct rcu_head *rcu)
7575
xa = container_of(rcu, struct xdp_mem_allocator, rcu);
7676

7777
/* Allow this ID to be reused */
78-
ida_simple_remove(&mem_id_pool, xa->mem.id);
78+
ida_free(&mem_id_pool, xa->mem.id);
7979

8080
kfree(xa);
8181
}
@@ -242,7 +242,7 @@ static int __mem_id_cyclic_get(gfp_t gfp)
242242
int id;
243243

244244
again:
245-
id = ida_simple_get(&mem_id_pool, mem_id_next, MEM_ID_MAX, gfp);
245+
id = ida_alloc_range(&mem_id_pool, mem_id_next, MEM_ID_MAX - 1, gfp);
246246
if (id < 0) {
247247
if (id == -ENOSPC) {
248248
/* Cyclic allocator, reset next id */
@@ -317,7 +317,7 @@ static struct xdp_mem_allocator *__xdp_reg_mem_model(struct xdp_mem_info *mem,
317317
/* Insert allocator into ID lookup table */
318318
ptr = rhashtable_insert_slow(mem_id_ht, &id, &xdp_alloc->node);
319319
if (IS_ERR(ptr)) {
320-
ida_simple_remove(&mem_id_pool, mem->id);
320+
ida_free(&mem_id_pool, mem->id);
321321
mem->id = 0;
322322
errno = PTR_ERR(ptr);
323323
goto err;

0 commit comments

Comments
 (0)