linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Tejun Heo <tj@kernel.org>, Haifeng Xu <haifeng.xu@shopee.com>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
	tytso@mit.edu, yi.zhang@huaweicloud.com, yukuai1@huaweicloud.com,
	linux-ext4@vger.kernel.org, linux-block@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH] buffer: Associate the meta bio with blkg from buffer page
Date: Sat, 31 Aug 2024 14:11:08 +0800	[thread overview]
Message-ID: <9cae20f9-aa6a-77da-8978-b4cfb7b0cb73@huaweicloud.com> (raw)
In-Reply-To: <ZtIfgc1CcG9XOu0-@slm.duckdns.org>

Hi, Tejun!

在 2024/08/31 3:37, Tejun Heo 写道:
> Hello, Haifeng.
> 
> On Wed, Aug 28, 2024 at 11:32:24AM +0800, Haifeng Xu wrote:
> ...
>> The filesystem is ext4(ordered). The meta data can be written out by
>> writeback, but if there are too many dirty pages, we had to do
>> checkpoint to write out the meta data in current thread context.
>>
>> In this case, the blkg of thread1 has set io.max, so the j_checkpoint_mutex
>> can't be released and many threads must wait for it. However, the blkg from
>> buffer page didn' set any io policy. Therefore, for the meta buffer head,
>> we can associate the bio with blkg from the buffer page instead of current
>> thread context.
>>
>> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
>> ---
>>   fs/buffer.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/fs/buffer.c b/fs/buffer.c
>> index e55ad471c530..a7889f258d0d 100644
>> --- a/fs/buffer.c
>> +++ b/fs/buffer.c
>> @@ -2819,6 +2819,17 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
>>   	if (wbc) {
>>   		wbc_init_bio(wbc, bio);
>>   		wbc_account_cgroup_owner(wbc, bh->b_page, bh->b_size);
>> +	} else if (buffer_meta(bh)) {
>> +		struct folio *folio;
>> +		struct cgroup_subsys_state *memcg_css, *blkcg_css;
>> +
>> +		folio = page_folio(bh->b_page);
>> +		memcg_css = mem_cgroup_css_from_folio(folio);
>> +		if (cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
>> +		    cgroup_subsys_on_dfl(io_cgrp_subsys)) {
>> +			blkcg_css = cgroup_e_css(memcg_css->cgroup, &io_cgrp_subsys);
>> +			bio_associate_blkg_from_css(bio, blkcg_css);
> 
> I think the right way to do it is marking the bio with REQ_META and
> implement forced charging in blk-throtl similar to blk-iocost.

This is the exact thing I did in the code I attached in the other
thread, do you take a look?

https://lore.kernel.org/all/97fc38e6-a226-5e22-efc2-4405beb6d75b@huaweicloud.com/

Thanks,
Kuai
> 
> Thanks.
> 


  reply	other threads:[~2024-08-31  6:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28  3:32 [PATCH] buffer: Associate the meta bio with blkg from buffer page Haifeng Xu
2024-08-28  5:19 ` Christoph Hellwig
2024-08-29 16:20 ` kernel test robot
2024-08-29 17:43 ` kernel test robot
2024-08-30 19:37 ` Tejun Heo
2024-08-31  6:11   ` Yu Kuai [this message]
2024-08-31  8:03     ` Tejun Heo
2024-08-31  9:48       ` 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=9cae20f9-aa6a-77da-8978-b4cfb7b0cb73@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=brauner@kernel.org \
    --cc=haifeng.xu@shopee.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yi.zhang@huaweicloud.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;
as well as URLs for NNTP newsgroup(s).