public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Tso" <tytso@mit.edu>
To: liubaolin <liubaolin12138@163.com>
Cc: libaokun@linux.alibaba.com, adilger.kernel@dilger.ca,
	ojaswin@linux.ibm.com, ritesh.list@gmail.com,
	yi.zhang@huawei.com, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org, wangguanyu@vivo.com,
	Baolin Liu <liubaolin@kylinos.cn>,
	Andreas Dilger <adilger@dilger.ca>
Subject: Re: [PATCH v3 v3 2/2] ext4: allow clearing mballoc stats through mb_stats
Date: Fri, 24 Apr 2026 08:07:02 -0400	[thread overview]
Message-ID: <20260424120702.GD11127@macsyma-wired.lan> (raw)
In-Reply-To: <592456a9-ce45-4967-a7c4-4ed80e908bac@163.com>

On Fri, Apr 24, 2026 at 04:09:31PM +0800, liubaolin wrote:
> 
>    2. Do not delete the `/sys/fs/.../mb_stats` node for now; implement the
> same write control logic.
> 	* Write 0 to `/sys/fs/.../mb_stats` to disable statistics collection.
> 	* Write 1 to `/sys/fs/.../mb_stats` to enable statistics collection.
> 	* Write 2 to `/sys/fs/.../mb_stats` to clear statistics counters.

We could do that, but note that currently writing to
/sys/fs/.../mb_stats just sets an unsigned integer in
EXT4(sb)->s_mb_stats.  There is no ext4-specific function that runs
when /sys/fs/.../mb_stats is updated.

So either you have to add some check in fs/ext4/mballoc.c which gets
called every single time a block allocation happens --- and consider
the race condition where two CPU's are checking s_mb_stats at the same
time, and the desireability of adding a spinlock that would need to be
taken every single time a block allocation happens ---- or you have
add an ext4-specific function in fs/ext4/sysfs.c.

>    Compared to your suggestion, I recommend using the value 2 for the clear
> operation because s_mb_stats is an unsigned int variable, and using -1
> requires changing the variable type.

Well, since you have introduced an ext4-specific function which gets
called when writing to the procfs file, that function can clear the
statistics counter when -1 is written to the file --- and then set
s_mbi_stats to 1.

Cheers,

						- Ted

  parent reply	other threads:[~2026-04-24 12:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22  1:50 [PATCH v3 v3 0/2] add blocks_allocated to mb_stats and clear mb_stats Baolin Liu
2026-04-22  1:50 ` [PATCH v3 v3 1/2] ext4: add blocks_allocated to mb_stats output Baolin Liu
2026-04-24  2:35   ` Baokun Li
2026-04-22  1:50 ` [PATCH v3 v3 2/2] ext4: allow clearing mballoc stats through mb_stats Baolin Liu
2026-04-23 16:19   ` Theodore Tso
2026-04-24  3:12     ` Baokun Li
2026-04-24  8:09     ` liubaolin
2026-04-24  9:34       ` Baokun Li
2026-04-24 12:07       ` Theodore Tso [this message]
2026-04-22  9:55 ` [PATCH v3 v3 0/2] add blocks_allocated to mb_stats and clear mb_stats liubaolin

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=20260424120702.GD11127@macsyma-wired.lan \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=adilger@dilger.ca \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin12138@163.com \
    --cc=liubaolin@kylinos.cn \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=wangguanyu@vivo.com \
    --cc=yi.zhang@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