From: Yu Kuai <yukuai1@huaweicloud.com>
To: Matt Fleming <mfleming@cloudflare.com>, Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team <kernel-team@cloudflare.com>,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: 10x I/O await times in 6.12
Date: Tue, 22 Apr 2025 09:39:17 +0800 [thread overview]
Message-ID: <ceefa848-082b-0153-e41d-26c0559f3666@huaweicloud.com> (raw)
In-Reply-To: <CAGis_TU1V2_L227SP9Ut1gSTNx9-AT9nbwgJH6azzH8==35hBQ@mail.gmail.com>
Hi,
在 2025/04/22 3:10, Matt Fleming 写道:
> On Mon, 21 Apr 2025 at 19:53, Keith Busch <kbusch@kernel.org> wrote:
>>
>> Not sure. I'm also guessing cond_resched is the reason for your
>> observation, so that might be worth confirming is happening in whatever
>> IO paths you're workload is taking in case there's some other
>> explanation.
>
> Yep, you're spot on. We're hitting cond_resched() from various code
> paths (xfs_buf_delwri_submit_buffers(), swap_writepage(),
> rmap_walk_file(), etc, etc).
All pluged IO must be submited before scheduled out, there is no point
for this direction. :(
Please check the other mail that I replied to your original report,
it'll make sense if a task keeps running on one cpu for milliseconds.
Thanks,
Kuai
>
> sudo bpftrace -e 'k:psi_task_switch { $prev = (struct
> task_struct *)arg0; if ($prev->plug != 0) {
> if ($prev->plug->cur_ktime) {
> @[kstack(3)] = count();
> }
> }
> }'
> Attaching 1 probe...
> ^C
>
> @[
> psi_task_switch+5
> __schedule+2081
> __cond_resched+51
> ]: 3044
>
>> fs-writeback happens to work around it by unplugging if it knows
>> cond_resched is going to schedule. The decision to unplug here wasn't
>> necessarily because of the plug's ktime, but it gets the job done:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/fs-writeback.c?h=v6.15-rc3#n1984
>>
>> Doesn't really scale well to copy this for every caller of
>> cond_resched(), though. An io specific helper implementation of
>> cond_resched might help.
>>
>> Or if we don't want cond_resched to unplug (though I feel like you would
>> normally want that), I think we could invalidate the ktime when
>> scheduling to get the stats to read the current ktime after the process
>> is scheduled back in.
>
> Thanks. Makes sense to me. I'll try this out and report back.
>
>> ---
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -6978,6 +6978,9 @@ static void __sched notrace preempt_schedule_common(void)
>> * between schedule and now.
>> */
>> } while (need_resched());
>> +
>> + if (current->flags & PF_BLOCK_TS)
>> + blk_plug_invalidate_ts(current);
>> }
>>
>> #ifdef CONFIG_PREEMPTION
>> --
>
> .
>
next prev parent reply other threads:[~2025-04-22 1:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 8:53 10x I/O await times in 6.12 Matt Fleming
2025-04-21 12:21 ` Yu Kuai
2025-04-23 10:51 ` Matt Fleming
2025-04-24 2:35 ` Yu Kuai
2025-05-01 9:52 ` Matt Fleming
2026-04-23 18:18 ` Matt Fleming
2025-04-21 15:22 ` Keith Busch
2025-04-21 18:35 ` Matt Fleming
2025-04-21 18:53 ` Keith Busch
2025-04-21 19:10 ` Matt Fleming
2025-04-22 1:39 ` Yu Kuai [this message]
2025-04-22 1:28 ` Yu Kuai
2025-04-22 1:39 ` Keith Busch
2025-04-22 3:02 ` Yu Kuai
2025-04-22 10:45 ` Matt Fleming
2025-04-23 3:36 ` 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=ceefa848-082b-0153-e41d-26c0559f3666@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=axboe@kernel.dk \
--cc=kbusch@kernel.org \
--cc=kernel-team@cloudflare.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfleming@cloudflare.com \
--cc=yukuai3@huawei.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