[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABWYdi0BF4TmwcNhwszUJ=aseOiPYVo3cR1oh9RK=6AXAxKYmQ@mail.gmail.com>
Date: Sat, 17 Sep 2022 11:32:04 -0700
From: Ivan Babrou <ivan@...udflare.com>
To: "Theodore Ts'o" <tytso@....edu>
Cc: linux-fsdevel@...r.kernel.org,
linux-kernel <linux-kernel@...r.kernel.org>,
kernel-team <kernel-team@...udflare.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Kalesh Singh <kaleshsingh@...gle.com>
Subject: Re: [RFC] proc: report open files as size in stat() for /proc/pid/fd
On Sat, Sep 17, 2022 at 8:31 AM Theodore Ts'o <tytso@....edu> wrote:
>
> On Fri, Sep 16, 2022 at 04:08:52PM -0700, Ivan Babrou wrote:
> > We considered putting the number of open files in /proc/pid/stat.
> > Unfortunately, counting the number of fds involves iterating the fdtable,
> > which means that it might slow down /proc/pid/stat for processes
> > with many open files. Instead we opted to put this info in /proc/pid/fd
> > as a size member of the stat syscall result. Previously the reported
> > number was zero, so there's very little risk of breaking anything,
> > while still providing a somewhat logical way to count the open files.
>
> Instead of using the st_size of /proc/<pid>/fd, why not return that
> value in st_nlink? /proc/<pid>/fd is a directory, so having st_nlinks
> return number of fd's plus 2 (for . and ..) would be much more natural.
>From what I see, st_nlinks is used for the number of subdirectories
and it doesn't include files. In /proc/fd we only have files (well,
symlinks really). I'm still happy to use that instead if that's
preferred.
Powered by blists - more mailing lists