Skip to content

Commit

Permalink
xsk: convert atomic_t to refcount_t
Browse files Browse the repository at this point in the history
Introduce refcount_t, in favor of atomic_t.

Signed-off-by: Björn Töpel <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
Björn Töpel authored and borkmann committed May 22, 2018
1 parent a49049e commit d3b42f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions net/xdp/xdp_umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ static void xdp_umem_release_deferred(struct work_struct *work)

void xdp_get_umem(struct xdp_umem *umem)
{
atomic_inc(&umem->users);
refcount_inc(&umem->users);
}

void xdp_put_umem(struct xdp_umem *umem)
{
if (!umem)
return;

if (atomic_dec_and_test(&umem->users)) {
if (refcount_dec_and_test(&umem->users)) {
INIT_WORK(&umem->work, xdp_umem_release_deferred);
schedule_work(&umem->work);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
umem->frame_size_log2 = ilog2(frame_size);
umem->nfpp_mask = nfpp - 1;
umem->nfpplog2 = ilog2(nfpp);
atomic_set(&umem->users, 1);
refcount_set(&umem->users, 1);

err = xdp_umem_account_pages(umem);
if (err)
Expand Down
2 changes: 1 addition & 1 deletion net/xdp/xdp_umem.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct xdp_umem {
struct pid *pid;
unsigned long address;
size_t size;
atomic_t users;
refcount_t users;
struct work_struct work;
};

Expand Down

0 comments on commit d3b42f1

Please sign in to comment.