close_range: check for kernel support below 5.9
PATCH 1/1 close_range: check for kernel support below 5.9
Check for close_range syscall support in the kernel before running close_range01 and close_range02 tests.
--- include/lapi/close_range.h | 13 +++++++++++++ .../kernel/syscalls/close_range/close_range01.c | 2 ++ .../kernel/syscalls/close_range/close_range02.c | 1 + 3 files changed, 16 insertions(+)
include/lapi/close_range.h +13 -0
@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd,return tst_syscall (__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void ) +{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ + ret =syscall (__NR_close_range,1 ,0 ,0 ); +if (ret ==-1 && errno ==ENOSYS ) +tst_brk (TCONF ,"Test not supported on kernel version < v5.9" ); + } +} +#endif /* LAPI_CLOSE_RANGE_H__ */
testcases/kernel/syscalls/close_range/close_range01.c +2 -0
@@ -53,6 +53,8 @@ static inline void do_close_range(unsigned int fd, unsigned int max_fd,static void setup (void ) { +close_range_supported_by_kernel (); +struct rlimit nfd;SAFE_GETRLIMIT (RLIMIT_NOFILE , &nfd);
testcases/kernel/syscalls/close_range/close_range02.c +1 -0
@@ -111,4 +111,5 @@ static struct tst_test test = { .tcnt = 6, .forks_child = 1, .test = run, + .setup = close_range_supported_by_kernel, };
Signature · 5 lines
2.39.1.456.gfc5497dd1b-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Edward,
good catch :).
...
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned int max_fd, · line 34
Quoted 12 lines
+++
b/include/lapi/close_range.hinclude/lapi/close_range.h +7
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void ) +{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */
BTW what particular use case this fixed? Is it backported to some android kernel? Or to some enterprise distro? Because I don't think kernel stable trees accept new functionality, just fixes.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr,
Quoted 7 lines
Quoted 7 lines
+++
b/include/lapi/close_range.hinclude/lapi/close_range.h +2
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void )
Quoted 8 lines
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned int max_fd, · line 34
Quoted 5 lines
include/lapi/close_range.h +5
-0+{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ BTW what particular use case this fixed? Is it backported to some android kernel? Or to some enterprise distro? Because I don't think kernel stable trees accept new functionality, just fixes.
Oops, should I use .min_kver instead? It isn't backported on Android; I just wasn't sure what the right approach was.
Thanks,
Edward
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Edward,
Quoted 18 lines
Hi Petr,
Quoted 7 lines
Quoted 7 lines
+++
b/include/lapi/close_range.hinclude/lapi/close_range.h +2
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void )Quoted 8 lines
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned int max_fd, · line 34
Quoted 5 lines
include/lapi/close_range.h +5
-0+{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ BTW what particular use case this fixed? Is it backported to some android kernel? Or to some enterprise distro? Because I don't think kernel stable trees accept new functionality, just fixes.
Quoted 2 lines
Oops, should I use .min_kver instead? It isn't backported on Android; I just wasn't sure what the right approach was.
Actually, looking into SLES kernel sources, we backported close_range() to SLES 15-SP3 (bsc#1179090), which was 5.3.18 based. Thus you actually did good work :).
@Li, @Jan out of curiosity, was this backported to RHEL kernel as well? It'd be useful to note that (one day we will be able to remove it once kernels which backported are EOL).
Kind regards,
Petr
Quoted 2 lines
Thanks,
Edward
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 24 lines · Petr Vorel
Hi Edward,
Quoted 18 lines
Hi Petr,
Quoted 7 lines
Quoted 7 lines
+++
b/include/lapi/close_range.hinclude/lapi/close_range.h +2
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void )Quoted 8 lines
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned int max_fd, · line 34
Quoted 5 lines
include/lapi/close_range.h +5
-0+{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ BTW what particular use case this fixed? Is it backported to some android kernel? Or to some enterprise distro? Because I don't think kernel stable trees accept new functionality, just fixes.
Quoted 2 lines
Oops, should I use .min_kver instead? It isn't backported on Android; I just wasn't sure what the right approach was.
Quoted 6 lines
Actually, looking into SLES kernel sources, we backported
close_range()to SLES 15-SP3 (bsc#1179090), which was 5.3.18 based. Thus you actually did good work :).@Li, @Jan out of curiosity, was this backported to RHEL kernel as well? It'd be useful to note that (one day we will be able to remove it once kernels which backported are EOL).
Yes, it's present in 8.4 since kernel-4.18.0-290.el8.
Quoted 7 lines
Kind regards,
PetrQuoted 2 lines
Thanks,
Edward
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 25 lines · Petr Vorel
Quoted 23 lines
Hi Edward,
Quoted 20 lines
Hi Petr,
Quoted 7 lines
Quoted 7 lines
+++
b/include/lapi/close_range.hinclude/lapi/close_range.h +2
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void )Quoted 8 lines
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned int max_fd, · line 34
Quoted 5 lines
include/lapi/close_range.h +5
-0+{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ BTW what particular use case this fixed? Is it backported to some android kernel? Or to some enterprise distro? Because I don't think kernel stable trees accept new functionality, just fixes.
Oops, should I use .min_kver instead? It isn't backported on Android; I just wasn't sure what the right approach was.
Quoted 8 lines
Quoted 6 lines
Actually, looking into SLES kernel sources, we backported
close_range()to SLES 15-SP3 (bsc#1179090), which was 5.3.18 based. Thus you actually did good work :).@Li, @Jan out of curiosity, was this backported to RHEL kernel as well? It'd be useful to note that (one day we will be able to remove it once kernels which backported are EOL).
Yes, it's present in 8.4 since kernel-4.18.0-290.el8.
Jan, thanks a lot!
@Edward we have Hackweek at SUSE, I'll merge this on Monday, noting the reason why to keep this instead simple .min_kver.
Kind regards,
Petr
Quoted 5 lines
Quoted 5 lines
Kind regards,
PetrQuoted 2 lines
Thanks,
Edward
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Oh, lucky coincidence I guess. Thanks, Petr!
Quoted 50 lines · Petr Vorel
Quoted 26 lines · Petr Vorel
Quoted 23 lines
Hi Edward,
Quoted 20 lines
Hi Petr,
Quoted 7 lines
Quoted 7 lines
+++
b/include/lapi/close_range.hinclude/lapi/close_range.h +2
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void )Quoted 8 lines
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned int max_fd, · line 34
Quoted 5 lines
include/lapi/close_range.h +5
-0+{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ BTW what particular use case this fixed? Is it backported to some android kernel? Or to some enterprise distro? Because I don't think kernel stable trees accept new functionality, just fixes.
Oops, should I use .min_kver instead? It isn't backported on Android; I just wasn't sure what the right approach was.
Quoted 8 lines
Quoted 6 lines
Actually, looking into SLES kernel sources, we backported
close_range()to SLES 15-SP3 (bsc#1179090), which was 5.3.18 based. Thus you actually did good work :).@Li, @Jan out of curiosity, was this backported to RHEL kernel as well? It'd be useful to note that (one day we will be able to remove it once kernels which backported are EOL).
Yes, it's present in 8.4 since kernel-4.18.0-290.el8.
Jan, thanks a lot!
@Edward we have Hackweek at SUSE, I'll merge this on Monday, noting the reason why to keep this instead simple .min_kver.
Kind regards,
PetrQuoted 5 lines
Quoted 5 lines
Kind regards,
PetrQuoted 2 lines
Thanks,
Edward
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
Edward, thanks for your work, merged.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
hm, I was too fast to merge it. Looking at older result, It looks like this (merged as 7b5ee03899) was not needed, because tst_syscall() properly detects missing support:
close_range01.c:134: TINFO: Plain close range../../../../include/lapi/close_range.h:25: TCONF: syscall(436) __NR_close_range not supported on your arch
@Edward: Before we revert it, did you encounter some problem that it's really needed? If yes, please share details.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hey Petr,
We turned on the HAVE_CLOSE_RANGE flag to test the bionic-defined close_range on Android, but doing so bypasses tst_syscall in include/lapi/close_range.h. We don't currently have a way to configure ltp differently across each kernel version, so I wanted to use this check as a fallback to gate earlier kernels.
Thanks,
Edward
Quoted 15 lines · Petr Vorel
Hi,
hm, I was too fast to merge it. Looking at older result, It looks like this (merged as
7b5ee03899) was not needed, becausetst_syscall()properly detects missing support:close_range01.c:134: TINFO: Plain close range
../../../../include/lapi/close_range.h:25: TCONF: syscall(436)__NR_close_rangenot supported on your arch@Edward: Before we revert it, did you encounter some problem that it's really needed? If yes, please share details.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Edward,
Quoted 7 lines
Hey Petr,
We turned on the
HAVE_CLOSE_RANGEflag to test the bionic-definedclose_rangeon Android, but doing so bypassestst_syscallininclude/lapi/close_range.h. We don't currently have a way to configure ltp differently across each kernel version, so I wanted to use this check as a fallback to gate earlier kernels.
Thanks for info. OK, at least it's needed :).
If these fixes would be needed for more syscalls, we might want to check if there is a way to enhance tst_syscall() (likely there is no way).
Also (for next time) it's always safe to be more verbose for the reason in the commit message to prevent cleanup of workarounds too early (before EOL of that particular kernel).
Kind regards,
Petr
Quoted 20 lines
Thanks,
EdwardQuoted 14 lines · Petr Vorel
Hi,
hm, I was too fast to merge it. Looking at older result, It looks like this (merged as
7b5ee03899) was not needed, becausetst_syscall()properly detects missing support:close_range01.c:134: TINFO: Plain close range
../../../../include/lapi/close_range.h:25: TCONF: syscall(436)__NR_close_rangenot supported on your arch@Edward: Before we revert it, did you encounter some problem that it's really needed? If yes, please share details.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr,
Thanks, I will do that in the future. This is the only time I've encountered this so far but will look into doing that if there is another.
Thanks,
Edward
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Edward, Petr,
Sorry for the late append reply.
Quoted 16 lines · Edward Liaw via ltp
Check for
close_rangesyscall support in the kernel before runningclose_range01andclose_range02tests.Signed-off-by Edward Liaw <[email protected]>--- include/lapi/close_range.h | 13 +++++++++++++ .../kernel/syscalls/close_range/close_range01.c | 2 ++ .../kernel/syscalls/close_range/close_range02.c | 1 + 3 files changed, 16 insertions(+)include/lapi/close_range.h +0
-0
include/lapi/close_range.h static inline int close_range(unsigned int fd, unsigned · line 34
Quoted 10 lines
include/lapi/close_range.h +6
-0@@ -25,4 +25,17 @@ static inline int close_range(unsigned int fd, unsignedint max_fd, return tst_syscall(__NR_close_range, fd, max_fd, flags); }# endif + +static inline void close_range_supported_by_kernel (void ) +{ +long ret; + +if ((tst_kvercmp (5 ,9 ,0 )) <0 ) {
Using tst_kvercmp together with ENOSYS check is a repetitive practice, I think verifying the returned value and errno is quite enough to determine an un-support syscall.
And there is possible a lite kernel version newer than 5.9 removes this syscall support. Then this test will fail again because this tst_kvercmp skips the ENOSYS check.
Otherwise:
Quoted 43 lines
include/lapi/close_range.h +4
-0+/* Check if the syscall is backported on an older kernel */ + ret =syscall (__NR_close_range,1 ,0 ,0 ); +if (ret ==-1 && errno ==ENOSYS ) + tst_brk(TCONF, "Test not supported on kernelversion < v5.9");
include/lapi/close_range.h +3
-0+ } +} +#endif /* LAPI_CLOSE_RANGE_H__ */ testcases/kernel/syscalls/close_range/close_range01.c +2
-0@@ -53,6 +53,8 @@ static inline void do_close_range(unsigned int fd,unsigned int max_fd, static void setup(void) { +close_range_supported_by_kernel (); +struct rlimit nfd;SAFE_GETRLIMIT(RLIMIT_NOFILE, &nfd);testcases/kernel/syscalls/close_range/close_range02.c +1
-1@@ -111,4 +111,5 @@ static struct tst_test test = { .tcnt = 6, .forks_child = 1, .test = run, + .setup = close_range_supported_by_kernel, }; --2.39.1.456.gfc5497dd1b-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp