On 9/18/21 5:37 PM, Jens Axboe wrote: >> and it failed with the same as before... >> >> io_uring_register(13, IORING_REGISTER_FILES, [-1, -1, -1, 3, 4, 5, 6, 7, 8, >> 9, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, >> -1, -1, -1, -1, >> -1, ...], 32768) = -1 EMFILE (Too many open files) >> >> if you want i can debug it for you tomorrow? (in london) > > Nah that's fine, I think it's just because you have other files opened > too. We bump the cur limit _to_ 'nr', but that leaves no room for anyone > else. Would be my guess. It works fine for the test case I ran here, but > your case may be different. Does it work if you just make it: > > rlim.rlim_cur += nr; > > instead? Specifically, just something like the below incremental. If rlim_cur _seems_ big enough, leave it alone. If not, add the amount we need to cur. And don't do any error checking here, let's leave failure to the kernel. diff --git a/src/register.c b/src/register.c index bab42d0..7597ec1 100644 --- a/src/register.c +++ b/src/register.c @@ -126,9 +126,7 @@ static int bump_rlimit_nofile(unsigned nr) if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) return -errno; if (rlim.rlim_cur < nr) { - if (nr > rlim.rlim_max) - return -EMFILE; - rlim.rlim_cur = nr; + rlim.rlim_cur += nr; setrlimit(RLIMIT_NOFILE, &rlim); } -- Jens Axboe