public inbox for [email protected]
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <[email protected]>
To: Jeff Moyer <[email protected]>
Cc: [email protected], [email protected]
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: <[email protected]> (raw)
In-Reply-To: <[email protected]> (Jeff Moyer's message of "Thu, 07 Sep 2023 14:55:27 -0400")

Jeff Moyer <[email protected]> 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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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