Skip to content

Commit

Permalink
xsk: Remove unnecessary member in xdp_umem
Browse files Browse the repository at this point in the history
Remove the unnecessary member of address in struct xdp_umem as it is
only used during the umem registration. No need to carry this around
as it is not used during run-time nor when unregistering the umem.

Signed-off-by: Magnus Karlsson <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Jonathan Lemon <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
magnus-karlsson authored and borkmann committed May 4, 2020
1 parent e4e5aef commit 07bf2d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion include/net/xdp_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ struct xdp_umem {
u32 headroom;
u32 chunk_size_nohr;
struct user_struct *user;
unsigned long address;
refcount_t users;
struct work_struct work;
struct page **pgs;
Expand Down
7 changes: 3 additions & 4 deletions net/xdp/xdp_umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void xdp_put_umem(struct xdp_umem *umem)
}
}

static int xdp_umem_pin_pages(struct xdp_umem *umem)
static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
{
unsigned int gup_flags = FOLL_WRITE;
long npgs;
Expand All @@ -291,7 +291,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem)
return -ENOMEM;

down_read(&current->mm->mmap_sem);
npgs = pin_user_pages(umem->address, umem->npgs,
npgs = pin_user_pages(address, umem->npgs,
gup_flags | FOLL_LONGTERM, &umem->pgs[0], NULL);
up_read(&current->mm->mmap_sem);

Expand Down Expand Up @@ -385,7 +385,6 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
if (headroom >= chunk_size - XDP_PACKET_HEADROOM)
return -EINVAL;

umem->address = (unsigned long)addr;
umem->chunk_mask = unaligned_chunks ? XSK_UNALIGNED_BUF_ADDR_MASK
: ~((u64)chunk_size - 1);
umem->size = size;
Expand All @@ -404,7 +403,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
if (err)
return err;

err = xdp_umem_pin_pages(umem);
err = xdp_umem_pin_pages(umem, (unsigned long)addr);
if (err)
goto out_account;

Expand Down

0 comments on commit 07bf2d9

Please sign in to comment.