Skip to content

Rework file::show_fdinfo method to use seq-files engine, v2

Cyrill Gorcunov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7seq-file: Export single_ helpersfs/seq_file.c include/linux/seq_file.h+9 -32 replies
2/7procfs: Introduce sequential fdinfo enginefs/proc/fd.c include/linux/fs.h+109 -330 replies
3/7epoll: Use sequential fdinfo enginefs/eventpoll.c+34 -120 replies
4/7eventfd: Use sequential fdinfo enginefs/eventfd.c+12 -70 replies
5/7signalfd: Use sequential fdinfo enginefs/signalfd.c+10 -30 replies
6/7fsnotify: Use sequential fdinfo enginefs/notify/fanotify/fanotify_user.c fs/notify/fdinfo.c fs/notify/fdinfo.h +1 more+116 -710 replies
7/7procfs: Drop legacy show_fdinfo file operationfs/proc/fd.c include/linux/fs.h+0 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [patch 0/7] Rework file::show_fdinfo method to use seq-files engine, v2

Hi, in criu we intensively use additional information provided by /proc/<pid>/fdinfo/<fd> particular to the object opened file represents. The output is printed out by calling the file_operations::show_fdinfo method.

The implementation implies that data is getting printed in one pass and returns error in case if seq buffer is overflowed, which works fine while data fit one memory page. For epoll it's about 73 epoll targets can be printed, for notify system -- significantly less depending on notify type and file handler. This limitation didn't cause any problems in applications we're checkpointing and restoring at moment, but might become a problem in future.

So to resolve the problem I considered two ways

1) Don't return error if seq-buffer overflowed thus, one show() method is called the kernel will notice that buffer is overflowed and double its size returning -EAGAIN. But I fear such interface might be misused (say process creates epoll with a number of target descriptors, then application opens a big number of fdinfo reader causing kernel to allocate big seq-buffer for each reader).

2) Instead of printing fdinfo in one pass rather provide seq-operations pointer in file_operations, and subsystems which need it simply hook own seq-operations here. The main code in fs/proc/fd.c will call for underlied seq-operation methods.

The second way looks more preferrable from my POV, here is the series. Please take a look, thanks. Any comments are highly appreciated!