t/io_uring: don't make setrlimit() failing fatal
authorJens Axboe <axboe@kernel.dk>
Wed, 8 Sep 2021 14:07:57 +0000 (08:07 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 8 Sep 2021 14:07:57 +0000 (08:07 -0600)
We don't even need this on newer kernels, so just ignore it if it
fails. The worst that can happen is that buffer registration will
fail.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 28c76b02a6261544f0ea613ff0b70ded095e3a52..77d27859710301a5a9eb09bbc273ba27b6b73c31 100644 (file)
@@ -468,6 +468,13 @@ static int setup_ring(struct submitter *s)
        io_uring_probe(fd);
 
        if (fixedbufs) {
+               struct rlimit rlim;
+
+               rlim.rlim_cur = RLIM_INFINITY;
+               rlim.rlim_max = RLIM_INFINITY;
+               /* ignore potential error, not needed on newer kernels */
+               setrlimit(RLIMIT_MEMLOCK, &rlim);
+
                ret = io_uring_register_buffers(s);
                if (ret < 0) {
                        perror("io_uring_register_buffers");
@@ -646,17 +653,6 @@ int main(int argc, char *argv[])
                        j = 0;
        }
 
-       if (fixedbufs) {
-               struct rlimit rlim;
-
-               rlim.rlim_cur = RLIM_INFINITY;
-               rlim.rlim_max = RLIM_INFINITY;
-               if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0) {
-                       perror("setrlimit");
-                       return 1;
-               }
-       }
-
        arm_sig_int();
 
        for (j = 0; j < nthreads; j++) {