linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems
@ 2019-06-26 15:59 Ivan Khoronzhuk
  2019-06-26 20:50 ` Björn Töpel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ivan Khoronzhuk @ 2019-06-26 15:59 UTC (permalink / raw)
  To: bjorn.topel, magnus.karlsson, davem
  Cc: ast, daniel, hawk, john.fastabend, netdev, bpf, xdp-newbies,
	linux-kernel, Ivan Khoronzhuk

Use kmap instead of page_address as it's not always in low memory.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 net/xdp/xdp_umem.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 9c6de4f114f8..d3c1411420fd 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -169,6 +169,14 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
 	}
 }
 
+static void xdp_umem_unmap_pages(struct xdp_umem *umem)
+{
+	unsigned int i;
+
+	for (i = 0; i < umem->npgs; i++)
+		kunmap(umem->pgs[i]);
+}
+
 static void xdp_umem_unpin_pages(struct xdp_umem *umem)
 {
 	unsigned int i;
@@ -210,6 +218,7 @@ static void xdp_umem_release(struct xdp_umem *umem)
 
 	xsk_reuseq_destroy(umem);
 
+	xdp_umem_unmap_pages(umem);
 	xdp_umem_unpin_pages(umem);
 
 	kfree(umem->pages);
@@ -372,7 +381,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
 	}
 
 	for (i = 0; i < umem->npgs; i++)
-		umem->pages[i].addr = page_address(umem->pgs[i]);
+		umem->pages[i].addr = kmap(umem->pgs[i]);
 
 	return 0;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems
  2019-06-26 15:59 [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems Ivan Khoronzhuk
@ 2019-06-26 20:50 ` Björn Töpel
  2019-06-29 17:53   ` David Miller
  2019-06-27  7:04 ` kbuild test robot
  2019-06-27  9:01 ` kbuild test robot
  2 siblings, 1 reply; 6+ messages in thread
From: Björn Töpel @ 2019-06-26 20:50 UTC (permalink / raw)
  To: Ivan Khoronzhuk
  Cc: Björn Töpel, Karlsson, Magnus, David Miller,
	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
	John Fastabend, Netdev, bpf, Xdp, LKML

On Wed, 26 Jun 2019 at 17:59, Ivan Khoronzhuk
<ivan.khoronzhuk@linaro.org> wrote:
>
> Use kmap instead of page_address as it's not always in low memory.
>

Ah, some 32-bit love. :-) Thanks for working on this!

For future patches, please base AF_XDP patches on the bpf/bpf-next
tree instead of net/net-next.

Acked-by: Björn Töpel <bjorn.topel@intel.com>

> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> ---
>  net/xdp/xdp_umem.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
> index 9c6de4f114f8..d3c1411420fd 100644
> --- a/net/xdp/xdp_umem.c
> +++ b/net/xdp/xdp_umem.c
> @@ -169,6 +169,14 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
>         }
>  }
>
> +static void xdp_umem_unmap_pages(struct xdp_umem *umem)
> +{
> +       unsigned int i;
> +
> +       for (i = 0; i < umem->npgs; i++)
> +               kunmap(umem->pgs[i]);
> +}
> +
>  static void xdp_umem_unpin_pages(struct xdp_umem *umem)
>  {
>         unsigned int i;
> @@ -210,6 +218,7 @@ static void xdp_umem_release(struct xdp_umem *umem)
>
>         xsk_reuseq_destroy(umem);
>
> +       xdp_umem_unmap_pages(umem);
>         xdp_umem_unpin_pages(umem);
>
>         kfree(umem->pages);
> @@ -372,7 +381,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
>         }
>
>         for (i = 0; i < umem->npgs; i++)
> -               umem->pages[i].addr = page_address(umem->pgs[i]);
> +               umem->pages[i].addr = kmap(umem->pgs[i]);
>
>         return 0;
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems
  2019-06-26 15:59 [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems Ivan Khoronzhuk
  2019-06-26 20:50 ` Björn Töpel
@ 2019-06-27  7:04 ` kbuild test robot
  2019-06-27  9:01 ` kbuild test robot
  2 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-06-27  7:04 UTC (permalink / raw)
  To: Ivan Khoronzhuk
  Cc: kbuild-all, bjorn.topel, magnus.karlsson, davem, ast, daniel,
	hawk, john.fastabend, netdev, bpf, xdp-newbies, linux-kernel,
	Ivan Khoronzhuk

