Re: [PATCH v3 v3 2/2] ext4: allow clearing mballoc stats through mb_stats
From: Baokun Li
Date: Thu Apr 23 2026 - 23:15:20 EST
On 2026/4/24 00:19, Theodore Tso wrote:
> On Wed, Apr 22, 2026 at 09:50:25AM +0800, Baolin Liu wrote:
>> From: Baolin Liu <liubaolin@xxxxxxxxxx>
>>
>> Make /proc/fs/ext4/<dev>/mb_stats writable and clear the runtime
>> mballoc statistics when 0 is written.
> At the moment to enable mb_stats the system administrator needs to
> write "1" to /sys/fs/ext4/<dev>/mb_stats, and writing "0" to the sysfs
> file will pauce the statistics colleciton (but not clear the
> statistics). Adding a way to clear the statistics by writing to the
> procfs file might be confusing to users.
>
> So.... as a suggestion, if you're adding to the ability to write to
> /proc/fs/.../mb_stats, what if we make things work by
>
> * Write 1 to /proc/fs/.../mb_stats to enable statistics collection
> * Write 0 to /proc/fs/.../mb_stats to disable statistics collection
> * Write -1 to /proc/fs/.../mb_stats to clear statistics counters
>
> And then deprecate the /sys/fs/.../mb_stats variable (but we probably
> won't be able to remove it for at least a year or two).
I like this idea. Consolidating everything into /proc/fs/.../mb_stats
and using -1 to reset the counters is much cleaner than the current
split approach.
Cheers,
Baokun