[PATCH 7/8] md/raid5: raise MAX_STRIPE_BATCH from 8 to 32
Hiroshi Nishida <[email protected]>
| Newsgroups | gmane.linux.raid,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
handle_active_stripes() dequeues up to MAX_STRIPE_BATCH stripes under device_lock per pass, then processes them after dropping the lock. Raising the batch from 8 to 32 amortizes each device_lock acquisition over more stripes, reducing lock cycles per unit of stripe work. The worker-spawn heuristic in raid5_wakeup_stripe_thread() also divided by MAX_STRIPE_BATCH; split it into a separate STRIPE_BATCH_WORKERS=8 so the spawn sensitivity is preserved unchanged while the batch size grows. Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Hiroshi Nishida <[email protected]> --- drivers/md/raid5.c | 2 +- drivers/md/raid5.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index c8787ab7b309..ad6230415af3 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -210,7 +210,7 @@ static void raid5_wakeup_stripe_thread(struct stripe_head *sh) /* at least one worker should run to avoid race */ queue_work_on(sh->cpu, raid5_wq, &group->workers[0].work); - thread_cnt = group->stripes_cnt / MAX_STRIPE_BATCH - 1; + thread_cnt = group->stripes_cnt / STRIPE_BATCH_WORKERS - 1; /* wakeup more workers */ for (i = 1; i < conf->worker_cnt_per_group && thread_cnt > 0; i++) { if (group->workers[i].working == false) { diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index 7aeba1fc7f09..1f37dabd727b 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h @@ -496,7 +496,8 @@ struct disk_info { #define BYPASS_THRESHOLD 1 #define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head)) #define HASH_MASK (NR_HASH - 1) -#define MAX_STRIPE_BATCH 8 +#define MAX_STRIPE_BATCH 32 /* stripes per handle_active_stripes pass */ +#define STRIPE_BATCH_WORKERS 8 /* stripes-per-worker threshold for spawning */ #define RAID5_SYNC_WINDOW 32 /* stripes to pre-submit per sync_request call */ /* NR_STRIPE_HASH_LOCKS must be a power of two, since -- 2.43.0