tests/io_uring/iouring.c: bump RLIMIT_MEMLOCK up to hard limit
PATCH v2 1/1 tests/io_uring/iouring.c: bump RLIMIT_MEMLOCK up to hard limit
Test domains may get their soft resource limits lowered on transition due to the typically denied rlimitinh permission. However, the resulting RLIMIT_MEMLOCK limit may not be enough to run the io_uring test program in some cases (low init task's limit + large page size, for example). Ensure that io_uring tests can run successfully in such environments as well by bumping the soft limit to the hard limit (which should be sufficient everywhere) in iouring.c.
The issue can be observed for example on CentOS Stream 9 on aarch64 or ppc64le.
---
This is an alternative (better) approach to fix the problem described in the v1 patch:
https://lore.kernel.org/selinux/[email protected]/
tests/io_uring/iouring.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tests/io_uring/iouring.c +15 -0
@@ -68,6 +68,7 @@#include <fcntl.h> #include <unistd.h> #include <sys/mman.h> +#include <sys/resource.h> #include <sys/stat.h> #include <sys/wait.h>
@@ -475,6 +476,7 @@ int main(int argc, char *argv[])struct urt_config *cfg_p;char *progname;char *progdir; +struct rlimit rlim;enum {TST_UNKNOWN ,TST_SQPOLL ,
@@ -500,6 +502,19 @@ int main(int argc, char *argv[]) progname =strdup (argv[0 ]); progdir =dirname (progname); +/* +* bump RLIMIT_MEMLOCK up to hard limit (some operations may need it, +* especially if PAGE_SIZE is big) +*/ +if (getrlimit (RLIMIT_MEMLOCK , &rlim)) +fatal ("getrlimit" ); + +if (rlim.rlim_cur < rlim.rlim_max) { + rlim.rlim_cur = rlim.rlim_max; +if (setrlimit (RLIMIT_MEMLOCK , &rlim)) +fatal ("setrlimit" ); + } +snprintf (uring_path,sizeof (uring_path),"%s/iouring.out" , progdir);/* simple header */
Signature · 1 line
2.55.0
Quoted 9 lines · Ondrej Mosnacek
Test domains may get their soft resource limits lowered on transition due to the typically denied rlimitinh permission. However, the resulting
RLIMIT_MEMLOCKlimit may not be enough to run theio_uringtest program in some cases (low init task's limit + large page size, for example). Ensure thatio_uringtests can run successfully in such environments as well by bumping the soft limit to the hard limit (which should be sufficient everywhere) iniouring.c.
Quoted 5 lines
The issue can be observed for example on CentOS Stream 9 on aarch64 or ppc64le.
Fixes 3b4e44eb3243 ("Add tests for io_uring")Signed-off-by Ondrej Mosnacek <[email protected]>
Ondrej Mosnacek
AppliedQuoted 11 lines · Stephen Smalley
Quoted 9 lines · Ondrej Mosnacek
Test domains may get their soft resource limits lowered on transition due to the typically denied rlimitinh permission. However, the resulting
RLIMIT_MEMLOCKlimit may not be enough to run theio_uringtest program in some cases (low init task's limit + large page size, for example). Ensure thatio_uringtests can run successfully in such environments as well by bumping the soft limit to the hard limit (which should be sufficient everywhere) iniouring.c.
Quoted 7 lines
Quoted 5 lines
The issue can be observed for example on CentOS Stream 9 on aarch64 or ppc64le.
Fixes 3b4e44eb3243 ("Add tests for io_uring")Signed-off-by Ondrej Mosnacek <[email protected]>Acked-by Stephen Smalley <[email protected]>
Thanks, applied:
https://github.com/SELinuxProject/selinux-testsuite/commit/d03e89292da66e638d795c06840037d27131d82c
Signature · 3 lines
Ondrej Mosnacek Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.