From: alexander.shishckin@gmail.com
To: linux-fsdevel@vger.kernel.org
Cc: Alexander Shishkin <alexander.shishckin@gmail.com>
Subject: [PATCH] [RFC] List per-process file descriptor consumption when hitting file-max
Date: Mon, 8 Jun 2009 14:38:42 +0300 [thread overview]
Message-ID: <1244461122-3303-1-git-send-email-alexander.shishckin@gmail.com> (raw)
From: Alexander Shishkin <alexander.shishckin@gmail.com>
When a file descriptor limit is hit, it might be useful to see all the
users to be able to identify those that leak descriptors.
Signed-off-by: Alexander Shishkin <alexander.shishckin@gmail.com>
---
fs/file_table.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/fs/file_table.c b/fs/file_table.c
index 54018fe..9e53167 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -136,8 +136,35 @@ struct file *get_empty_filp(void)
over:
/* Ran out of filps - report that */
if (get_nr_files() > old_max) {
+ struct task_struct *p;
+ struct files_struct *files;
+ struct fdtable *fdt;
+ int i, count = 0;
+
printk(KERN_INFO "VFS: file-max limit %d reached\n",
get_max_files());
+
+ read_lock(&tasklist_lock);
+ for_each_process(p) {
+ files = get_files_struct(p);
+ if (!files)
+ continue;
+
+ spin_lock(&files->file_lock);
+ fdt = files_fdtable(files);
+
+ /* we have to actually *count* the fds */
+ for (count = i = 0; i < fdt->max_fds; i++)
+ count += !!fcheck_files(files, i);
+
+ printk(KERN_INFO "=> %s [%d]: %d\n", p->comm,
+ p->pid, count);
+
+ spin_unlock(&files->file_lock);
+ put_files_struct(files);
+ }
+ read_unlock(&tasklist_lock);
+
old_max = get_nr_files();
}
goto fail;
--
1.6.1.3
next reply other threads:[~2009-06-08 11:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 11:38 alexander.shishckin [this message]
2009-07-29 16:17 ` [PATCH] [RFC] List per-process file descriptor consumption when hitting file-max Alexander Shishkin
2009-07-30 12:40 ` Valdis.Kletnieks
2009-10-11 12:17 ` Alexander Shishkin
2010-01-10 16:34 ` [RFC][PATCHv2] " Alexander Shishkin
2010-01-13 22:12 ` Andrew Morton
2010-01-11 9:38 ` [RFC][PATCHv3] " Alexander Shishkin
2010-01-11 12:40 ` Andreas Dilger
2010-01-13 22:06 ` Andi Kleen
2010-01-13 22:44 ` Al Viro
2010-01-13 22:57 ` Al Viro
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=1244461122-3303-1-git-send-email-alexander.shishckin@gmail.com \
--to=alexander.shishckin@gmail.com \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).