LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available
@ 2024-03-21 16:01 Arnaldo Carvalho de Melo
  2024-03-21 16:13 ` Andrii Nakryiko
  2024-03-21 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-03-21 16:01 UTC (permalink / raw
  To: Andrii Nakryiko, Daniel Borkmann
  Cc: bpf, Linux Kernel Mailing List, linux-perf-users

Since its going directly to the syscall to avoid not having
memfd_create() available in some systems, do the same for its
MFD_CLOEXEC flags, defining it if not available.

This fixes the build in those systems, noticed while building perf on a
set of build containers.

Fixes: 9fa5e1a180aa639f ("libbpf: Call memfd_create() syscall directly")
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/bpf/libbpf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index efab29b8935bd9f7..635a38c6f947a34d 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1650,6 +1650,10 @@ static int sys_memfd_create(const char *name, unsigned flags)
 	return syscall(__NR_memfd_create, name, flags);
 }
 
+#ifndef MFD_CLOEXEC
+#define MFD_CLOEXEC 0x0001U
+#endif
+
 static int create_placeholder_fd(void)
 {
 	int fd;
-- 
2.44.0


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

* Re: [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available
  2024-03-21 16:01 [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available Arnaldo Carvalho de Melo
@ 2024-03-21 16:13 ` Andrii Nakryiko
  2024-03-21 16:16   ` Arnaldo Carvalho de Melo
  2024-03-21 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2024-03-21 16:13 UTC (permalink / raw
  To: Arnaldo Carvalho de Melo
  Cc: Andrii Nakryiko, Daniel Borkmann, bpf, Linux Kernel Mailing List,
	linux-perf-users

On Thu, Mar 21, 2024 at 9:02 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Since its going directly to the syscall to avoid not having
> memfd_create() available in some systems, do the same for its
> MFD_CLOEXEC flags, defining it if not available.
>
> This fixes the build in those systems, noticed while building perf on a
> set of build containers.
>
> Fixes: 9fa5e1a180aa639f ("libbpf: Call memfd_create() syscall directly")
> Cc: Andrii Nakryiko <andrii@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/lib/bpf/libbpf.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index efab29b8935bd9f7..635a38c6f947a34d 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -1650,6 +1650,10 @@ static int sys_memfd_create(const char *name, unsigned flags)
>         return syscall(__NR_memfd_create, name, flags);
>  }
>
> +#ifndef MFD_CLOEXEC
> +#define MFD_CLOEXEC 0x0001U
> +#endif
> +

makes sense, and lgtm. Do you need it in the bpf or bpf-next tree the
most? your patch header doesn't specify this


>  static int create_placeholder_fd(void)
>  {
>         int fd;
> --
> 2.44.0
>

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

* Re: [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available
  2024-03-21 16:13 ` Andrii Nakryiko
@ 2024-03-21 16:16   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-03-21 16:16 UTC (permalink / raw
  To: Andrii Nakryiko
  Cc: Andrii Nakryiko, Daniel Borkmann, bpf, Linux Kernel Mailing List,
	linux-perf-users

On Thu, Mar 21, 2024 at 09:13:35AM -0700, Andrii Nakryiko wrote:
> On Thu, Mar 21, 2024 at 9:02 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Since its going directly to the syscall to avoid not having
> > memfd_create() available in some systems, do the same for its
> > MFD_CLOEXEC flags, defining it if not available.
> >
> > This fixes the build in those systems, noticed while building perf on a
> > set of build containers.
> >
> > Fixes: 9fa5e1a180aa639f ("libbpf: Call memfd_create() syscall directly")
> > Cc: Andrii Nakryiko <andrii@kernel.org>
> > Cc: Daniel Borkmann <daniel@iogearbox.net>
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > ---
> >  tools/lib/bpf/libbpf.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index efab29b8935bd9f7..635a38c6f947a34d 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -1650,6 +1650,10 @@ static int sys_memfd_create(const char *name, unsigned flags)
> >         return syscall(__NR_memfd_create, name, flags);
> >  }
> >
> > +#ifndef MFD_CLOEXEC
> > +#define MFD_CLOEXEC 0x0001U
> > +#endif
> > +
> 
> makes sense, and lgtm. Do you need it in the bpf or bpf-next tree the
> most? your patch header doesn't specify this

Modern distros don't have this problem, so its not urgent, if bpf-next
is more convenient for you, so be it.

- Arnaldo
 
> 
> >  static int create_placeholder_fd(void)
> >  {
> >         int fd;
> > --
> > 2.44.0
> >

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

* Re: [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available
  2024-03-21 16:01 [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available Arnaldo Carvalho de Melo
  2024-03-21 16:13 ` Andrii Nakryiko
@ 2024-03-21 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-21 18:50 UTC (permalink / raw
  To: Arnaldo Carvalho de Melo
  Cc: andrii, daniel, bpf, linux-kernel, linux-perf-users

Hello:

This patch was applied to bpf/bpf.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Thu, 21 Mar 2024 13:01:58 -0300 you wrote:
> Since its going directly to the syscall to avoid not having
> memfd_create() available in some systems, do the same for its
> MFD_CLOEXEC flags, defining it if not available.
> 
> This fixes the build in those systems, noticed while building perf on a
> set of build containers.
> 
> [...]

Here is the summary with links:
  - [1/1] libbpf: Define MFD_CLOEXEC if not available
    https://git.kernel.org/bpf/bpf/c/ddb2ffdc474a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-03-21 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 16:01 [PATCH 1/1] libbpf: Define MFD_CLOEXEC if not available Arnaldo Carvalho de Melo
2024-03-21 16:13 ` Andrii Nakryiko
2024-03-21 16:16   ` Arnaldo Carvalho de Melo
2024-03-21 18:50 ` patchwork-bot+netdevbpf

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 read-only IMAP folder(s) and NNTP newsgroup(s).