Skip to content

Commit

Permalink
xdp: obtain the mem_id mutex before trying to remove an entry.
Browse files Browse the repository at this point in the history
A lockdep splat was observed when trying to remove an xdp memory
model from the table since the mutex was obtained when trying to
remove the entry, but not before the table walk started:

Fix the splat by obtaining the lock before starting the table walk.

Fixes: c3f812c ("page_pool: do not release pool until inflight == 0.")
Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Tested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jonathan Lemon authored and David S. Miller committed Dec 5, 2019
1 parent 95219af commit 86c76c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/core/xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,17 @@ static void mem_xa_remove(struct xdp_mem_allocator *xa)
{
trace_mem_disconnect(xa);

mutex_lock(&mem_id_lock);

if (!rhashtable_remove_fast(mem_id_ht, &xa->node, mem_id_rht_params))
call_rcu(&xa->rcu, __xdp_mem_allocator_rcu_free);

mutex_unlock(&mem_id_lock);
}

static void mem_allocator_disconnect(void *allocator)
{
struct xdp_mem_allocator *xa;
struct rhashtable_iter iter;

mutex_lock(&mem_id_lock);

rhashtable_walk_enter(mem_id_ht, &iter);
do {
rhashtable_walk_start(&iter);
Expand All @@ -106,6 +104,8 @@ static void mem_allocator_disconnect(void *allocator)

} while (xa == ERR_PTR(-EAGAIN));
rhashtable_walk_exit(&iter);

mutex_unlock(&mem_id_lock);
}

static void mem_id_disconnect(int id)
Expand Down

0 comments on commit 86c76c0

Please sign in to comment.