[-- Attachment #1: Type: text/plain, Size: 4008 bytes --]

Hi Ivan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Ivan-Khoronzhuk/xdp-xdp_umem-fix-umem-pages-mapping-for-32bits-systems/20190627-135949
config: i386-randconfig-x073-201925 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-9) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   net//xdp/xdp_umem.c: In function 'xdp_umem_unmap_pages':
   net//xdp/xdp_umem.c:177:3: error: implicit declaration of function 'kunmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
      kunmap(umem->pgs[i]);
      ^~~~~~
      vunmap
   net//xdp/xdp_umem.c: In function 'xdp_umem_reg':
>> net//xdp/xdp_umem.c:384:25: error: implicit declaration of function 'kmap'; did you mean 'vmap'? [-Werror=implicit-function-declaration]
      umem->pages[i].addr = kmap(umem->pgs[i]);
                            ^~~~
                            vmap
   net//xdp/xdp_umem.c:384:23: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
      umem->pages[i].addr = kmap(umem->pgs[i]);
                          ^
   cc1: some warnings being treated as errors

vim +384 net//xdp/xdp_umem.c

   311	
   312	static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
   313	{
   314		u32 chunk_size = mr->chunk_size, headroom = mr->headroom;
   315		unsigned int chunks, chunks_per_page;
   316		u64 addr = mr->addr, size = mr->len;
   317		int size_chk, err, i;
   318	
   319		if (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) {
   320			/* Strictly speaking we could support this, if:
   321			 * - huge pages, or*
   322			 * - using an IOMMU, or
   323			 * - making sure the memory area is consecutive
   324			 * but for now, we simply say "computer says no".
   325			 */
   326			return -EINVAL;
   327		}
   328	
   329		if (!is_power_of_2(chunk_size))
   330			return -EINVAL;
   331	
   332		if (!PAGE_ALIGNED(addr)) {
   333			/* Memory area has to be page size aligned. For
   334			 * simplicity, this might change.
   335			 */
   336			return -EINVAL;
   337		}
   338	
   339		if ((addr + size) < addr)
   340			return -EINVAL;
   341	
   342		chunks = (unsigned int)div_u64(size, chunk_size);
   343		if (chunks == 0)
   344			return -EINVAL;
   345	
   346		chunks_per_page = PAGE_SIZE / chunk_size;
   347		if (chunks < chunks_per_page || chunks % chunks_per_page)
   348			return -EINVAL;
   349	
   350		headroom = ALIGN(headroom, 64);
   351	
   352		size_chk = chunk_size - headroom - XDP_PACKET_HEADROOM;
   353		if (size_chk < 0)
   354			return -EINVAL;
   355	
   356		umem->address = (unsigned long)addr;
   357		umem->chunk_mask = ~((u64)chunk_size - 1);
   358		umem->size = size;
   359		umem->headroom = headroom;
   360		umem->chunk_size_nohr = chunk_size - headroom;
   361		umem->npgs = size / PAGE_SIZE;
   362		umem->pgs = NULL;
   363		umem->user = NULL;
   364		INIT_LIST_HEAD(&umem->xsk_list);
   365		spin_lock_init(&umem->xsk_list_lock);
   366	
   367		refcount_set(&umem->users, 1);
   368	
   369		err = xdp_umem_account_pages(umem);
   370		if (err)
   371			return err;
   372	
   373		err = xdp_umem_pin_pages(umem);
   374		if (err)
   375			goto out_account;
   376	
   377		umem->pages = kcalloc(umem->npgs, sizeof(*umem->pages), GFP_KERNEL);
   378		if (!umem->pages) {
   379			err = -ENOMEM;
   380			goto out_account;
   381		}
   382	
   383		for (i = 0; i < umem->npgs; i++)
 > 384			umem->pages[i].addr = kmap(umem->pgs[i]);
   385	
   386		return 0;
   387	
   388	out_account:
   389		xdp_umem_unaccount_pages(umem);
   390		return err;
   391	}
   392	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32965 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems
  2019-06-26 15:59 [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems Ivan Khoronzhuk
  2019-06-26 20:50 ` Björn Töpel
  2019-06-27  7:04 ` kbuild test robot
@ 2019-06-27  9:01 ` kbuild test robot
  2 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-06-27  9:01 UTC (permalink / raw)
  To: Ivan Khoronzhuk
  Cc: kbuild-all, bjorn.topel, magnus.karlsson, davem, ast, daniel,
	hawk, john.fastabend, netdev, bpf, xdp-newbies, linux-kernel,
	Ivan Khoronzhuk

[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]

Hi Ivan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Ivan-Khoronzhuk/xdp-xdp_umem-fix-umem-pages-mapping-for-32bits-systems/20190627-135949
config: x86_64-randconfig-x004-201925 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-9) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   net//xdp/xdp_umem.c: In function 'xdp_umem_unmap_pages':
>> net//xdp/xdp_umem.c:177:3: error: implicit declaration of function 'kunmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
      kunmap(umem->pgs[i]);
      ^~~~~~
      vunmap
   net//xdp/xdp_umem.c: In function 'xdp_umem_reg':
>> net//xdp/xdp_umem.c:384:25: error: implicit declaration of function 'kmap'; did you mean 'bmap'? [-Werror=implicit-function-declaration]
      umem->pages[i].addr = kmap(umem->pgs[i]);
                            ^~~~
                            bmap
>> net//xdp/xdp_umem.c:384:23: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
      umem->pages[i].addr = kmap(umem->pgs[i]);
                          ^
   cc1: some warnings being treated as errors

vim +177 net//xdp/xdp_umem.c

   171	
   172	static void xdp_umem_unmap_pages(struct xdp_umem *umem)
   173	{
   174		unsigned int i;
   175	
   176		for (i = 0; i < umem->npgs; i++)
 > 177			kunmap(umem->pgs[i]);
   178	}
   179	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28463 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems
  2019-06-26 20:50 ` Björn Töpel
@ 2019-06-29 17:53   ` David Miller
  2019-07-01 13:10     ` Björn Töpel
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2019-06-29 17:53 UTC (permalink / raw)
  To: bjorn.topel
  Cc: ivan.khoronzhuk, bjorn.topel, magnus.karlsson, ast, daniel, hawk,
	john.fastabend, netdev, bpf, xdp-newbies, linux-kernel

From: Björn Töpel <bjorn.topel@gmail.com>
Date: Wed, 26 Jun 2019 22:50:23 +0200

> On Wed, 26 Jun 2019 at 17:59, Ivan Khoronzhuk
> <ivan.khoronzhuk@linaro.org> wrote:
>>
>> Use kmap instead of page_address as it's not always in low memory.
>>
> 
> Ah, some 32-bit love. :-) Thanks for working on this!
> 
> For future patches, please base AF_XDP patches on the bpf/bpf-next
> tree instead of net/net-next.
> 
> Acked-by: Björn Töpel <bjorn.topel@intel.com>

