public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Victor Stewart <v@nametag.social>
Cc: io-uring <io-uring@vger.kernel.org>
Subject: Re: [BUG? liburing] io_uring_register_files_update with liburing 2.0 on 5.13.17
Date: Sat, 18 Sep 2021 17:40:51 -0600	[thread overview]
Message-ID: <3df95a9f-7a5a-14bd-13e4-cef8a3f58dbd@kernel.dk> (raw)
In-Reply-To: <d0cbd186-b721-c7ca-f304-430e272a78f4@kernel.dk>

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


  reply	other threads:[~2021-09-18 23:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18 13:41 [BUG? liburing] io_uring_register_files_update with liburing 2.0 on 5.13.17 Victor Stewart
2021-09-18 14:41 ` Jens Axboe
2021-09-18 20:13   ` Victor Stewart
2021-09-18 20:26     ` Jens Axboe
2021-09-18 20:38       ` Jens Axboe
2021-09-18 21:55         ` Victor Stewart
2021-09-18 22:21           ` Jens Axboe
2021-09-18 23:19             ` Victor Stewart
2021-09-18 23:23               ` Victor Stewart
2021-09-18 23:37               ` Jens Axboe
2021-09-18 23:40                 ` Jens Axboe [this message]
2021-09-19  4:15                   ` Vito Caputo
2021-09-19 14:16                     ` Jens Axboe
2021-09-20 12:51                   ` Victor Stewart
2021-09-20 13:10                     ` Jens Axboe
2021-09-20 13:19                       ` Victor Stewart
2021-09-19 11:56             ` Pavel Begunkov
2021-09-19 14:24               ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3df95a9f-7a5a-14bd-13e4-cef8a3f58dbd@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=v@nametag.social \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox