public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH 2/2] io_uring: get rid of alloc cache init_once handling
Date: Thu, 23 Jan 2025 14:47:42 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 1/23/25 14:27, Pavel Begunkov wrote:
> On 1/23/25 14:21, Jens Axboe wrote:
>> init_once is called when an object doesn't come from the cache, and
>> hence needs initial clearing of certain members. While the whole
>> struct could get cleared by memset() in that case, a few of the cache
>> members are large enough that this may cause unnecessary overhead if
>> the caches used aren't large enough to satisfy the workload. For those
>> cases, some churn of kmalloc+kfree is to be expected.
>>
>> Ensure that the 3 users that need clearing put the members they need
>> cleared at the start of the struct, and place an empty placeholder
>> 'init' member so that the cache initialization knows how much to
>> clear.
>>
>> Signed-off-by: Jens Axboe <[email protected]>
>> ---
>>   include/linux/io_uring/cmd.h   |  3 ++-
>>   include/linux/io_uring_types.h |  3 ++-
>>   io_uring/alloc_cache.h         | 30 +++++++++++++++++++++---------
>>   io_uring/futex.c               |  4 ++--
>>   io_uring/io_uring.c            | 13 ++++++++-----
>>   io_uring/io_uring.h            |  5 ++---
>>   io_uring/net.c                 | 11 +----------
>>   io_uring/net.h                 |  7 +++++--
>>   io_uring/poll.c                |  2 +-
>>   io_uring/rw.c                  | 10 +---------
>>   io_uring/rw.h                  |  5 ++++-
>>   io_uring/uring_cmd.c           | 10 +---------
>>   12 files changed, 50 insertions(+), 53 deletions(-)
>>
>> diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h
>> index a3ce553413de..8d7746d9fd23 100644
>> --- a/include/linux/io_uring/cmd.h
>> +++ b/include/linux/io_uring/cmd.h
>> @@ -19,8 +19,9 @@ struct io_uring_cmd {
>>   };
>>   struct io_uring_cmd_data {
>> -    struct io_uring_sqe    sqes[2];
>>       void            *op_data;
>> +    int            init[0];
> 
> What do you think about using struct_group instead?

And why do we care not clearing it all on initial alloc? If that's
because of kasan, we can disable it until ("kasan, mempool: don't
store free stacktrace in io_alloc_cache objects") lands.

-- 
Pavel Begunkov


  reply	other threads:[~2025-01-23 14:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 14:21 [PATCHSET 0/2] Cleanup alloc cache init_once handling Jens Axboe
2025-01-23 14:21 ` [PATCH 1/2] io_uring/uring_cmd: cleanup struct io_uring_cmd_data layout Jens Axboe
2025-01-23 14:38   ` Pavel Begunkov
2025-01-23 14:54     ` Jens Axboe
2025-01-23 14:57       ` Pavel Begunkov
2025-01-23 14:58         ` Jens Axboe
2025-01-23 14:21 ` [PATCH 2/2] io_uring: get rid of alloc cache init_once handling Jens Axboe
2025-01-23 14:27   ` Pavel Begunkov
2025-01-23 14:47     ` Pavel Begunkov [this message]
2025-01-23 14:55       ` Jens Axboe
2025-01-23 15:05         ` Pavel Begunkov
2025-01-23 15:09           ` Jens Axboe
2025-01-23 14:54     ` 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 \
    [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