* [PATCH v3 0/2] nolibc: Add fallocate()
@ 2026-04-30 16:41 Daniel Palmer
2026-04-30 16:41 ` [PATCH v3 1/2] tools/nolibc: fcntl: " Daniel Palmer
` (3 more replies)
0 siblings, 4 replies; 17+ messages in thread
From: Daniel Palmer @ 2026-04-30 16:41 UTC (permalink / raw)
To: w, linux; +Cc: linux-kernel, Daniel Palmer
While poking around with my "static PIE for nommu" series I found
I needed fallocate(). Implementing it turned out a bit more
interesting than I thought it would be due to how the offset and
size need to be passed on 32bit machines.
v3:
- Reworked the test a bit, ran it on all the targets I could get
to run (s390, loongarch and sh currently don't work for me).
sparc32 doesn't seem to support fallocate() so made it skip
the test.
- Rebase on nolibc/for-next with the large file support bits.
v2:
- Addressed Thomas' comments
- Trial and error'd a test for the arguments being passed correctly.
Hopefully someone smarter than I am can tell if it actually works.
Daniel Palmer (2):
tools/nolibc: fcntl: Add fallocate()
selftests/nolibc: Add a very basic test for fallocate()
tools/include/nolibc/arch-mips.h | 11 ++++
tools/include/nolibc/fcntl.h | 33 ++++++++++
tools/include/nolibc/sys.h | 8 +++
tools/testing/selftests/nolibc/nolibc-test.c | 69 ++++++++++++++++++++
4 files changed, 121 insertions(+)
--
2.53.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/2] tools/nolibc: fcntl: Add fallocate()
2026-04-30 16:41 [PATCH v3 0/2] nolibc: Add fallocate() Daniel Palmer
@ 2026-04-30 16:41 ` Daniel Palmer
2026-05-01 8:18 ` David Laight
2026-04-30 16:41 ` [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
` (2 subsequent siblings)
3 siblings, 1 reply; 17+ messages in thread
From: Daniel Palmer @ 2026-04-30 16:41 UTC (permalink / raw)
To: w, linux; +Cc: linux-kernel, Daniel Palmer
Add fallocate().
Some special care is needed to put the offset and size
into the syscall parameters for 32bit machines, x32,
and mipsn32.
For x32 we can just check if the kernel long size is the
same as off_t and use the same path as x86_64.
For mipsn32 we override the generic version and provide
one that does the right thing.
Signed-off-by: Daniel Palmer <daniel@thingy.jp>
---
tools/include/nolibc/arch-mips.h | 11 +++++++++++
tools/include/nolibc/fcntl.h | 33 ++++++++++++++++++++++++++++++++
tools/include/nolibc/sys.h | 8 ++++++++
3 files changed, 52 insertions(+)
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 1400653c76c1..e4e42f2bcaf4 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -6,6 +6,7 @@
#ifndef _NOLIBC_ARCH_MIPS_H
#define _NOLIBC_ARCH_MIPS_H
+#include <linux/unistd.h>
#include "compiler.h"
#include "crt.h"
@@ -256,6 +257,16 @@
_arg4 ? -_num : _num; \
})
+/* The generic version of this will split offset and size for _ABIN32,
+ * override it and do the right thing here.
+ */
+static __attribute__((unused))
+int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
+{
+ return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
+}
+#define _sys_fallocate _sys_fallocate
+
#endif /* _ABIO32 */
#ifndef NOLIBC_NO_RUNTIME
diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h
index 014910a8e928..dbc99188a49e 100644
--- a/tools/include/nolibc/fcntl.h
+++ b/tools/include/nolibc/fcntl.h
@@ -14,6 +14,9 @@
#include "types.h"
#include "sys.h"
+/* For fallocate() modes */
+#include <linux/falloc.h>
+
/*
* int openat(int dirfd, const char *path, int flags[, mode_t mode]);
*/
@@ -80,4 +83,34 @@ int creat(const char *path, mode_t mode)
return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode);
}
+/*
+ * int fallocate(int fd, int mode, off_t offset, off_t size);
+ */
+
+#if !defined(_sys_fallocate)
+static __attribute__((unused))
+int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
+{
+ /*
+ * For 32 bit machines __kernel_long_t will be 4, off_t will be 8
+ * and we need to split offset and size, for 64 machines we can use
+ * the values as-is.
+ */
+ const bool offsetsz_two_args = sizeof(__kernel_long_t) != sizeof(off_t);
+
+ if (offsetsz_two_args)
+ return __nolibc_syscall6(__NR_fallocate, fd, mode,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1),
+ __NOLIBC_LLARGPART(size, 0), __NOLIBC_LLARGPART(size, 1));
+ else
+ return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
+}
+#endif
+
+static __attribute__((unused))
+int fallocate(int fd, int mode, off_t offset, off_t size)
+{
+ return __sysret(_sys_fallocate(fd, mode, offset, size));
+}
+
#endif /* _NOLIBC_FCNTL_H */
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 33f9c970ae57..b7136a3a7d6a 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -29,6 +29,14 @@
#include "stdarg.h"
#include "types.h"
+/*
+ * Helper for 32bit machines where a 64bit syscall arg needs to be split into
+ * two 32bit parts while making sure the order of the low/high parts are correct
+ * for the endian:
+ * __NOLIBC_LLARGPART(x, 0), __NOLIBC_LLARGPART(x, 1)
+ */
+#define __NOLIBC_LLARGPART(_arg, _part) \
+ (((union { long long ll; long l[2]; }) { .ll = _arg }).l[_part])
/* Syscall return helper: takes the syscall value in argument and checks for an
* error in it. This may only be used with signed returns (int or long), but
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate()
2026-04-30 16:41 [PATCH v3 0/2] nolibc: Add fallocate() Daniel Palmer
2026-04-30 16:41 ` [PATCH v3 1/2] tools/nolibc: fcntl: " Daniel Palmer
@ 2026-04-30 16:41 ` Daniel Palmer
2026-05-02 3:04 ` Willy Tarreau
2026-05-03 16:20 ` Thomas Weißschuh
2026-05-02 3:05 ` [PATCH v3 0/2] nolibc: Add fallocate() Willy Tarreau
2026-05-03 16:21 ` Thomas Weißschuh
3 siblings, 2 replies; 17+ messages in thread
From: Daniel Palmer @ 2026-04-30 16:41 UTC (permalink / raw)
To: w, linux; +Cc: linux-kernel, Daniel Palmer
1: Create a tmp file, fallocate() to make it a bit bigger, check the
size is what was expected.
2: Try to fallocate() (1 << 20), this should work.
3: Try to fallocate() (1 << 52), this should cause ENOSPC or EFBIG.
2 and 3 are basically to make sure if the offset or size are split
into a pair of registers for the syscall that we are passing them
the correct way around.
sparc32 seems to return EOPNOTSUPP for fallocate() so skip the
test there.
Signed-off-by: Daniel Palmer <daniel@thingy.jp>
---
tools/testing/selftests/nolibc/nolibc-test.c | 69 ++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 08610cacf030..a586e9d9ede2 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -89,6 +89,14 @@ static const int is_glibc =
#endif
;
+static const int is_sparc32 =
+#if defined(__sparc__) && !defined(__arch64__)
+ 1
+#else
+ 0
+#endif
+;
+
#if !defined(NOLIBC)
/* Some disabled tests may not compile. */
@@ -898,6 +906,66 @@ int test_getpagesize(void)
return !c;
}
+int test_fallocate(void)
+{
+ struct stat st;
+ int fd, r;
+
+ /* Create a new tmp file */
+ fd = open("/tmp", O_TMPFILE | O_RDWR, 0644);
+ if (fd == -1)
+ return -1;
+
+ /* Expand it to 42 bytes */
+ r = fallocate(fd, 0, 0, 42);
+ if (r)
+ goto close_tmpfile;
+
+ /* Get the new stat */
+ r = fstat(fd, &st);
+ if (r)
+ goto close_tmpfile;
+
+ /* It should be 42 bytes long */
+ if (st.st_size != 42) {
+ r = -1;
+ goto close_tmpfile;
+ }
+
+ /* Now try to allocate 1MiB. This puts a single bit
+ * into one of the registers if the size is split into
+ * two registers. This shouldn't fail if the bit is in
+ * the correct register.
+ */
+ r = fallocate(fd, 0, 0, (1ll << 20));
+ if (r)
+ goto close_tmpfile;
+
+ /* Check a massive size that puts a single bit into
+ * the other register if splitting.
+ * This should return an error and errno = ENOSPC or
+ * EFBIG indicating the value was passed correctly but it
+ * was rejected.
+ */
+ r = fallocate(fd, 0, 0, (1ll << (20 + 32)));
+ if (r != -1) {
+ r = -1;
+ goto close_tmpfile;
+ }
+ if (errno != ENOSPC && errno != EFBIG) {
+ r = -1;
+ goto close_tmpfile;
+ }
+
+ /* Test passed */
+ r = 0;
+
+close_tmpfile:
+ close(fd);
+
+ return r;
+}
+
int test_file_stream(void)
{
FILE *f;
@@ -1507,6 +1575,7 @@ int run_syscall(int min, int max)
CASE_TEST(dup3_0); tmp = dup3(0, 100, 0); EXPECT_SYSNE(1, tmp, -1); close(tmp); break;
CASE_TEST(dup3_m1); tmp = dup3(-1, 100, 0); EXPECT_SYSER(1, tmp, -1, EBADF); if (tmp != -1) close(tmp); break;
CASE_TEST(execve_root); EXPECT_SYSER(1, execve("/", (char*[]){ [0] = "/", [1] = NULL }, NULL), -1, EACCES); break;
+ CASE_TEST(fallocate); EXPECT_SYSZR(!is_sparc32, test_fallocate()); break;
CASE_TEST(fchdir_stdin); EXPECT_SYSER(1, fchdir(STDIN_FILENO), -1, ENOTDIR); break;
CASE_TEST(fchdir_badfd); EXPECT_SYSER(1, fchdir(-1), -1, EBADF); break;
CASE_TEST(file_stream); EXPECT_SYSZR(1, test_file_stream()); break;
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] tools/nolibc: fcntl: Add fallocate()
2026-04-30 16:41 ` [PATCH v3 1/2] tools/nolibc: fcntl: " Daniel Palmer
@ 2026-05-01 8:18 ` David Laight
2026-05-02 3:00 ` Willy Tarreau
0 siblings, 1 reply; 17+ messages in thread
From: David Laight @ 2026-05-01 8:18 UTC (permalink / raw)
To: Daniel Palmer; +Cc: w, linux, linux-kernel
On Fri, 1 May 2026 01:41:24 +0900
Daniel Palmer <daniel@thingy.jp> wrote:
> Add fallocate().
>
> Some special care is needed to put the offset and size
> into the syscall parameters for 32bit machines, x32,
> and mipsn32.
>
> For x32 we can just check if the kernel long size is the
> same as off_t and use the same path as x86_64.
>
> For mipsn32 we override the generic version and provide
> one that does the right thing.
>
> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
> tools/include/nolibc/arch-mips.h | 11 +++++++++++
> tools/include/nolibc/fcntl.h | 33 ++++++++++++++++++++++++++++++++
> tools/include/nolibc/sys.h | 8 ++++++++
> 3 files changed, 52 insertions(+)
>
> diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
> index 1400653c76c1..e4e42f2bcaf4 100644
> --- a/tools/include/nolibc/arch-mips.h
> +++ b/tools/include/nolibc/arch-mips.h
> @@ -6,6 +6,7 @@
>
> #ifndef _NOLIBC_ARCH_MIPS_H
> #define _NOLIBC_ARCH_MIPS_H
> +#include <linux/unistd.h>
>
> #include "compiler.h"
> #include "crt.h"
> @@ -256,6 +257,16 @@
> _arg4 ? -_num : _num; \
> })
>
> +/* The generic version of this will split offset and size for _ABIN32,
> + * override it and do the right thing here.
> + */
> +static __attribute__((unused))
> +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> +{
> + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> +}
> +#define _sys_fallocate _sys_fallocate
> +
> #endif /* _ABIO32 */
>
> #ifndef NOLIBC_NO_RUNTIME
> diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h
> index 014910a8e928..dbc99188a49e 100644
> --- a/tools/include/nolibc/fcntl.h
> +++ b/tools/include/nolibc/fcntl.h
> @@ -14,6 +14,9 @@
> #include "types.h"
> #include "sys.h"
>
> +/* For fallocate() modes */
> +#include <linux/falloc.h>
> +
> /*
> * int openat(int dirfd, const char *path, int flags[, mode_t mode]);
> */
> @@ -80,4 +83,34 @@ int creat(const char *path, mode_t mode)
> return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode);
> }
>
> +/*
> + * int fallocate(int fd, int mode, off_t offset, off_t size);
> + */
> +
> +#if !defined(_sys_fallocate)
> +static __attribute__((unused))
> +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> +{
> + /*
> + * For 32 bit machines __kernel_long_t will be 4, off_t will be 8
> + * and we need to split offset and size, for 64 machines we can use
> + * the values as-is.
> + */
> + const bool offsetsz_two_args = sizeof(__kernel_long_t) != sizeof(off_t);
I don't think you care about the size of off_t.
Were it to be 4 the code would be badly wrong.
> +
> + if (offsetsz_two_args)
> + return __nolibc_syscall6(__NR_fallocate, fd, mode,
> + __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1),
> + __NOLIBC_LLARGPART(size, 0), __NOLIBC_LLARGPART(size, 1));
> + else
> + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> +}
The above might be more readable as:
if (sizeof(__kernel_long_t) == 8)
/* 64 bit, values fit in single arguments */
return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
/* 32 bit, values need splitting, order depends on endianness */
/* This test for endianness doesn't rely on any pre-processor defines */
if (({union {int x; char c;} u; u.x = 1; u.c;}))
/* Little endian */
return __nolibc_syscall6(__NR_fallocate, fd, mode,
offset, offset >> 32, size, size >> 32);
/* Big endian */
return __nolibc_syscall6(__NR_fallocate, fd, mode,
offset >> 32, offset, size >> 32, size);
Although you might want to change/factor out the endianness test.
-- David
> +#endif
> +
> +static __attribute__((unused))
> +int fallocate(int fd, int mode, off_t offset, off_t size)
> +{
> + return __sysret(_sys_fallocate(fd, mode, offset, size));
> +}
> +
> #endif /* _NOLIBC_FCNTL_H */
> diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> index 33f9c970ae57..b7136a3a7d6a 100644
> --- a/tools/include/nolibc/sys.h
> +++ b/tools/include/nolibc/sys.h
> @@ -29,6 +29,14 @@
> #include "stdarg.h"
> #include "types.h"
>
> +/*
> + * Helper for 32bit machines where a 64bit syscall arg needs to be split into
> + * two 32bit parts while making sure the order of the low/high parts are correct
> + * for the endian:
> + * __NOLIBC_LLARGPART(x, 0), __NOLIBC_LLARGPART(x, 1)
> + */
> +#define __NOLIBC_LLARGPART(_arg, _part) \
> + (((union { long long ll; long l[2]; }) { .ll = _arg }).l[_part])
>
> /* Syscall return helper: takes the syscall value in argument and checks for an
> * error in it. This may only be used with signed returns (int or long), but
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] tools/nolibc: fcntl: Add fallocate()
2026-05-01 8:18 ` David Laight
@ 2026-05-02 3:00 ` Willy Tarreau
2026-05-02 21:26 ` David Laight
0 siblings, 1 reply; 17+ messages in thread
From: Willy Tarreau @ 2026-05-02 3:00 UTC (permalink / raw)
To: David Laight; +Cc: Daniel Palmer, linux, linux-kernel
On Fri, May 01, 2026 at 09:18:31AM +0100, David Laight wrote:
> On Fri, 1 May 2026 01:41:24 +0900
> Daniel Palmer <daniel@thingy.jp> wrote:
>
> > Add fallocate().
> >
> > Some special care is needed to put the offset and size
> > into the syscall parameters for 32bit machines, x32,
> > and mipsn32.
> >
> > For x32 we can just check if the kernel long size is the
> > same as off_t and use the same path as x86_64.
> >
> > For mipsn32 we override the generic version and provide
> > one that does the right thing.
> >
> > Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> > ---
> > tools/include/nolibc/arch-mips.h | 11 +++++++++++
> > tools/include/nolibc/fcntl.h | 33 ++++++++++++++++++++++++++++++++
> > tools/include/nolibc/sys.h | 8 ++++++++
> > 3 files changed, 52 insertions(+)
> >
> > diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
> > index 1400653c76c1..e4e42f2bcaf4 100644
> > --- a/tools/include/nolibc/arch-mips.h
> > +++ b/tools/include/nolibc/arch-mips.h
> > @@ -6,6 +6,7 @@
> >
> > #ifndef _NOLIBC_ARCH_MIPS_H
> > #define _NOLIBC_ARCH_MIPS_H
> > +#include <linux/unistd.h>
> >
> > #include "compiler.h"
> > #include "crt.h"
> > @@ -256,6 +257,16 @@
> > _arg4 ? -_num : _num; \
> > })
> >
> > +/* The generic version of this will split offset and size for _ABIN32,
> > + * override it and do the right thing here.
> > + */
> > +static __attribute__((unused))
> > +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> > +{
> > + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> > +}
> > +#define _sys_fallocate _sys_fallocate
> > +
> > #endif /* _ABIO32 */
> >
> > #ifndef NOLIBC_NO_RUNTIME
> > diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h
> > index 014910a8e928..dbc99188a49e 100644
> > --- a/tools/include/nolibc/fcntl.h
> > +++ b/tools/include/nolibc/fcntl.h
> > @@ -14,6 +14,9 @@
> > #include "types.h"
> > #include "sys.h"
> >
> > +/* For fallocate() modes */
> > +#include <linux/falloc.h>
> > +
> > /*
> > * int openat(int dirfd, const char *path, int flags[, mode_t mode]);
> > */
> > @@ -80,4 +83,34 @@ int creat(const char *path, mode_t mode)
> > return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode);
> > }
> >
> > +/*
> > + * int fallocate(int fd, int mode, off_t offset, off_t size);
> > + */
> > +
> > +#if !defined(_sys_fallocate)
> > +static __attribute__((unused))
> > +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> > +{
> > + /*
> > + * For 32 bit machines __kernel_long_t will be 4, off_t will be 8
> > + * and we need to split offset and size, for 64 machines we can use
> > + * the values as-is.
> > + */
> > + const bool offsetsz_two_args = sizeof(__kernel_long_t) != sizeof(off_t);
>
> I don't think you care about the size of off_t.
> Were it to be 4 the code would be badly wrong.
>
> > +
> > + if (offsetsz_two_args)
> > + return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > + __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1),
> > + __NOLIBC_LLARGPART(size, 0), __NOLIBC_LLARGPART(size, 1));
> > + else
> > + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> > +}
>
> The above might be more readable as:
> if (sizeof(__kernel_long_t) == 8)
> /* 64 bit, values fit in single arguments */
> return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
>
> /* 32 bit, values need splitting, order depends on endianness */
> /* This test for endianness doesn't rely on any pre-processor defines */
> if (({union {int x; char c;} u; u.x = 1; u.c;}))
> /* Little endian */
> return __nolibc_syscall6(__NR_fallocate, fd, mode,
> offset, offset >> 32, size, size >> 32);
> /* Big endian */
> return __nolibc_syscall6(__NR_fallocate, fd, mode,
> offset >> 32, offset, size >> 32, size);
Honestly David, I find Daniel's version way more readable :-) Precisely
because the repeated variations are abstracted with this more readable
macro. If it was used only once I could possibly agree. Even the
endianness test is hard to read, better rely on __BYTE_ORDER__ for
this.
Cheers,
Willy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate()
2026-04-30 16:41 ` [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
@ 2026-05-02 3:04 ` Willy Tarreau
2026-05-02 4:00 ` Daniel Palmer
2026-05-03 16:20 ` Thomas Weißschuh
1 sibling, 1 reply; 17+ messages in thread
From: Willy Tarreau @ 2026-05-02 3:04 UTC (permalink / raw)
To: Daniel Palmer; +Cc: linux, linux-kernel
On Fri, May 01, 2026 at 01:41:25AM +0900, Daniel Palmer wrote:
> 1: Create a tmp file, fallocate() to make it a bit bigger, check the
> size is what was expected.
>
> 2: Try to fallocate() (1 << 20), this should work.
>
> 3: Try to fallocate() (1 << 52), this should cause ENOSPC or EFBIG.
Note that I've already seen one place with more than 4PB on a shared
FS, so I don't know how long such a test could hold true without
causing a havoc. I understand the reason behind the +32 though, and
I'm not worried for the short-to-mid term.
Willy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/2] nolibc: Add fallocate()
2026-04-30 16:41 [PATCH v3 0/2] nolibc: Add fallocate() Daniel Palmer
2026-04-30 16:41 ` [PATCH v3 1/2] tools/nolibc: fcntl: " Daniel Palmer
2026-04-30 16:41 ` [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
@ 2026-05-02 3:05 ` Willy Tarreau
2026-05-03 16:21 ` Thomas Weißschuh
3 siblings, 0 replies; 17+ messages in thread
From: Willy Tarreau @ 2026-05-02 3:05 UTC (permalink / raw)
To: Daniel Palmer; +Cc: linux, linux-kernel
On Fri, May 01, 2026 at 01:41:23AM +0900, Daniel Palmer wrote:
> While poking around with my "static PIE for nommu" series I found
> I needed fallocate(). Implementing it turned out a bit more
> interesting than I thought it would be due to how the offset and
> size need to be passed on 32bit machines.
>
> v3:
> - Reworked the test a bit, ran it on all the targets I could get
> to run (s390, loongarch and sh currently don't work for me).
> sparc32 doesn't seem to support fallocate() so made it skip
> the test.
> - Rebase on nolibc/for-next with the large file support bits.
>
> v2:
> - Addressed Thomas' comments
> - Trial and error'd a test for the arguments being passed correctly.
> Hopefully someone smarter than I am can tell if it actually works.
The series looks good to me, I don't have any particular comment, but
let's wait for Thomas since he's been reviewing it from day one.
Acked-by: Willy Tarreau <w@1wt.eu>
Thanks,
Willy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate()
2026-05-02 3:04 ` Willy Tarreau
@ 2026-05-02 4:00 ` Daniel Palmer
2026-05-02 4:40 ` Willy Tarreau
0 siblings, 1 reply; 17+ messages in thread
From: Daniel Palmer @ 2026-05-02 4:00 UTC (permalink / raw)
To: Willy Tarreau; +Cc: linux, linux-kernel
Hi Willy,
On Sat, 2 May 2026 at 12:04, Willy Tarreau <w@1wt.eu> wrote:
> Note that I've already seen one place with more than 4PB on a shared
> FS, so I don't know how long such a test could hold true without
> causing a havoc. I understand the reason behind the +32 though, and
> I'm not worried for the short-to-mid term.
I think there is the assumption that the file is on tmpfs and since
tmpfs is in memory it can't be bigger that your system memory.
I think with current memory prices we might be ok for now? :)
Thanks,
Daniel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate()
2026-05-02 4:00 ` Daniel Palmer
@ 2026-05-02 4:40 ` Willy Tarreau
0 siblings, 0 replies; 17+ messages in thread
From: Willy Tarreau @ 2026-05-02 4:40 UTC (permalink / raw)
To: Daniel Palmer; +Cc: linux, linux-kernel
On Sat, May 02, 2026 at 01:00:27PM +0900, Daniel Palmer wrote:
> Hi Willy,
>
> On Sat, 2 May 2026 at 12:04, Willy Tarreau <w@1wt.eu> wrote:
> > Note that I've already seen one place with more than 4PB on a shared
> > FS, so I don't know how long such a test could hold true without
> > causing a havoc. I understand the reason behind the +32 though, and
> > I'm not worried for the short-to-mid term.
>
> I think there is the assumption that the file is on tmpfs and since
> tmpfs is in memory it can't be bigger that your system memory.
> I think with current memory prices we might be ok for now? :)
Agreed :-)
Willy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] tools/nolibc: fcntl: Add fallocate()
2026-05-02 3:00 ` Willy Tarreau
@ 2026-05-02 21:26 ` David Laight
2026-05-03 16:28 ` Thomas Weißschuh
0 siblings, 1 reply; 17+ messages in thread
From: David Laight @ 2026-05-02 21:26 UTC (permalink / raw)
To: Willy Tarreau; +Cc: Daniel Palmer, linux, linux-kernel
On Sat, 2 May 2026 05:00:06 +0200
Willy Tarreau <w@1wt.eu> wrote:
> On Fri, May 01, 2026 at 09:18:31AM +0100, David Laight wrote:
> > On Fri, 1 May 2026 01:41:24 +0900
> > Daniel Palmer <daniel@thingy.jp> wrote:
> >
> > > Add fallocate().
> > >
> > > Some special care is needed to put the offset and size
> > > into the syscall parameters for 32bit machines, x32,
> > > and mipsn32.
> > >
> > > For x32 we can just check if the kernel long size is the
> > > same as off_t and use the same path as x86_64.
> > >
> > > For mipsn32 we override the generic version and provide
> > > one that does the right thing.
> > >
> > > Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> > > ---
> > > tools/include/nolibc/arch-mips.h | 11 +++++++++++
> > > tools/include/nolibc/fcntl.h | 33 ++++++++++++++++++++++++++++++++
> > > tools/include/nolibc/sys.h | 8 ++++++++
> > > 3 files changed, 52 insertions(+)
> > >
> > > diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
> > > index 1400653c76c1..e4e42f2bcaf4 100644
> > > --- a/tools/include/nolibc/arch-mips.h
> > > +++ b/tools/include/nolibc/arch-mips.h
> > > @@ -6,6 +6,7 @@
> > >
> > > #ifndef _NOLIBC_ARCH_MIPS_H
> > > #define _NOLIBC_ARCH_MIPS_H
> > > +#include <linux/unistd.h>
> > >
> > > #include "compiler.h"
> > > #include "crt.h"
> > > @@ -256,6 +257,16 @@
> > > _arg4 ? -_num : _num; \
> > > })
> > >
> > > +/* The generic version of this will split offset and size for _ABIN32,
> > > + * override it and do the right thing here.
> > > + */
> > > +static __attribute__((unused))
> > > +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> > > +{
> > > + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> > > +}
> > > +#define _sys_fallocate _sys_fallocate
> > > +
> > > #endif /* _ABIO32 */
> > >
> > > #ifndef NOLIBC_NO_RUNTIME
> > > diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h
> > > index 014910a8e928..dbc99188a49e 100644
> > > --- a/tools/include/nolibc/fcntl.h
> > > +++ b/tools/include/nolibc/fcntl.h
> > > @@ -14,6 +14,9 @@
> > > #include "types.h"
> > > #include "sys.h"
> > >
> > > +/* For fallocate() modes */
> > > +#include <linux/falloc.h>
> > > +
> > > /*
> > > * int openat(int dirfd, const char *path, int flags[, mode_t mode]);
> > > */
> > > @@ -80,4 +83,34 @@ int creat(const char *path, mode_t mode)
> > > return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode);
> > > }
> > >
> > > +/*
> > > + * int fallocate(int fd, int mode, off_t offset, off_t size);
> > > + */
> > > +
> > > +#if !defined(_sys_fallocate)
> > > +static __attribute__((unused))
> > > +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> > > +{
> > > + /*
> > > + * For 32 bit machines __kernel_long_t will be 4, off_t will be 8
> > > + * and we need to split offset and size, for 64 machines we can use
> > > + * the values as-is.
> > > + */
> > > + const bool offsetsz_two_args = sizeof(__kernel_long_t) != sizeof(off_t);
> >
> > I don't think you care about the size of off_t.
> > Were it to be 4 the code would be badly wrong.
> >
> > > +
> > > + if (offsetsz_two_args)
> > > + return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > > + __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1),
> > > + __NOLIBC_LLARGPART(size, 0), __NOLIBC_LLARGPART(size, 1));
> > > + else
> > > + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> > > +}
> >
> > The above might be more readable as:
> > if (sizeof(__kernel_long_t) == 8)
> > /* 64 bit, values fit in single arguments */
> > return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> >
> > /* 32 bit, values need splitting, order depends on endianness */
> > /* This test for endianness doesn't rely on any pre-processor defines */
> > if (({union {int x; char c;} u; u.x = 1; u.c;}))
> > /* Little endian */
> > return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > offset, offset >> 32, size, size >> 32);
> > /* Big endian */
> > return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > offset >> 32, offset, size >> 32, size);
>
> Honestly David, I find Daniel's version way more readable :-) Precisely
> because the repeated variations are abstracted with this more readable
> macro. If it was used only once I could possibly agree. Even the
> endianness test is hard to read, better rely on __BYTE_ORDER__ for
> this.
I did say 'might' :-) and I should probably have used __BYTE_ORDER__.
Looking again, the code is trying to copy what the compiler generates
when it passes a 64bit quantity on stack or in 2 registers.
So f(a, b, c, d) is traditionally 'push d; push c; push b, push a; call f'.
With the normal 'stack grows down' this gives (in increasing addresses):
return address
a
b
c
d
If 'b,c' is replaced by a 64bit value then you want the stack memory
to contain the correct representation of a 64bit value.
So for LE you need to pass the low part before the high part.
But there is one architecture (parisc) where the stack goes the other way.
It is BE (I believe), but would need the LE argument order.
I think all the conditionals could be moved out of the fallocate code.
I'm not sure of the exact pre-processor conditionals but something like:
#if (__BITS_PER_LONG == 64) || defined(x86_x32) || defined(mips_n32)
#define __NOLIBC_ARG64(x) (x)
#else
/* The on-stack data has to be in the natural order for a 64bit value. */
#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN_) ^ defined(STACK_GROWS_UP)
#define __NOLIBC_ARG64(x) ((int)(x)), ((int)((long long)(x) >> 32))
#else
#define __NOLIBC_ARG64(x) ((int)((long long)(x) >> 32)), ((int)(x))
#endif
#endif
Then (if I've got it right):
static __attribute__((unused))
int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
{
return _syscall(__NR_fallocate, fd, mode, __NOLIBC_ARG64(offset),
__NOLIBC_ARG64(size));
}
There is the other problem that arm32 (and maybe others) requires the 64bit
variable be aligned in the stack frame.
So f(int a, long long b) is effectively f(int a, int pad, long long b).
(This usually causes grief with lseek().)
So a pad might be needed for some system calls on some 32bit architectures.
This could be done with something that expands to '' or '0,'.
David
>
> Cheers,
> Willy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate()
2026-04-30 16:41 ` [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
2026-05-02 3:04 ` Willy Tarreau
@ 2026-05-03 16:20 ` Thomas Weißschuh
1 sibling, 0 replies; 17+ messages in thread
From: Thomas Weißschuh @ 2026-05-03 16:20 UTC (permalink / raw)
To: Daniel Palmer; +Cc: w, linux-kernel
On 2026-05-01 01:41:25+0900, Daniel Palmer wrote:
> 1: Create a tmp file, fallocate() to make it a bit bigger, check the
> size is what was expected.
>
> 2: Try to fallocate() (1 << 20), this should work.
>
> 3: Try to fallocate() (1 << 52), this should cause ENOSPC or EFBIG.
>
> 2 and 3 are basically to make sure if the offset or size are split
> into a pair of registers for the syscall that we are passing them
> the correct way around.
>
> sparc32 seems to return EOPNOTSUPP for fallocate() so skip the
> test there.
This is because the kernel created in our testsuite does not enable
CONFIG_TMPFS, falling back to ramfs/rootfs for /tmp. We should
gracefully handle EOPNOTSUPP from fallocate() but also enable
CONFIG_TMPFS for our test kernels to increase the test coverage.
> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
> tools/testing/selftests/nolibc/nolibc-test.c | 69 ++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 08610cacf030..a586e9d9ede2 100644
(...)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/2] nolibc: Add fallocate()
2026-04-30 16:41 [PATCH v3 0/2] nolibc: Add fallocate() Daniel Palmer
` (2 preceding siblings ...)
2026-05-02 3:05 ` [PATCH v3 0/2] nolibc: Add fallocate() Willy Tarreau
@ 2026-05-03 16:21 ` Thomas Weißschuh
2026-05-04 1:46 ` Daniel Palmer
3 siblings, 1 reply; 17+ messages in thread
From: Thomas Weißschuh @ 2026-05-03 16:21 UTC (permalink / raw)
To: Daniel Palmer; +Cc: w, linux-kernel
On 2026-05-01 01:41:23+0900, Daniel Palmer wrote:
> While poking around with my "static PIE for nommu" series I found
> I needed fallocate(). Implementing it turned out a bit more
> interesting than I thought it would be due to how the offset and
> size need to be passed on 32bit machines.
>
> v3:
> - Reworked the test a bit, ran it on all the targets I could get
> to run (s390, loongarch and sh currently don't work for me).
Can you elaborate on what is broken?
> sparc32 doesn't seem to support fallocate() so made it skip
> the test.
> - Rebase on nolibc/for-next with the large file support bits.
(...)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] tools/nolibc: fcntl: Add fallocate()
2026-05-02 21:26 ` David Laight
@ 2026-05-03 16:28 ` Thomas Weißschuh
2026-05-03 22:38 ` David Laight
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Weißschuh @ 2026-05-03 16:28 UTC (permalink / raw)
To: David Laight; +Cc: Willy Tarreau, Daniel Palmer, linux-kernel
On 2026-05-02 22:26:07+0100, David Laight wrote:
> On Sat, 2 May 2026 05:00:06 +0200
> Willy Tarreau <w@1wt.eu> wrote:
>
> > On Fri, May 01, 2026 at 09:18:31AM +0100, David Laight wrote:
> > > On Fri, 1 May 2026 01:41:24 +0900
> > > Daniel Palmer <daniel@thingy.jp> wrote:
(...)
> > > > +/*
> > > > + * int fallocate(int fd, int mode, off_t offset, off_t size);
> > > > + */
> > > > +
> > > > +#if !defined(_sys_fallocate)
> > > > +static __attribute__((unused))
> > > > +int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> > > > +{
> > > > + /*
> > > > + * For 32 bit machines __kernel_long_t will be 4, off_t will be 8
> > > > + * and we need to split offset and size, for 64 machines we can use
> > > > + * the values as-is.
> > > > + */
> > > > + const bool offsetsz_two_args = sizeof(__kernel_long_t) != sizeof(off_t);
> > >
> > > I don't think you care about the size of off_t.
> > > Were it to be 4 the code would be badly wrong.
I agree here that sizeof(__kernel_long_t) != 8 would be clearer a bit.
Also the intermediate variable could go away.
> > >
> > > > +
> > > > + if (offsetsz_two_args)
> > > > + return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > > > + __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1),
> > > > + __NOLIBC_LLARGPART(size, 0), __NOLIBC_LLARGPART(size, 1));
> > > > + else
> > > > + return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> > > > +}
> > >
> > > The above might be more readable as:
> > > if (sizeof(__kernel_long_t) == 8)
> > > /* 64 bit, values fit in single arguments */
> > > return __nolibc_syscall4(__NR_fallocate, fd, mode, offset, size);
> > >
> > > /* 32 bit, values need splitting, order depends on endianness */
> > > /* This test for endianness doesn't rely on any pre-processor defines */
> > > if (({union {int x; char c;} u; u.x = 1; u.c;}))
> > > /* Little endian */
> > > return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > > offset, offset >> 32, size, size >> 32);
> > > /* Big endian */
> > > return __nolibc_syscall6(__NR_fallocate, fd, mode,
> > > offset >> 32, offset, size >> 32, size);
> >
> > Honestly David, I find Daniel's version way more readable :-) Precisely
> > because the repeated variations are abstracted with this more readable
> > macro. If it was used only once I could possibly agree. Even the
> > endianness test is hard to read, better rely on __BYTE_ORDER__ for
> > this.
Here I agree with Daniel and Willy, the original aproach looks cleaner.
> I did say 'might' :-) and I should probably have used __BYTE_ORDER__.
>
> Looking again, the code is trying to copy what the compiler generates
> when it passes a 64bit quantity on stack or in 2 registers.
> So f(a, b, c, d) is traditionally 'push d; push c; push b, push a; call f'.
> With the normal 'stack grows down' this gives (in increasing addresses):
> return address
> a
> b
> c
> d
> If 'b,c' is replaced by a 64bit value then you want the stack memory
> to contain the correct representation of a 64bit value.
> So for LE you need to pass the low part before the high part.
Most architectures should use registers and not the stack.
> But there is one architecture (parisc) where the stack goes the other way.
> It is BE (I believe), but would need the LE argument order.
>
> I think all the conditionals could be moved out of the fallocate code.
> I'm not sure of the exact pre-processor conditionals but something like:
>
> #if (__BITS_PER_LONG == 64) || defined(x86_x32) || defined(mips_n32)
> #define __NOLIBC_ARG64(x) (x)
> #else
> /* The on-stack data has to be in the natural order for a 64bit value. */
> #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN_) ^ defined(STACK_GROWS_UP)
> #define __NOLIBC_ARG64(x) ((int)(x)), ((int)((long long)(x) >> 32))
> #else
> #define __NOLIBC_ARG64(x) ((int)((long long)(x) >> 32)), ((int)(x))
> #endif
> #endif
I highly dislike macros like these which may expand to either a single
or multiple arguments. Also this logic looks much more complicated than
what Daniel proposed.
> Then (if I've got it right):
> static __attribute__((unused))
> int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> {
> return _syscall(__NR_fallocate, fd, mode, __NOLIBC_ARG64(offset),
> __NOLIBC_ARG64(size));
> }
We intentionally use __nolibc_syscallX() inside nolibc proper over
_syscall()/syscall() to have the arity of the syscall written out.
> There is the other problem that arm32 (and maybe others) requires the 64bit
> variable be aligned in the stack frame.
> So f(int a, long long b) is effectively f(int a, int pad, long long b).
> (This usually causes grief with lseek().)
> So a pad might be needed for some system calls on some 32bit architectures.
> This could be done with something that expands to '' or '0,'.
I don't see why we have to worry about variable alignment or stack
direction at all. That's the compilers job. We do have both lseek() and
parisc32 nowadays and both work fine. Also with Daniel's series on top.
Am I missing something?
Thomas
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] tools/nolibc: fcntl: Add fallocate()
2026-05-03 16:28 ` Thomas Weißschuh
@ 2026-05-03 22:38 ` David Laight
0 siblings, 0 replies; 17+ messages in thread
From: David Laight @ 2026-05-03 22:38 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Willy Tarreau, Daniel Palmer, linux-kernel
On Sun, 3 May 2026 18:28:39 +0200
Thomas Weißschuh <linux@weissschuh.net> wrote:
> On 2026-05-02 22:26:07+0100, David Laight wrote:
> > On Sat, 2 May 2026 05:00:06 +0200
> > Willy Tarreau <w@1wt.eu> wrote:
> >
> > > On Fri, May 01, 2026 at 09:18:31AM +0100, David Laight wrote:
> > > > On Fri, 1 May 2026 01:41:24 +0900
> > > > Daniel Palmer <daniel@thingy.jp> wrote:
>
> (...)
...
> > Looking again, the code is trying to copy what the compiler generates
> > when it passes a 64bit quantity on stack or in 2 registers.
> > So f(a, b, c, d) is traditionally 'push d; push c; push b, push a; call f'.
> > With the normal 'stack grows down' this gives (in increasing addresses):
> > return address
> > a
> > b
> > c
> > d
> > If 'b,c' is replaced by a 64bit value then you want the stack memory
> > to contain the correct representation of a 64bit value.
> > So for LE you need to pass the low part before the high part.
>
> Most architectures should use registers and not the stack.
Indeed, but the registers are picked as though they are caching on-stack locations.
So the way the stack would look is relevant.
>
> > But there is one architecture (parisc) where the stack goes the other way.
> > It is BE (I believe), but would need the LE argument order.
> >
> > I think all the conditionals could be moved out of the fallocate code.
> > I'm not sure of the exact pre-processor conditionals but something like:
> >
> > #if (__BITS_PER_LONG == 64) || defined(x86_x32) || defined(mips_n32)
> > #define __NOLIBC_ARG64(x) (x)
> > #else
> > /* The on-stack data has to be in the natural order for a 64bit value. */
> > #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN_) ^ defined(STACK_GROWS_UP)
> > #define __NOLIBC_ARG64(x) ((int)(x)), ((int)((long long)(x) >> 32))
> > #else
> > #define __NOLIBC_ARG64(x) ((int)((long long)(x) >> 32)), ((int)(x))
> > #endif
> > #endif
>
> I highly dislike macros like these which may expand to either a single
> or multiple arguments.
> Also this logic looks much more complicated than what Daniel proposed.
I'm not sure the casts are needed.
The implicit casts from the function calls may mean that it is enough
to use (x) and (x) >> 32.
I really didn't like the expansions Daniel proposed in sys_fallocate() itself.
Neither the fallocate code nor the header file really said what was going on.
You had to read both together and then read between the lines so see why
it was necessary at all.
> > Then (if I've got it right):
> > static __attribute__((unused))
> > int _sys_fallocate(int fd, int mode, off_t offset, off_t size)
> > {
> > return _syscall(__NR_fallocate, fd, mode, __NOLIBC_ARG64(offset),
> > __NOLIBC_ARG64(size));
> > }
>
> We intentionally use __nolibc_syscallX() inside nolibc proper over
> _syscall()/syscall() to have the arity of the syscall written out.
In this case the number of arguments varies - so that wouldn't work.
But I can see why it would normally be better.
>
> > There is the other problem that arm32 (and maybe others) requires the 64bit
> > variable be aligned in the stack frame.
> > So f(int a, long long b) is effectively f(int a, int pad, long long b).
> > (This usually causes grief with lseek().)
> > So a pad might be needed for some system calls on some 32bit architectures.
> > This could be done with something that expands to '' or '0,'.
>
> I don't see why we have to worry about variable alignment or stack
> direction at all. That's the compilers job.
Except you do because you are trying to match what the compiler would
generate for a 64bit argument by passing two 32bit values.
I'm pretty sure that the normal syscall interface just passes the registers
that contain arguments over from user space to kernel space and then calls
the kernel function (ie without any regard for the types of the parameters).
This is normally fine except for lseek() and mmap() - they may have an
interface that re-orders the arguments.
> We do have both lseek() and
> parisc32 nowadays and both work fine. Also with Daniel's series on top.
> Am I missing something?
godbolt doesn't have a parisc32 compiler - so I couldn't check.
But I think if you compare the code for calls to f1(int, int, int, int),
f2(int, long long, int) and f3(int, int long long) for f1(1,2,3,4),
f2(1, 2ull<<32 | 3, 4) and f3(1, 2, 3ull<<32 | 4) against another BE
system the 64bit constants will overlay different 32bit ones.
David
>
>
> Thomas
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/2] nolibc: Add fallocate()
2026-05-03 16:21 ` Thomas Weißschuh
@ 2026-05-04 1:46 ` Daniel Palmer
2026-05-04 15:33 ` Thomas Weißschuh
0 siblings, 1 reply; 17+ messages in thread
From: Daniel Palmer @ 2026-05-04 1:46 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: w, linux-kernel
Hi Thomas,
On Mon, 4 May 2026 at 01:21, Thomas Weißschuh <linux@weissschuh.net> wrote:
> Can you elaborate on what is broken?
>
> > sparc32 doesn't seem to support fallocate() so made it skip
> > the test.
> > - Rebase on nolibc/for-next with the large file support bits.
>
> (...)
For loongarch I seem to be missing OVMF:
qemu-system-loongarch64 -display none -no-reboot -kernel
"/home/daniel/.cache/nolibc-tests/loongarch/arch/loongarch/boot/vmlinuz.efi"
-initrd initramfs.cpio -serial file:/dev/stdout -m 1G
-M virt -append "console=ttyS0,115200 panic=-1 " -bios
/usr/share/edk2//loongarch64/OVMF_CODE.fd >
"/home/daniel/coding/cleantrees/linux-nolibc/tools/testing/selftests/nolibc/run.out"
qemu-system-loongarch64: Could not find ROM image
'/usr/share/edk2//loongarch64/OVMF_CODE.fd'
make: *** [Makefile.nolibc:341: run] Error 1
Debian doesn't seem to have a package for this.
For s390x, fixed now. Missing package.
For sh4, qemu-system-sh4 is 100% on one CPU and the test never
completes. I guess it's getting stuck during boot.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/2] nolibc: Add fallocate()
2026-05-04 1:46 ` Daniel Palmer
@ 2026-05-04 15:33 ` Thomas Weißschuh
2026-05-05 2:20 ` Daniel Palmer
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Weißschuh @ 2026-05-04 15:33 UTC (permalink / raw)
To: Daniel Palmer; +Cc: w, linux-kernel
On 2026-05-04 10:46:29+0900, Daniel Palmer wrote:
> On Mon, 4 May 2026 at 01:21, Thomas Weißschuh <linux@weissschuh.net> wrote:
> > Can you elaborate on what is broken?
> >
> > > sparc32 doesn't seem to support fallocate() so made it skip
> > > the test.
> > > - Rebase on nolibc/for-next with the large file support bits.
> >
> > (...)
>
> For loongarch I seem to be missing OVMF:
>
> qemu-system-loongarch64 -display none -no-reboot -kernel
> "/home/daniel/.cache/nolibc-tests/loongarch/arch/loongarch/boot/vmlinuz.efi"
> -initrd initramfs.cpio -serial file:/dev/stdout -m 1G
> -M virt -append "console=ttyS0,115200 panic=-1 " -bios
> /usr/share/edk2//loongarch64/OVMF_CODE.fd >
> "/home/daniel/coding/cleantrees/linux-nolibc/tools/testing/selftests/nolibc/run.out"
> qemu-system-loongarch64: Could not find ROM image
> '/usr/share/edk2//loongarch64/OVMF_CODE.fd'
> make: *** [Makefile.nolibc:341: run] Error 1
>
> Debian doesn't seem to have a package for this.
There is this in trixie:
https://packages.debian.org/trixie/all/qemu-efi-loongarch64
Unfortunately the path to the firmware files differ between distros and
QEMU versions. There are standard JSON descriptors which could be
queried but no tool for that is provided...
(...)
> For sh4, qemu-system-sh4 is 100% on one CPU and the test never
> completes. I guess it's getting stuck during boot.
See commit b0aa5e4b087b ("sh: Fix fallout from ZERO_PAGE
consolidation"). I now merged v7.1-rc2 into the nolibc tree to get
this fix.
Thomas
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/2] nolibc: Add fallocate()
2026-05-04 15:33 ` Thomas Weißschuh
@ 2026-05-05 2:20 ` Daniel Palmer
0 siblings, 0 replies; 17+ messages in thread
From: Daniel Palmer @ 2026-05-05 2:20 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: w, linux-kernel
Hi Thomas,
On Tue, 5 May 2026 at 00:33, Thomas Weißschuh <linux@weissschuh.net> wrote:
> > Debian doesn't seem to have a package for this.
>
> There is this in trixie:
>
> https://packages.debian.org/trixie/all/qemu-efi-loongarch64
For sid it is now /usr/share/qemu-efi-loongarch64/QEMU_EFI.fd
I've changed to that locally and the tests complete now.
> > For sh4, qemu-system-sh4 is 100% on one CPU and the test never
> > completes. I guess it's getting stuck during boot.
>
> See commit b0aa5e4b087b ("sh: Fix fallout from ZERO_PAGE
> consolidation"). I now merged v7.1-rc2 into the nolibc tree to get
> this fix.
SH4 is also completing now.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-05-05 2:20 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 16:41 [PATCH v3 0/2] nolibc: Add fallocate() Daniel Palmer
2026-04-30 16:41 ` [PATCH v3 1/2] tools/nolibc: fcntl: " Daniel Palmer
2026-05-01 8:18 ` David Laight
2026-05-02 3:00 ` Willy Tarreau
2026-05-02 21:26 ` David Laight
2026-05-03 16:28 ` Thomas Weißschuh
2026-05-03 22:38 ` David Laight
2026-04-30 16:41 ` [PATCH v3 2/2] selftests/nolibc: Add a very basic test for fallocate() Daniel Palmer
2026-05-02 3:04 ` Willy Tarreau
2026-05-02 4:00 ` Daniel Palmer
2026-05-02 4:40 ` Willy Tarreau
2026-05-03 16:20 ` Thomas Weißschuh
2026-05-02 3:05 ` [PATCH v3 0/2] nolibc: Add fallocate() Willy Tarreau
2026-05-03 16:21 ` Thomas Weißschuh
2026-05-04 1:46 ` Daniel Palmer
2026-05-04 15:33 ` Thomas Weißschuh
2026-05-05 2:20 ` Daniel Palmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox