From: "Björn Töpel" <bjorn.topel@gmail.com>
To: magnus.karlsson@intel.com, magnus.karlsson@gmail.com, ast@fb.com,
daniel@iogearbox.net, netdev@vger.kernel.org
Cc: "Björn Töpel" <bjorn.topel@intel.com>
Subject: [PATCH bpf-next 8/8] xsk: convert atomic_t to refcount_t
Date: Tue, 22 May 2018 09:35:03 +0200 [thread overview]
Message-ID: <20180522073503.2199-9-bjorn.topel@gmail.com> (raw)
In-Reply-To: <20180522073503.2199-1-bjorn.topel@gmail.com>
From: Björn Töpel <bjorn.topel@intel.com>
Introduce refcount_t, in favor of atomic_t.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
net/xdp/xdp_umem.c | 6 +++---
net/xdp/xdp_umem.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index faa6ffbaf6ab..87998818116f 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -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)
diff --git a/net/xdp/xdp_umem.h b/net/xdp/xdp_umem.h
index 9802287ff19d..0881cf456230 100644
--- a/net/xdp/xdp_umem.h
+++ b/net/xdp/xdp_umem.h
@@ -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;
};
--
2.14.1
next prev parent reply other threads:[~2018-05-22 7:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 7:34 [PATCH bpf-next 0/8] AF_XDP follow-up patches, uapi and cleanups Björn Töpel
2018-05-22 7:34 ` [PATCH bpf-next 1/8] xsk: remove rebind support Björn Töpel
2018-05-22 7:34 ` [PATCH bpf-next 2/8] xsk: fill hole in struct sockaddr_xdp Björn Töpel
2018-05-22 7:34 ` [PATCH bpf-next 3/8] xsk: proper queue id check at bind Björn Töpel
2018-05-22 7:34 ` [PATCH bpf-next 4/8] xsk: remove explicit ring structure from uapi Björn Töpel
2018-05-22 7:35 ` [PATCH bpf-next 5/8] samples/bpf: adapt xdpsock to the new uapi Björn Töpel
2018-05-22 7:35 ` [PATCH bpf-next 6/8] xsk: add missing write- and data-dependency barrier Björn Töpel
2018-05-22 7:35 ` [PATCH bpf-next 7/8] xsk: simplified umem setup Björn Töpel
2018-05-22 7:35 ` Björn Töpel [this message]
2018-05-22 8:59 ` [PATCH bpf-next 0/8] AF_XDP follow-up patches, uapi and cleanups Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180522073503.2199-9-bjorn.topel@gmail.com \
--to=bjorn.topel@gmail.com \
--cc=ast@fb.com \
--cc=bjorn.topel@intel.com \
--cc=daniel@iogearbox.net \
--cc=magnus.karlsson@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).