Re: [PATCH v4 v4 0/3] ext4: improve mballoc statistics reporting and control

From: liubaolin

Date: Fri May 08 2026 - 06:32:20 EST


Dear Ted, Baokun,

I have revised the patch according to your previous comments.
There are three additional points I would like to clarify:
1.Ted, you previously suggested considering concurrency issues.
After thinking about it, I decided to use an atomic variable for s_mb_stats to address the concurrency problem.
Using a spinlock would require much larger code changes.

2.Regarding the modification to Documentation/filesystems/proc.rst, I previously sent an email to Jonathan, the maintainer of proc.rst:
https://lore.kernel.org/all/87ik9bmphp.fsf@xxxxxxxxxxxxxx/
Jonathan replied and agreed with my idea that it is sufficient to simply add the following note in proc.rst:
“See Documentation/admin-guide/ext4.rst for ext4-specific /proc entries.”
If you also agree, Ted, then in the future we will no longer duplicate ext4 proc file documentation in proc.rst.
All ext4 proc file related documentation will instead be maintained centrally in Documentation/admin-guide/ext4.rst.

3.The functionality of the sys mb_stats file will be retained,
but the following note will be added to Documentation/ABI/testing/sysfs-fs-ext4:
“This sysfs entry is deprecated, and users should prefer /proc/fs/ext4//mb_stats.”

Thank you for your comments and reviews.

Thanks,
Baolin

在 2026/5/8 17:34, Baolin Liu 写道:
This series improves ext4 mballoc statistics reporting and control.
Compared with v3, this version adds a new patch to convert s_mb_stats
to atomic_t and use atomic operations for its accesses, so as to avoid
potential concurrent accesses to this variable.

Patch 3 is updated according to comments from Ted and BaoKun. Writing 0
to /proc/fs/ext4/<dev>/mb_stats disables statistics collection, writing
1 enables it, and writing -1 clears the current statistics and enables
collection. The related documentation is updated accordingly, and the
sysfs mb_stats entry is documented as deprecated in favor of the proc
mb_stats entry.

Changes since v3:
- add a new patch to convert s_mb_stats to atomic_t and use atomic
operations for its accesses
- update /proc/fs/ext4/<dev>/mb_stats write semantics based on comments
from Ted and BaoKun
- update related documentation and document sysfs mb_stats as deprecated

Baolin Liu (3):
ext4: add blocks_allocated to mb_stats output
ext4: use atomic operations for s_mb_stats accesses
ext4: allow controlling mballoc stats through proc mb_stats

Documentation/ABI/testing/sysfs-fs-ext4 | 3 +-
Documentation/admin-guide/ext4.rst | 9 +++-
Documentation/filesystems/proc.rst | 13 +-----
fs/ext4/ext4.h | 3 +-
fs/ext4/mballoc.c | 57 +++++++++++++++++++------
fs/ext4/sysfs.c | 55 ++++++++++++++++++++++--
6 files changed, 109 insertions(+), 31 deletions(-)