bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags
@ 2019-11-23 22:08 Andrii Nakryiko
  2019-11-25 14:30 ` Johannes Weiner
  2019-11-25 20:36 ` John Fastabend
  0 siblings, 2 replies; 6+ messages in thread
From: Andrii Nakryiko @ 2019-11-23 22:08 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel
  Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko, Johannes Weiner

To fix build with !CONFIG_MMU, implement it for no-MMU configurations as well.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 mm/nommu.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/mm/nommu.c b/mm/nommu.c
index 99b7ec318824..7de592058ab4 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -155,11 +155,11 @@ void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags)
 	return __vmalloc(size, flags, PAGE_KERNEL);
 }
 
-void *vmalloc_user(unsigned long size)
+static void *__vmalloc_user_flags(unsigned long size, gfp_t flags)
 {
 	void *ret;
 
-	ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
+	ret = __vmalloc(size, flags, PAGE_KERNEL);
 	if (ret) {
 		struct vm_area_struct *vma;
 
@@ -172,8 +172,19 @@ void *vmalloc_user(unsigned long size)
 
 	return ret;
 }
+
+void *vmalloc_user(unsigned long size)
+{
+	return __vmalloc_user_flags(size, GFP_KERNEL | __GFP_ZERO);
+}
 EXPORT_SYMBOL(vmalloc_user);
 
+void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
+{
+	return __vmalloc_user_flags(size, flags | __GFP_ZERO);
+}
+EXPORT_SYMBOL(vmalloc_user_node_flags);
+
 struct page *vmalloc_to_page(const void *addr)
 {
 	return virt_to_page(addr);
-- 
2.17.1


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

* Re: [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags
  2019-11-23 22:08 [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags Andrii Nakryiko
@ 2019-11-25 14:30 ` Johannes Weiner
  2019-11-25 20:36 ` John Fastabend
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Weiner @ 2019-11-25 14:30 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, netdev, ast, daniel, andrii.nakryiko, kernel-team

On Sat, Nov 23, 2019 at 02:08:35PM -0800, Andrii Nakryiko wrote:
> To fix build with !CONFIG_MMU, implement it for no-MMU configurations as well.
> 
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

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

* RE: [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags
  2019-11-23 22:08 [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags Andrii Nakryiko
  2019-11-25 14:30 ` Johannes Weiner
@ 2019-11-25 20:36 ` John Fastabend
  2019-11-25 20:38   ` Andrii Nakryiko
  1 sibling, 1 reply; 6+ messages in thread
From: John Fastabend @ 2019-11-25 20:36 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf, netdev, ast, daniel
  Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko, Johannes Weiner

Andrii Nakryiko wrote:
> To fix build with !CONFIG_MMU, implement it for no-MMU configurations as well.
> 
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
>  mm/nommu.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 99b7ec318824..7de592058ab4 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -155,11 +155,11 @@ void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags)
>  	return __vmalloc(size, flags, PAGE_KERNEL);
>  }
>  
> -void *vmalloc_user(unsigned long size)
> +static void *__vmalloc_user_flags(unsigned long size, gfp_t flags)
>  {
>  	void *ret;
>  
> -	ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
> +	ret = __vmalloc(size, flags, PAGE_KERNEL);
>  	if (ret) {
>  		struct vm_area_struct *vma;
>  
> @@ -172,8 +172,19 @@ void *vmalloc_user(unsigned long size)
>  
>  	return ret;
>  }
> +
> +void *vmalloc_user(unsigned long size)
> +{
> +	return __vmalloc_user_flags(size, GFP_KERNEL | __GFP_ZERO);
> +}
>  EXPORT_SYMBOL(vmalloc_user);
>  
> +void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
> +{
> +	return __vmalloc_user_flags(size, flags | __GFP_ZERO);
> +}
> +EXPORT_SYMBOL(vmalloc_user_node_flags);
> +

Hi Andrii, my first reaction was that it seemed not ideal to just ignore
the node value like this but everything I came up with was uglier. I
guess only user is BPF at the moment so it should be fine.

Acked-by: John Fastabend <john.fastabend@gmail.com>

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

* Re: [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags
  2019-11-25 20:36 ` John Fastabend
@ 2019-11-25 20:38   ` Andrii Nakryiko
  2019-11-25 20:50     ` John Fastabend
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Nakryiko @ 2019-11-25 20:38 UTC (permalink / raw)
  To: John Fastabend
  Cc: Andrii Nakryiko, bpf, Networking, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team, Johannes Weiner

On Mon, Nov 25, 2019 at 12:36 PM John Fastabend
<john.fastabend@gmail.com> wrote:
>
> Andrii Nakryiko wrote:
> > To fix build with !CONFIG_MMU, implement it for no-MMU configurations as well.
> >
> > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > ---
> >  mm/nommu.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/nommu.c b/mm/nommu.c
> > index 99b7ec318824..7de592058ab4 100644
> > --- a/mm/nommu.c
> > +++ b/mm/nommu.c
> > @@ -155,11 +155,11 @@ void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags)
> >       return __vmalloc(size, flags, PAGE_KERNEL);
> >  }
> >
> > -void *vmalloc_user(unsigned long size)
> > +static void *__vmalloc_user_flags(unsigned long size, gfp_t flags)
> >  {
> >       void *ret;
> >
> > -     ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
> > +     ret = __vmalloc(size, flags, PAGE_KERNEL);
> >       if (ret) {
> >               struct vm_area_struct *vma;
> >
> > @@ -172,8 +172,19 @@ void *vmalloc_user(unsigned long size)
> >
> >       return ret;
> >  }
> > +
> > +void *vmalloc_user(unsigned long size)
> > +{
> > +     return __vmalloc_user_flags(size, GFP_KERNEL | __GFP_ZERO);
> > +}
> >  EXPORT_SYMBOL(vmalloc_user);
> >
> > +void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
> > +{
> > +     return __vmalloc_user_flags(size, flags | __GFP_ZERO);
> > +}
> > +EXPORT_SYMBOL(vmalloc_user_node_flags);
> > +
>
> Hi Andrii, my first reaction was that it seemed not ideal to just ignore
> the node value like this but everything I came up with was uglier. I
> guess only user is BPF at the moment so it should be fine.

Yeah, but that's what other node-aware vmalloc() variants do in
nommu.c, so at least it's consistent with other cases. Thanks for
review!

>
> Acked-by: John Fastabend <john.fastabend@gmail.com>

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

* Re: [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags
  2019-11-25 20:38   ` Andrii Nakryiko
@ 2019-11-25 20:50     ` John Fastabend
  2019-11-25 21:52       ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: John Fastabend @ 2019-11-25 20:50 UTC (permalink / raw)
  To: Andrii Nakryiko, John Fastabend
  Cc: Andrii Nakryiko, bpf, Networking, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team, Johannes Weiner

Andrii Nakryiko wrote:
> On Mon, Nov 25, 2019 at 12:36 PM John Fastabend
> <john.fastabend@gmail.com> wrote:
> >
> > Andrii Nakryiko wrote:
> > > To fix build with !CONFIG_MMU, implement it for no-MMU configurations as well.
> > >
> > > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > > Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> > > Reported-by: kbuild test robot <lkp@intel.com>
> > > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > > ---
> > >  mm/nommu.c | 15 +++++++++++++--
> > >  1 file changed, 13 insertions(+), 2 deletions(-)
> > >

[...]

> > Hi Andrii, my first reaction was that it seemed not ideal to just ignore
> > the node value like this but everything I came up with was uglier. I
> > guess only user is BPF at the moment so it should be fine.
> 
> Yeah, but that's what other node-aware vmalloc() variants do in
> nommu.c, so at least it's consistent with other cases. Thanks for
> review!

Great, at least folks (not me) who are used to working with no-mmu APIs
will expect this then.

> 
> >
> > Acked-by: John Fastabend <john.fastabend@gmail.com>



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

* Re: [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags
  2019-11-25 20:50     ` John Fastabend
@ 2019-11-25 21:52       ` Alexei Starovoitov
  0 siblings, 0 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2019-11-25 21:52 UTC (permalink / raw)
  To: John Fastabend
  Cc: Andrii Nakryiko, Andrii Nakryiko, bpf, Networking,
	Alexei Starovoitov, Daniel Borkmann, Kernel Team,
	Johannes Weiner

On Mon, Nov 25, 2019 at 12:51 PM John Fastabend
<john.fastabend@gmail.com> wrote:
>
> Andrii Nakryiko wrote:
> > On Mon, Nov 25, 2019 at 12:36 PM John Fastabend
> > <john.fastabend@gmail.com> wrote:
> > >
> > > Andrii Nakryiko wrote:
> > > > To fix build with !CONFIG_MMU, implement it for no-MMU configurations as well.
> > > >
> > > > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > > > Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
> > > > Reported-by: kbuild test robot <lkp@intel.com>
> > > > Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Applied. Thanks

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

end of thread, other threads:[~2019-11-25 21:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-23 22:08 [PATCH bpf-next] mm: implement no-MMU variant of vmalloc_user_node_flags Andrii Nakryiko
2019-11-25 14:30 ` Johannes Weiner
2019-11-25 20:36 ` John Fastabend
2019-11-25 20:38   ` Andrii Nakryiko
2019-11-25 20:50     ` John Fastabend
2019-11-25 21:52       ` Alexei Starovoitov

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