From: Ivan Babrou <ivan@cloudflare.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-fsdevel@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>,
kernel-team <kernel-team@cloudflare.com>,
Andrew Morton <akpm@linux-foundation.org>,
Kalesh Singh <kaleshsingh@google.com>
Subject: Re: [RFC] proc: report open files as size in stat() for /proc/pid/fd
Date: Sat, 17 Sep 2022 11:32:04 -0700 [thread overview]
Message-ID: <CABWYdi0BF4TmwcNhwszUJ=aseOiPYVo3cR1oh9RK=6AXAxKYmQ@mail.gmail.com> (raw)
In-Reply-To: <YyXoVxS5+FUA+vat@mit.edu>
On Sat, Sep 17, 2022 at 8:31 AM Theodore Ts'o <tytso@mit.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.
prev parent reply other threads:[~2022-09-17 18:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 23:08 [RFC] proc: report open files as size in stat() for /proc/pid/fd Ivan Babrou
2022-09-17 0:01 ` Andrew Morton
2022-09-17 0:28 ` Ivan Babrou
2022-09-17 7:15 ` Alexey Dobriyan
2022-09-17 18:32 ` Ivan Babrou
2022-09-19 12:30 ` Alexey Dobriyan
2022-09-19 22:03 ` Ivan Babrou
2022-09-19 8:18 ` Christian Brauner
2022-09-17 15:31 ` Theodore Ts'o
2022-09-17 18:32 ` Ivan Babrou [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABWYdi0BF4TmwcNhwszUJ=aseOiPYVo3cR1oh9RK=6AXAxKYmQ@mail.gmail.com' \
--to=ivan@cloudflare.com \
--cc=akpm@linux-foundation.org \
--cc=kaleshsingh@google.com \
--cc=kernel-team@cloudflare.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).