The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Ivan Babrou <ivan@cloudflare.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	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:31:35 -0400	[thread overview]
Message-ID: <YyXoVxS5+FUA+vat@mit.edu> (raw)
In-Reply-To: <20220916230853.49056-1-ivan@cloudflare.com>

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.

Cheers,

					- Ted

  parent reply	other threads:[~2022-09-17 15:31 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 [this message]
2022-09-17 18:32   ` Ivan Babrou

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=YyXoVxS5+FUA+vat@mit.edu \
    --to=tytso@mit.edu \
    --cc=akpm@linux-foundation.org \
    --cc=ivan@cloudflare.com \
    --cc=kaleshsingh@google.com \
    --cc=kernel-team@cloudflare.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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