mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yu Kuai" <yukuai@fnnas.com>
To: "Li Nan" <linan666@huaweicloud.com>, <song@kernel.org>,
	 <linux-raid@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <filippo@debian.org>,
	<colyli@fnnas.com>,  <yukuai@fnnas.com>
Subject: Re: [PATCH v2 04/11] md/raid5: use mempool to allocate stripe_request_ctx
Date: Sat, 3 Jan 2026 19:12:33 +0800	[thread overview]
Message-ID: <5460e6b3-9b23-49e9-a52b-57e1e6d2490a@fnnas.com> (raw)
In-Reply-To: <343e3081-7d24-f783-b040-2f61aad4ea4f@huaweicloud.com>

Hi,

在 2025/12/26 16:33, Li Nan 写道:
>
>
> 在 2025/11/24 14:31, Yu Kuai 写道:
>> On the one hand, stripe_request_ctx is 72 bytes, and it's a bit huge for
>> a stack variable.
>>
>> On the other hand, the bitmap sectors_to_do is a fixed size, result in
>> max_hw_sector_kb of raid5 array is at most 256 * 4k = 1Mb, and this will
>> make full stripe IO impossible for the array that chunk_size * 
>> data_disks
>> is bigger. Allocate ctx during runtime will make it possible to get rid
>> of this limit.
>>
>> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
>> ---
>>   drivers/md/md.h       |  4 +++
>>   drivers/md/raid1-10.c |  5 ----
>>   drivers/md/raid5.c    | 61 +++++++++++++++++++++++++++----------------
>>   drivers/md/raid5.h    |  2 ++
>>   4 files changed, 45 insertions(+), 27 deletions(-)
>>
>
> [...]
>
>> @@ -7374,6 +7380,10 @@ static void free_conf(struct r5conf *conf)
>>       bioset_exit(&conf->bio_split);
>>       kfree(conf->stripe_hashtbl);
>>       kfree(conf->pending_data);
>> +
>> +    if (conf->ctx_pool)
>> +        mempool_destroy(conf->ctx_pool);
>> +
>>       kfree(conf);
>>   }
>>   @@ -8057,6 +8067,13 @@ static int raid5_run(struct mddev *mddev)
>>               goto abort;
>>       }
>>   +    conf->ctx_pool = mempool_create_kmalloc_pool(NR_RAID_BIOS,
>> +                    sizeof(struct stripe_request_ctx));
>> +    if (!conf->ctx_pool) {
>> +        ret = -ENOMEM;
>> +        goto abort;
>> +    }
>> +
>
> What about moving create to setup_conf()? If so, call destroy in
> free_conf() without checks.

No, we can't, this must be done after raid5_set_limits(), which is called
at the end of raid5_run().

>
>>       if (log_init(conf, journal_dev, raid5_has_ppl(conf)))
>>           goto abort;
>>   diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
>> index eafc6e9ed6ee..6e3f07119fa4 100644
>> --- a/drivers/md/raid5.h
>> +++ b/drivers/md/raid5.h
>> @@ -690,6 +690,8 @@ struct r5conf {
>>       struct list_head    pending_list;
>>       int            pending_data_cnt;
>>       struct r5pending_data    *next_pending_data;
>> +
>> +    mempool_t        *ctx_pool;
>>   };
>>     #if PAGE_SIZE == DEFAULT_STRIPE_SIZE
>
-- 
Thansk,
Kuai

  reply	other threads:[~2026-01-03 11:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24  6:31 [PATCH v2 00/11] md: align bio to io_opt and fix abnormal io_opt Yu Kuai
2025-11-24  6:31 ` [PATCH v2 01/11] md: merge mddev has_superblock into mddev_flags Yu Kuai
2025-12-26  3:04   ` Li Nan
2025-11-24  6:31 ` [PATCH v2 02/11] md: merge mddev faillast_dev " Yu Kuai
2025-12-26  3:46   ` Li Nan
2025-11-24  6:31 ` [PATCH v2 03/11] md: merge mddev serialize_policy " Yu Kuai
2025-12-26  6:33   ` Li Nan
2025-11-24  6:31 ` [PATCH v2 04/11] md/raid5: use mempool to allocate stripe_request_ctx Yu Kuai
2025-12-26  8:33   ` Li Nan
2026-01-03 11:12     ` Yu Kuai [this message]
2025-12-30  9:38   ` Li Nan
2026-01-03 11:13     ` Yu Kuai
2025-11-24  6:31 ` [PATCH v2 05/11] md/raid5: make sure max_sectors is not less than io_opt Yu Kuai
2025-11-24  6:31 ` [PATCH v2 06/11] md: support to align bio to limits Yu Kuai
2025-11-27  0:51   ` kernel test robot
2025-11-30  2:38     ` Yu Kuai
2025-11-27  7:05   ` kernel test robot
2025-11-24  6:31 ` [PATCH v2 07/11] md: add a helper md_config_align_limits() Yu Kuai
2025-11-24  6:32 ` [PATCH v2 08/11] md/raid5: align bio to io_opt Yu Kuai
2025-11-24  6:32 ` [PATCH v2 09/11] md/raid10: " Yu Kuai
2025-11-24  6:32 ` [PATCH v2 10/11] md/raid0: " Yu Kuai
2025-11-24  6:32 ` [PATCH v2 11/11] md: fix abnormal io_opt from member disks Yu Kuai

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=5460e6b3-9b23-49e9-a52b-57e1e6d2490a@fnnas.com \
    --to=yukuai@fnnas.com \
    --cc=colyli@fnnas.com \
    --cc=filippo@debian.org \
    --cc=linan666@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    /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

all inboxes | Powered by JetHome®