io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: axboe@kernel.dk, io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring: Use slab for struct io_buffer objects
Date: Thu, 07 Sep 2023 21:30:29 -0400	[thread overview]
Message-ID: <87o7ida1u2.fsf@suse.de> (raw)
In-Reply-To: <x49o7id3ja8.fsf@segfault.boston.devel.redhat.com> (Jeff Moyer's message of "Thu, 07 Sep 2023 14:55:27 -0400")

Jeff Moyer <jmoyer@redhat.com> writes:

> Hi, Gabriel,
>
> I just have a couple of comments.  I don't have an opinion on whether it
> makes sense to replace the existing allocator.
>
> -Jeff
>
>> @@ -362,11 +363,12 @@ int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
>>  	return 0;
>>  }
>>  
>> +#define IO_BUFFER_ALLOC_BATCH (PAGE_SIZE/sizeof(struct io_buffer))
>> +
>>  static int io_refill_buffer_cache(struct io_ring_ctx *ctx)
>>  {
>> -	struct io_buffer *buf;
>> -	struct page *page;
>> -	int bufs_in_page;
>> +	struct io_buffer *bufs[IO_BUFFER_ALLOC_BATCH];
>
> That's a pretty large on-stack allocation.

Indeed, that is definitely too large. Thanks for pointing it out.

Also,  I just noticed the define above should actually read:

#define IO_BUFFER_ALLOC_BATCH (PAGE_SIZE/sizeof(struct io_buffer *))

I'll follow up with a v2, after I retest the impact a smaller allocation
batch would have.

>
>> +	allocated = kmem_cache_alloc_bulk(io_buf_cachep, GFP_KERNEL_ACCOUNT,
>> +					  ARRAY_SIZE(bufs), (void **) bufs);
>> +	if (unlikely(allocated <= 0)) {
>
> Can't be less than 0.

Thanks, will fix.

>

-- 
Gabriel Krisman Bertazi

      reply	other threads:[~2023-09-08  1:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  0:36 [PATCH] io_uring: Use slab for struct io_buffer objects Gabriel Krisman Bertazi
2023-09-07 18:39 ` Gabriel Krisman Bertazi
2023-09-07 18:55 ` Jeff Moyer
2023-09-08  1:30   ` Gabriel Krisman Bertazi [this message]

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=87o7ida1u2.fsf@suse.de \
    --to=krisman@suse.de \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=jmoyer@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).