Re: [PATCH v2 v2 2/2] ext4: allow clearing mballoc stats through mb_stats

From: Ojaswin Mujoo

Date: Tue Apr 21 2026 - 02:12:57 EST


On Tue, Apr 21, 2026 at 01:22:31PM +0800, liubaolin wrote:
> Dear all,
> I noticed the discussion about where to document the ext4 proc parameter
> mb_stats.
> I ran:
> git grep -n "/proc/fs/ext4" Documentation/
> and found that ext4 proc parameters are currently documented in both
> Documentation/admin-guide/ext4.rst and
> Documentation/filesystems/proc.rst.
>
> To be consistent with the existing documentation, I am thinking about
> documenting mb_stats in both places.
> If there are no objections, I will send a v3 shortly.
> Compared with v2,the v3 patch will add the mb_stats documentation to both
> ext4.rst and proc.rst.

Yes this makes sense to me. Feel free to retain the Reviewed-by since this is
just a documentation change.

Thanks,
Ojaswin

>
> Regards,
> Baolin
>
>
>
> 在 2026/4/21 11:40, Ritesh Harjani (IBM) 写道:
> > Andreas Dilger <adilger@xxxxxxxxx> writes:
> >
> > > On Apr 20, 2026, at 03:12, Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx> wrote:
> > > >
> > > > On Sun, Apr 19, 2026 at 02:34:36PM +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.
> > > > >
> > > > > Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
> > > > > ---
> > > > Hi Baolin, thanks for the changes.
> > > >
> > > > Seems like userspace doesn't have any way to know that writing 0 will
> > > > clear the that. Well, I guess if you are looking at this file you are
> > > > anyways debugging kernel code so that should be fine
> > >
> > > That could be documented in Documentation/filesystems/ext4/allocators.rst,
> > > or better would be to add a new file that covers mballoc in more detail.
> > >
> >
> > I started looking for ext4's control knobs for sys-admins in kernel
> > Documentation where we should ideally document this, and I see those
> > are declared here..
> >
> > Documentation/admin-guide/ext4.rst
> > Documentation/ABI/testing/sysfs-fs-ext4.rst
> >
> > Looking at this and the relevant code, I see all /proc/ entries in ext4
> > are all readable and sysfs entries for ext4 are mostly the control knobs
> > which are declared in above admin guide.
> >
> > But now this patch adds a control knob to /proc/fs/ext4/<dev>/mb_stats,
> > to clear the stats :).
> >
> > I guess we could have simply documented a new control knob value (e.g.
> > "2") for clearing the stats via /sys/fs/ext4/<dev>/mb_stats itself or
> > maybe even having mb_stats_clear file in sysfs wasn't bad either... But
> > either ways, clearing the stats via the same procfs mb_stats file is not
> > totally bad and I don't have a strong preference.
> >
> >
> > For documenting this, we can add mb_stats entry under /proc section in
> > Documentation/admin-guide/ext4.rst and document this change. Something
> > like -
> >
> > mb_stats
> > reports runtime statistics from multiblock allocator (mballoc),
> > including allocation request counts, groups scanned,
> > per-criteria scan hits (cr_p2_aligned, cr_goal_fast,
> > cr_best_avail, cr_goal_slow, cr_any_free), groups / extents
> > scanned, goal hits, buddy bitmap generations, and preallocation
> > usage etc.
> > Writing 0 to this procfs file resets all counters to zero.
> >
> >
> > -ritesh
>