xsk: convert atomic_t to refcount_t
authorBjörn Töpel <bjorn.topel@intel.com>
Tue, 22 May 2018 07:35:03 +0000 (09:35 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 22 May 2018 08:25:06 +0000 (10:25 +0200)
Introduce refcount_t, in favor of atomic_t.

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/xdp/xdp_umem.c
net/xdp/xdp_umem.h

index faa6ffbaf6abb4a0beddb9f03a00f24624a42f83..87998818116f15380ddf47125f41a60af426e4ca 100644 (file)
@@ -78,7 +78,7 @@ 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)
@@ -86,7 +86,7 @@ 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);
        }
@@ -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)
index 9802287ff19ddb9cfaad475920e7536f462e2c1e..0881cf456230e737fdb515af3e99d7d38429eefd 100644 (file)
@@ -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;
 };