2019-06-26 15:59:40

by Ivan Khoronzhuk

[permalink] [raw]
Subject: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems

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

Signed-off-by: Ivan Khoronzhuk <[email protected]>
---
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


2019-06-26 20:50:57

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems

On Wed, 26 Jun 2019 at 17:59, Ivan Khoronzhuk
<[email protected]> 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 <[email protected]>

> Signed-off-by: Ivan Khoronzhuk <[email protected]>
> ---
> 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
>

2019-06-27 07:05:20

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems

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 <[email protected]>

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


Attachments:
(No filename) (4.03 kB)
.config.gz (32.19 kB)
Download all attachments

2019-06-27 09:02:48

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems

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 <[email protected]>

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


Attachments:
(No filename) (1.77 kB)
.config.gz (27.80 kB)
Download all attachments

2019-06-29 17:53:29

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems

From: Bj?rn T?pel <[email protected]>
Date: Wed, 26 Jun 2019 22:50:23 +0200

> On Wed, 26 Jun 2019 at 17:59, Ivan Khoronzhuk
> <[email protected]> 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 <[email protected]>

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

Thanks.

2019-07-01 13:11:15

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH net-next] xdp: xdp_umem: fix umem pages mapping for 32bits systems

On Sat, 29 Jun 2019 at 19:53, David Miller <[email protected]> wrote:
>
> From: Björn Töpel <[email protected]>
> Date: Wed, 26 Jun 2019 22:50:23 +0200
>
> > On Wed, 26 Jun 2019 at 17:59, Ivan Khoronzhuk
> > <[email protected]> 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 <[email protected]>
>
> 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