Re: [PATCH 1/2 v2] fdmap(2)
From: Andy Lutomirski <luto@amacapital.net>
Date: 2017-09-24 21:31:47
Also in:
lkml
On Sun, Sep 24, 2017 at 1:06 PM, Alexey Dobriyan [off-list ref] wrote:
From: Aliaksandr Patseyenak <redacted>
Implement system call for bulk retrieveing of opened descriptors
in binary form.
Some daemons could use it to reliably close file descriptors
before starting. Currently they close everything upto some number
which formally is not reliable. Other natural users are lsof(1) and CRIU
(although lsof does so much in /proc that the effect is thoroughly buried).
/proc, the only way to learn anything about file descriptors may not be
available. There is unavoidable overhead associated with instantiating
3 dentries and 3 inodes and converting integers to strings and back.
Benchmark:
N=1<<22 times
4 opened descriptors (0, 1, 2, 3)
opendir+readdir+closedir /proc/self/fd vs fdmap
/proc 8.31 ą 0.37%
fdmap 0.32 ą 0.72%This doesn't have the semantic problem that pidmap does, but I still wonder why this can't be accomplished by adding a new file in /proc.