Alexei and Daniel, I'll let you guys take this one.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems
  2019-06-29 17:53   ` David Miller
@ 2019-07-01 13:10     ` Björn Töpel
  0 siblings, 0 replies; 6+ messages in thread
From: Björn Töpel @ 2019-07-01 13:10 UTC (permalink / raw)
  To: David Miller, Ivan Khoronzhuk
  Cc: Björn Töpel, Karlsson, Magnus, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend, Netdev,
	bpf, Xdp, LKML

On Sat, 29 Jun 2019 at 19:53, David Miller <davem@davemloft.net> wrote:
>
> From: Björn Töpel <bjorn.topel@gmail.com>
> Date: Wed, 26 Jun 2019 22:50:23 +0200
>
> > On Wed, 26 Jun 2019 at 17:59, Ivan Khoronzhuk
> > <ivan.khoronzhuk@linaro.org> wrote:
> >>
> >> Use kmap instead of page_address as it's not always in low memory.
> >>
> >
> > Ah, some 32-bit love. :-) Thanks for working on this!
> >
> > For future patches, please base AF_XDP patches on the bpf/bpf-next
> > tree instead of net/net-next.
> >
> > Acked-by: Björn Töpel <bjorn.topel@intel.com>
>
> Alexei and Daniel, I'll let you guys take this one.
>
> Thanks.

Ivan, kbuild reported some build issues. Faulty, or not; Please have a
look at them.


Cheers,
Björn

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-01 13:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 15:59 [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems Ivan Khoronzhuk
2019-06-26 20:50 ` Björn Töpel
2019-06-29 17:53   ` David Miller
2019-07-01 13:10     ` Björn Töpel
2019-06-27  7:04 ` kbuild test robot
2019-06-27  9:01 ` kbuild test robot

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).