f2fs: Add ckpt_thread_task sysfs node
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Chao,
Quoted 8 lines · Chao Yu
Hi Yuenan,
Thanks for your contribution!
If there is a method to get pid via userspace, I prefer to do it in userspace, rather than implementing and maintaining an duplicated one in kernel.
Or do you have a strong reason to do this in kernel?
The main reason is that retrieving this PID from userspace is currently quite complex and fragile.
Previously, userspace tools had to rely on pipelines like:
pgrep f2fs_ckpt-$(ls -l /dev/block/by-name/userdata | awk '{print $5$6}' | tr ',' ':')
This approach has a few drawbacks:
1. It requires parsing major/minor numbers and executing multiple commands, which is inefficient for simple monitoring tools.
2. On some older kernels, the thread name can be truncated due to TASK_COMM_LEN limitations, causing 'pgrep' to fail to match the full 'f2fs_ckpt-X:Y' string.
Exposing the PID via a sysfs node provides a deterministic, lightweight, and reliable way (just a simple 'cat') to fetch it without any userspace guessing or complex parsing.
Does this address your concern?
Thanks,
Yuenan
Hi Yuenan,
Quoted 15 lines · zhaoyuenan
Hi Chao,
Quoted 8 lines · Chao Yu
Hi Yuenan,
Thanks for your contribution!
If there is a method to get pid via userspace, I prefer to do it in userspace, rather than implementing and maintaining an duplicated one in kernel.
Or do you have a strong reason to do this in kernel?
The main reason is that retrieving this PID from userspace is currently quite complex and fragile.
Quoted 6 lines
Previously, userspace tools had to rely on pipelines like:
pgrep f2fs_ckpt-$(ls -l/dev/block/by-name/userdata| awk '{print $5$6}' | tr ',' ':')This approach has a few drawbacks:
1. It requires parsing major/minor numbers and executing multiple commands, which is inefficient for simple monitoring tools.
I don't see why there is any performance concern in your scenario.
Quoted 2 lines
2. On some older kernels, the thread name can be truncated due to
TASK_COMM_LENlimitations, causing 'pgrep' to fail to match the full 'f2fs_ckpt-X:Y' string.
I don't think this method has scalability, is it better to backport below patch? so that you can trace all kthreads and set them to target cgroup.
https://lore.kernel.org/all/[email protected]
Thanks,
Quoted 9 lines
Exposing the PID via a sysfs node provides a deterministic, lightweight, and reliable way (just a simple 'cat') to fetch it without any userspace guessing or complex parsing.
Does this address your concern?
Thanks,
Yuenan