* [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
@ 2025-07-16 0:43 Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 1/3] " Alviro Iskandar Setiawan
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-16 0:43 UTC (permalink / raw)
To: Jens Axboe
Cc: Alviro Iskandar Setiawan, Ammar Faizi, GNU/Weeb Mailing List,
Linux Kernel Mailing List, io-uring Mailing List
Hello,
This is the v2 revision of the patch series to address the Android
build error related to `memfd_create()`. The series consists of three
patches:
1) Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error.
Partially reverts commit:
732bf609b670 ("test/io_uring_register: kill old memfd test")
to bring back `CONFIG_HAVE_MEMFD_CREATE` to resolve Android build
failures caused by:
93d3a7a70b4a ("examples/zcrx: udmabuf backed areas")
It added a call to `memfd_create()`, which is unavailable on some
Android toolchains, leading to the following build error:
```
zcrx.c:111:10: error: call to undeclared function 'memfd_create'; ISO C99 and \
later do not support implicit function declarations \
[-Wimplicit-function-declaration]
111 | memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING);
| ^
```
This reversion is a preparation patch for a proper fix by ensuring
`memfd_create()` usage is guarded and portable. It's only a partial
revert because the test itself is not restored.
2) Move `memfd_create()` to helpers.c, make it accessible for all tests.
Previously, the static definition of `memfd_create()` was limited to
io_uring_register.c. Now, promote it to a shared location accessible
to all test cases, ensuring that future tests using `memfd_create()`
do not trigger build failures on Android targets where the syscall
is undefined in the standard headers. It improves portability and
prevents regressions across test builds.
3) Also, add `memfd_create()` helper in the examples directory.
Changelog:
v1 -> v2:
- Omit the old memfd test because it's not needed anymore (Jens Axboe)
Link: https://lore.kernel.org/io-uring/4bc75566-9cb5-42ec-a6b7-16e04062e0c6@kernel.dk
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
Alviro Iskandar Setiawan (3):
Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build errors
test: Move `memfd_create()` to helpers.c, make it accessible for all tests
examples: Add `memfd_create()` helper
configure | 19 +++++++++++++++++++
examples/helpers.c | 8 ++++++++
examples/helpers.h | 5 +++++
test/helpers.c | 8 ++++++++
test/helpers.h | 5 +++++
5 files changed, 45 insertions(+)
base-commit: 0272bfa96f02cc47c024ec510a764ef7e37b76bf
--
Alviro Iskandar Setiawan
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH liburing v2 1/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
2025-07-16 0:43 [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
@ 2025-07-16 0:44 ` Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests Alviro Iskandar Setiawan
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-16 0:44 UTC (permalink / raw)
To: Jens Axboe
Cc: Alviro Iskandar Setiawan, Ammar Faizi, GNU/Weeb Mailing List,
Linux Kernel Mailing List, io-uring Mailing List
This partially reverts commit:
732bf609b670 ("test/io_uring_register: kill old memfd test")
Bring back `CONFIG_HAVE_MEMFD_CREATE` to resolve Android build failures
caused by:
93d3a7a70b4a ("examples/zcrx: udmabuf backed areas")
It added a call to `memfd_create()`, which is unavailable on some
Android toolchains, leading to the following build error:
```
zcrx.c:111:10: error: call to undeclared function 'memfd_create'; ISO C99 and \
later do not support implicit function declarations \
[-Wimplicit-function-declaration]
111 | memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING);
| ^
```
This reversion is a preparation patch for a proper fix by ensuring
`memfd_create()` usage is guarded and portable. It's only a partial
revert because the test itself is not restored.
v1 -> v2:
- Omit the old memfd test because it's not needed anymore.
Link: https://lore.kernel.org/io-uring/4bc75566-9cb5-42ec-a6b7-16e04062e0c6@kernel.dk
Co-authored-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
configure | 19 +++++++++++++++++++
test/io_uring_register.c | 11 +++++++++++
2 files changed, 30 insertions(+)
diff --git a/configure b/configure
index 552f8ae..3c95214 100755
--- a/configure
+++ b/configure
@@ -379,6 +379,22 @@ if compile_prog "" "" "has_ucontext"; then
fi
print_config "has_ucontext" "$has_ucontext"
+##########################################
+# check for memfd_create(2)
+has_memfd_create="no"
+cat > $TMPC << EOF
+#include <sys/mman.h>
+int main(int argc, char **argv)
+{
+ int memfd = memfd_create("test", 0);
+ return 0;
+}
+EOF
+if compile_prog "-Werror=implicit-function-declaration" "" "has_memfd_create"; then
+ has_memfd_create="yes"
+fi
+print_config "has_memfd_create" "$has_memfd_create"
+
##########################################
# Check NVME_URING_CMD support
nvme_uring_cmd="no"
@@ -539,6 +555,9 @@ fi
if test "$array_bounds" = "yes"; then
output_sym "CONFIG_HAVE_ARRAY_BOUNDS"
fi
+if test "$has_memfd_create" = "yes"; then
+ output_sym "CONFIG_HAVE_MEMFD_CREATE"
+fi
if test "$nvme_uring_cmd" = "yes"; then
output_sym "CONFIG_HAVE_NVME_URING"
fi
diff --git a/test/io_uring_register.c b/test/io_uring_register.c
index b53a67d..405a812 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -32,6 +32,17 @@ static int pagesize;
static rlim_t mlock_limit;
static int devnull;
+#if !defined(CONFIG_HAVE_MEMFD_CREATE)
+#include <sys/syscall.h>
+#include <linux/memfd.h>
+
+int memfd_create(const char *name, unsigned int flags)
+{
+ return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
+
static int expect_fail(int fd, unsigned int opcode, void *arg,
unsigned int nr_args, int error, int error2)
{
--
Alviro Iskandar Setiawan
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH liburing v2 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests
2025-07-16 0:43 [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 1/3] " Alviro Iskandar Setiawan
@ 2025-07-16 0:44 ` Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 3/3] examples: Add `memfd_create()` helper Alviro Iskandar Setiawan
2025-07-16 12:41 ` [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Jens Axboe
3 siblings, 0 replies; 7+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-16 0:44 UTC (permalink / raw)
To: Jens Axboe
Cc: Alviro Iskandar Setiawan, Ammar Faizi, GNU/Weeb Mailing List,
Linux Kernel Mailing List, io-uring Mailing List
Previously, the static definition of `memfd_create()` was limited to
io_uring_register.c. Now, promote it to a shared location accessible
to all test cases, ensuring that future tests using `memfd_create()`
do not trigger build failures on Android targets where the syscall
is undefined in the standard headers. It improves portability and
prevents regressions across test builds.
Co-authored-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
test/helpers.c | 8 ++++++++
test/helpers.h | 5 +++++
test/io_uring_register.c | 11 -----------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/test/helpers.c b/test/helpers.c
index 0589548..f1d4477 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -18,6 +18,14 @@
#include "helpers.h"
#include "liburing.h"
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <sys/syscall.h>
+int memfd_create(const char *name, unsigned int flags)
+{
+ return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
/*
* Helper for allocating memory in tests.
*/
diff --git a/test/helpers.h b/test/helpers.h
index 3f0c11a..8ab0920 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -122,6 +122,11 @@ unsigned long long mtime_since_now(struct timeval *tv);
unsigned long long utime_since(const struct timeval *s, const struct timeval *e);
unsigned long long utime_since_now(struct timeval *tv);
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#endif
+int memfd_create(const char *name, unsigned int flags);
+
#ifdef __cplusplus
}
#endif
diff --git a/test/io_uring_register.c b/test/io_uring_register.c
index 405a812..b53a67d 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -32,17 +32,6 @@ static int pagesize;
static rlim_t mlock_limit;
static int devnull;
-#if !defined(CONFIG_HAVE_MEMFD_CREATE)
-#include <sys/syscall.h>
-#include <linux/memfd.h>
-
-int memfd_create(const char *name, unsigned int flags)
-{
- return (int)syscall(SYS_memfd_create, name, flags);
-}
-#endif
-
-
static int expect_fail(int fd, unsigned int opcode, void *arg,
unsigned int nr_args, int error, int error2)
{
--
Alviro Iskandar Setiawan
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH liburing v2 3/3] examples: Add `memfd_create()` helper
2025-07-16 0:43 [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 1/3] " Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests Alviro Iskandar Setiawan
@ 2025-07-16 0:44 ` Alviro Iskandar Setiawan
2025-07-16 12:41 ` [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Jens Axboe
3 siblings, 0 replies; 7+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-16 0:44 UTC (permalink / raw)
To: Jens Axboe
Cc: Alviro Iskandar Setiawan, Ammar Faizi, GNU/Weeb Mailing List,
Linux Kernel Mailing List, io-uring Mailing List
Add `memfd_create()` helper to handle missing defintion on an environment
where `CONFIG_HAVE_MEMFD_CREATE` is not defined.
Fixes: 93d3a7a70b4a ("examples/zcrx: udmabuf backed areas")
Co-authored-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
examples/helpers.c | 8 ++++++++
examples/helpers.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/examples/helpers.c b/examples/helpers.c
index 483ddee..8c112f1 100644
--- a/examples/helpers.c
+++ b/examples/helpers.c
@@ -13,6 +13,14 @@
#include "helpers.h"
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <sys/syscall.h>
+int memfd_create(const char *name, unsigned int flags)
+{
+ return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
int setup_listening_socket(int port, int ipv6)
{
struct sockaddr_in srv_addr = { };
diff --git a/examples/helpers.h b/examples/helpers.h
index 44543e1..0b6f15f 100644
--- a/examples/helpers.h
+++ b/examples/helpers.h
@@ -17,4 +17,9 @@ void *t_aligned_alloc(size_t alignment, size_t size);
void t_error(int status, int errnum, const char *format, ...);
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#endif
+int memfd_create(const char *name, unsigned int flags);
+
#endif
--
Alviro Iskandar Setiawan
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
2025-07-16 0:43 [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
` (2 preceding siblings ...)
2025-07-16 0:44 ` [PATCH liburing v2 3/3] examples: Add `memfd_create()` helper Alviro Iskandar Setiawan
@ 2025-07-16 12:41 ` Jens Axboe
2025-07-16 14:28 ` Alviro Iskandar Setiawan
3 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2025-07-16 12:41 UTC (permalink / raw)
To: Alviro Iskandar Setiawan
Cc: Ammar Faizi, GNU/Weeb Mailing List, Linux Kernel Mailing List,
io-uring Mailing List
On 7/15/25 6:43 PM, Alviro Iskandar Setiawan wrote:
> Hello,
>
> This is the v2 revision of the patch series to address the Android
> build error related to `memfd_create()`. The series consists of three
> patches:
Took a closer look at this. A few comments:
For patch 1, maybe just bring back the configure test and not bother
with a revert style commit? There is nothing in test/ that uses
memfd_create, so there's no point bringing it back in there.
IOW, patch 2 can be dropped, as it's really just dropping bits
that patch 1 re-added for some reason.
All that's needed is to add it to the examples/ helpers. If it's
needed for test/ later, then it can get added at that time.
All of that to say, I'd just add the configure bit and the examples/
helper in a single patch and not worry about test/ at all.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
2025-07-16 12:41 ` [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Jens Axboe
@ 2025-07-16 14:28 ` Alviro Iskandar Setiawan
2025-07-16 14:30 ` Jens Axboe
0 siblings, 1 reply; 7+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-16 14:28 UTC (permalink / raw)
To: Jens Axboe
Cc: Ammar Faizi, GNU/Weeb Mailing List, Linux Kernel Mailing List,
io-uring Mailing List
On Wed, Jul 16, 2025 at 7:41 PM Jens Axboe wrote:
> For patch 1, maybe just bring back the configure test and not bother
> with a revert style commit? There is nothing in test/ that uses
> memfd_create, so there's no point bringing it back in there.
Ah yea. That'd be easier. I'll copy the configure part instead of
modifying the git revert result 😆
> IOW, patch 2 can be dropped, as it's really just dropping bits
> that patch 1 re-added for some reason.
>
> All that's needed is to add it to the examples/ helpers. If it's
> needed for test/ later, then it can get added at that time.
>
> All of that to say, I'd just add the configure bit and the examples/
> helper in a single patch and not worry about test/ at all.
Understandable. I'll send a v3 revision shortly.
-- Viro
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
2025-07-16 14:28 ` Alviro Iskandar Setiawan
@ 2025-07-16 14:30 ` Jens Axboe
0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2025-07-16 14:30 UTC (permalink / raw)
To: Alviro Iskandar Setiawan
Cc: Ammar Faizi, GNU/Weeb Mailing List, Linux Kernel Mailing List,
io-uring Mailing List
On 7/16/25 8:28 AM, Alviro Iskandar Setiawan wrote:
> On Wed, Jul 16, 2025 at 7:41?PM Jens Axboe wrote:
>> For patch 1, maybe just bring back the configure test and not bother
>> with a revert style commit? There is nothing in test/ that uses
>> memfd_create, so there's no point bringing it back in there.
>
> Ah yea. That'd be easier. I'll copy the configure part instead of
> modifying the git revert result ?
Exactly, just make it that single patch.
>> IOW, patch 2 can be dropped, as it's really just dropping bits
>> that patch 1 re-added for some reason.
>>
>> All that's needed is to add it to the examples/ helpers. If it's
>> needed for test/ later, then it can get added at that time.
>>
>> All of that to say, I'd just add the configure bit and the examples/
>> helper in a single patch and not worry about test/ at all.
>
> Understandable. I'll send a v3 revision shortly.
Thanks!
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-16 14:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16 0:43 [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 1/3] " Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 3/3] examples: Add `memfd_create()` helper Alviro Iskandar Setiawan
2025-07-16 12:41 ` [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Jens Axboe
2025-07-16 14:28 ` Alviro Iskandar Setiawan
2025-07-16 14:30 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox