Message ID | 20240820-loong-fstat-v1-1-799b6627bb2f@gmail.com |
---|---|
State | New |
Headers | show |
Series | Loongarch: adapt for the re-introduction of fstat and newfstatat in 6.11 | expand |
On Tue, 2024-08-20 at 20:27 +0800, Miao Wang via B4 Relay wrote: > Kernel 6.11 adds back fstat and newfstatat in commit 7697a0fe0154 > ("LoongArch: Define __ARCH_WANT_NEW_STAT in unistd.h"). With kernel > headers from 6.11, make update-syscall-lists will generate the following > diffs: > > diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h Don't directly embed a diff here (w/o some mangling). Doing so will puzzle patchwork, git am, etc to consider it a part of the patch. Look at the unwanted effect at https://patchwork.sourceware.org/project/glibc/patch/20240820-loong-fstat-v1-1-799b6627bb2f@gmail.com/. > +#include_next <kernel-features.h> > + > +#define __ASSUME_LOONGARCH_NEWSTAT 1 > + > +/* No support for fstat or newfstatat before 6.11. */ 6.10.6, the change is backported so we can assume anything >= 6.10.6 have these syscalls. But we cannot make a reasonable assumption with other backports like 6.6.47. > +#if __LINUX_KERNEL_VERSION < 0x060b00 0x060a06. > +# undef __ASSUME_LOONGARCH_NEWSTAT Can we just #undef __NR_fstat and #undef __NR_newfstatat here? Sparc is undefining __NR_pause in their kernel-features.h. > +#endif
The email address of Joseph was outdated. I got a bounce from mentor.com. On Tue, 2024-08-20 at 20:44 +0800, Xi Ruoyao wrote: > On Tue, 2024-08-20 at 20:27 +0800, Miao Wang via B4 Relay wrote: > > > Kernel 6.11 adds back fstat and newfstatat in commit 7697a0fe0154 > > ("LoongArch: Define __ARCH_WANT_NEW_STAT in unistd.h"). With kernel > > headers from 6.11, make update-syscall-lists will generate the > > following > > diffs: > > > > diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h > > b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h > > Don't directly embed a diff here (w/o some mangling). Doing so will > puzzle patchwork, git am, etc to consider it a part of the patch. > Look > at the unwanted effect at > https://patchwork.sourceware.org/project/glibc/patch/20240820-loong-fstat-v1-1-799b6627bb2f@gmail.com/ > . > > > +#include_next <kernel-features.h> > > + > > +#define __ASSUME_LOONGARCH_NEWSTAT 1 > > + > > +/* No support for fstat or newfstatat before 6.11. */ > > 6.10.6, the change is backported so we can assume anything >= 6.10.6 > have these syscalls. But we cannot make a reasonable assumption with > other backports like 6.6.47. > > > +#if __LINUX_KERNEL_VERSION < 0x060b00 > > 0x060a06. > > > +# undef __ASSUME_LOONGARCH_NEWSTAT > > Can we just #undef __NR_fstat and #undef __NR_newfstatat here? Sparc > is > undefining __NR_pause in their kernel-features.h. > > > +#endif >
Thanks for your quick reply. > 2024年8月20日 20:46,Xi Ruoyao <xry111@xry111.site> 写道: > > The email address of Joseph was outdated. I got a bounce from > mentor.com. > > On Tue, 2024-08-20 at 20:44 +0800, Xi Ruoyao wrote: >> On Tue, 2024-08-20 at 20:27 +0800, Miao Wang via B4 Relay wrote: >> >>> Kernel 6.11 adds back fstat and newfstatat in commit 7697a0fe0154 >>> ("LoongArch: Define __ARCH_WANT_NEW_STAT in unistd.h"). With kernel >>> headers from 6.11, make update-syscall-lists will generate the >>> following >>> diffs: >>> >>> diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h >>> b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h >> >> Don't directly embed a diff here (w/o some mangling). Doing so will >> puzzle patchwork, git am, etc to consider it a part of the patch. >> Look >> at the unwanted effect at >> https://patchwork.sourceware.org/project/glibc/patch/20240820-loong-fstat-v1-1-799b6627bb2f@gmail.com/ >> . >> >>> +#include_next <kernel-features.h> >>> + >>> +#define __ASSUME_LOONGARCH_NEWSTAT 1 >>> + >>> +/* No support for fstat or newfstatat before 6.11. */ >> >> 6.10.6, the change is backported so we can assume anything >= 6.10.6 >> have these syscalls. But we cannot make a reasonable assumption with >> other backports like 6.6.47. Actually such backport is questionable, since it changes the kernel feature. I believe that this breaks our assumption that kernel will have certain feature if version >= some number. So I think we can ignore the stable backports and only focus on the mainline releases. >> >>> +#if __LINUX_KERNEL_VERSION < 0x060b00 >> >> 0x060a06. >> >>> +# undef __ASSUME_LOONGARCH_NEWSTAT >> >> Can we just #undef __NR_fstat and #undef __NR_newfstatat here? Sparc >> is >> undefining __NR_pause in their kernel-features.h. I think it would be better if in sysdep.h. As far as I know, the inclusion of headers orders like that: sysdeps/unix/sysv/linux/loongarch/sysdep.h sysdeps/unix/sysv/linux/sysdep.h sysdeps/unix/sysv/linux/loongarch/kernel-features.h sysdeps/unix/sysv/linux/kernel-features.h sysdeps/unix/sysdep.h sysdeps/unix/sysv/linux/include/sys/syscall.h sysdeps/unix/sysv/linux/loongarch/arch-syscall.h So it seems to be safer to #undef in loongarch/sysdep.h after the inclusion of sysdeps/unix/sysdep.h Cheers, Miao Wang >> >>> +#endif >> > > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University
On Tue, 2024-08-20 at 21:03 +0800, Miao Wang wrote: > > > > +/* No support for fstat or newfstatat before 6.11. */ > > > > > > 6.10.6, the change is backported so we can assume anything >= 6.10.6 > > > have these syscalls. But we cannot make a reasonable assumption with > > > other backports like 6.6.47. > Actually such backport is questionable, since it changes the kernel feature. > I believe that this breaks our assumption that kernel will have certain feature > if version >= some number. So I think we can ignore the stable backports and > only focus on the mainline releases. Why? You cannot find an integer in (10, 11), thus any kernel release >= 6.10.6 will have these two syscalls, unless you plan to revert it for 6.10.7 or something. And I cannot see how a revert is possible because the ship is sailed and a revert will be outrageously "breaking userspace" now. If you really want to prevent it, you should have done that before 6.10.6 release like I'd attempted to do (but nobody listened to me). Note that random kernel snapshots are not supported (i.e. 6.11.0-rc1 isn't considered a supported "release" between 6.10.6 and 6.11.0). And random non-Linus forks of the kernel aren't supported by Glibc as well (for example, IA64 was directly removed from Glibc when the Linus' tree removed IA64 despite some guys have a working non-Linus fork), so the problematic vendor kernels mentioned by Greg and Cyril aren't ever considered. I'm now writing something in areweloongyet.com for this. If we went with 6.11.0 how would I explain the reason in the article? Just "someone thinks the backport is questionable"? Then I think the reintroduce of these two syscalls is questionable in the first place, so should we never use them in Glibc? Or for some reason your opinion can make a difference but mine cannot? OTOH it's a fact that any kernel release >= 6.10.6 supports those two syscalls, so we should live with the fact (instead of opinions) and it's the best way to avoid controversies. > > > > > > > +#if __LINUX_KERNEL_VERSION < 0x060b00 > > > > > > 0x060a06.
diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h index 8bb82448a7..7e732256fd 100644 --- a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h +++ b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h @@ -59,6 +59,7 @@ #define __NR_fsmount 432 #define __NR_fsopen 430 #define __NR_fspick 433 +#define __NR_fstat 80 #define __NR_fstatfs 44 #define __NR_fsync 82 #define __NR_ftruncate 46 @@ -166,6 +167,7 @@ #define __NR_munmap 215 #define __NR_name_to_handle_at 264 #define __NR_nanosleep 101 +#define __NR_newfstatat 79 #define __NR_nfsservctl 42 #define __NR_open_by_handle_at 265 #define __NR_open_tree 428 With that changed, the compiled libraries will unexpectedly include calls to these two syscalls, and be incompatible with previous kernel versions. This patch addresses this issue by removing the two definations if the targeted kernel version is below 6.11. I have tested this patch along with the change to arch-syscall.h with or without the configuration option --enable-kernel=6.11. --- .../unix/sysv/linux/loongarch/kernel-features.h | 27 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/loongarch/sysdep.h | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/sysdeps/unix/sysv/linux/loongarch/kernel-features.h b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h new file mode 100644 index 0000000000..c0e7ccb5de --- /dev/null +++ b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h @@ -0,0 +1,27 @@ +/* Set flags signalling availability of kernel features based on given + kernel version number. Loongarch version. + Copyright (C) 2024-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include_next <kernel-features.h> + +#define __ASSUME_LOONGARCH_NEWSTAT 1 + +/* No support for fstat or newfstatat before 6.11. */ +#if __LINUX_KERNEL_VERSION < 0x060b00 +# undef __ASSUME_LOONGARCH_NEWSTAT +#endif diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h index eb0ba790da..1fdf18197f 100644 --- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h +++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h @@ -109,6 +109,11 @@ #undef SYS_ify #define SYS_ify(syscall_name) __NR_##syscall_name +#ifndef __ASSUME_LOONGARCH_NEWSTAT +#undef __NR_fstat +#undef __NR_newfstatat +#endif + #ifndef __ASSEMBLER__ #define VDSO_NAME "LINUX_5.10"