From: Cyrill Gorcunov <gorcunov@openvz.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Alexey Dobriyan <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Pavel Emelyanov <xemul@parallels.com>,
James Bottomley <jbottomley@parallels.com>,
Matthew Helsley <matt.helsley@gmail.com>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: [patch 5/8] fs, epoll: Add procfs fdinfo helper v2
Date: Tue, 14 Aug 2012 18:03:47 +0400 [thread overview]
Message-ID: <20120814140620.191720208@openvz.org> (raw)
In-Reply-To: 20120814140342.354405844@openvz.org
[-- Attachment #1: seq-fdinfo-eventpoll-5 --]
[-- Type: text/plain, Size: 3033 bytes --]
This allow us to print out eventpoll target file descriptor,
events and data, the /proc/pid/fdinfo/fd consists of
| pos: 0
| flags: 02
| tfd: 5 events: 1d data: ffffffffffffffff
This feature is CONFIG_CHECKPOINT_RESTORE only.
v2:
- don't walk over all rb nodes on seq-next,
try to continue from pervious position
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Al Viro <viro@ZenIV.linux.org.uk>
CC: Alexey Dobriyan <adobriyan@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: James Bottomley <jbottomley@parallels.com>
CC: Matthew Helsley <matt.helsley@gmail.com>
---
fs/eventpoll.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
Index: linux-2.6.git/fs/eventpoll.c
===================================================================
--- linux-2.6.git.orig/fs/eventpoll.c
+++ linux-2.6.git/fs/eventpoll.c
@@ -38,6 +38,8 @@
#include <asm/io.h>
#include <asm/mman.h>
#include <linux/atomic.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
/*
* LOCKING:
@@ -1897,6 +1899,69 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd,
return error;
}
+#if defined(CONFIG_PROC_FS) && defined(CONFIG_CHECKPOINT_RESTORE)
+
+static void *seq_start(struct seq_file *m, loff_t *pos)
+{
+ struct proc_fdinfo_extra *extra = m->private;
+ struct eventpoll *ep = extra->f_file->private_data;
+ struct rb_node *rbp;
+ loff_t num = *pos;
+
+ mutex_lock(&ep->mtx);
+ for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
+ if (num-- == 0)
+ return rbp;
+ }
+
+ return NULL;
+}
+
+static void seq_stop(struct seq_file *m, void *v)
+{
+ struct proc_fdinfo_extra *extra = m->private;
+ struct eventpoll *ep = extra->f_file->private_data;
+ mutex_unlock(&ep->mtx);
+}
+
+static void *seq_next(struct seq_file *m, void *p, loff_t *pos)
+{
+ struct rb_node *rbp = p;
+ ++*pos;
+ return (void *)rb_next(rbp);
+}
+
+static int seq_show(struct seq_file *m, void *v)
+{
+ struct rb_node *rbp = v;
+ struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
+
+ return seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
+ epi->ffd.fd, epi->event.events,
+ (long long)epi->event.data);
+}
+
+static const struct seq_operations ep_fdinfo_ops = {
+ .start = seq_start,
+ .next = seq_next,
+ .stop = seq_stop,
+ .show = seq_show,
+};
+
+static struct proc_fdinfo_driver ep_fdinfo = {
+ .name = "eventpoll",
+ .ops = &ep_fdinfo_ops,
+ .probe = is_file_epoll,
+};
+
+static int __init ep_register_fdinfo_driver(void)
+{
+ return proc_register_fdinfo_driver(&ep_fdinfo);
+}
+#else
+static void ep_register_fdinfo_driver(void) { }
+#endif /* CONFIG_PROC_FS && CONFIG_CHECKPOINT_RESTORE */
+
static int __init eventpoll_init(void)
{
struct sysinfo si;
@@ -1929,6 +1994,8 @@ static int __init eventpoll_init(void)
pwq_cache = kmem_cache_create("eventpoll_pwq",
sizeof(struct eppoll_entry), 0, SLAB_PANIC, NULL);
+ ep_register_fdinfo_driver();
+
return 0;
}
fs_initcall(eventpoll_init);
next prev parent reply other threads:[~2012-08-14 14:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-14 14:03 [patch 0/8] procfs fdinfo providers updated Cyrill Gorcunov
2012-08-14 14:03 ` [patch 1/8] procfs: Move /proc/pid/fd[info] handling code to fd.[ch] Cyrill Gorcunov
2012-08-14 14:21 ` Pavel Emelyanov
2012-08-14 14:03 ` [patch 2/8] procfs: Convert /proc/pid/fdinfo/ handling routines to seq-file Cyrill Gorcunov
2012-08-14 14:21 ` Pavel Emelyanov
2012-08-14 14:03 ` [patch 3/8] procfs: Add ability to plug in auxiliary fdinfo providers Cyrill Gorcunov
2012-08-14 14:22 ` Pavel Emelyanov
2012-08-14 18:31 ` Al Viro
2012-08-14 18:35 ` Cyrill Gorcunov
2012-08-14 19:56 ` Cyrill Gorcunov
2012-08-14 21:27 ` Al Viro
2012-08-14 21:56 ` Cyrill Gorcunov
2012-08-14 22:21 ` Cyrill Gorcunov
2012-08-15 0:07 ` Al Viro
2012-08-15 7:40 ` Cyrill Gorcunov
2012-08-14 14:03 ` [patch 4/8] fs, eventfd: Add procfs fdinfo helper Cyrill Gorcunov
2012-08-14 14:22 ` Pavel Emelyanov
2012-08-14 14:03 ` Cyrill Gorcunov [this message]
2012-08-14 14:22 ` [patch 5/8] fs, epoll: Add procfs fdinfo helper v2 Pavel Emelyanov
2012-08-14 14:03 ` [patch 6/8] fs, exportfs: Add export_encode_inode_fh helper Cyrill Gorcunov
2012-08-14 14:23 ` Pavel Emelyanov
2012-08-14 14:03 ` [patch 7/8] fs, notify: Add procfs fdinfo helper v3 Cyrill Gorcunov
2012-08-14 14:23 ` Pavel Emelyanov
2012-08-14 14:03 ` [patch 8/8] fdinfo: Show sigmask for signalfd fd Cyrill Gorcunov
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=20120814140620.191720208@openvz.org \
--to=gorcunov@openvz.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jbottomley@parallels.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.helsley@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@parallels.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.