Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757123Ab2F0LFV (ORCPT ); Wed, 27 Jun 2012 07:05:21 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:51189 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752048Ab2F0LFR (ORCPT ); Wed, 27 Jun 2012 07:05:17 -0400 Message-Id: <20120627110512.652322059@openvz.org> User-Agent: quilt/0.48-1 Date: Wed, 27 Jun 2012 15:01:20 +0400 From: Cyrill Gorcunov To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Cyrill Gorcunov , Al Viro , Alexey Dobriyan , Andrew Morton , Pavel Emelyanov , James Bottomley Subject: [rfc 4/7] fs, eventfd: Add procfs fdinfo helper References: <20120627110116.201735815@openvz.org> Content-Disposition: inline; filename=seq-fdinfo-eventfd-6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2521 Lines: 95 This allow us to print out raw counter value. The /proc/pid/fdinfo/fd output is | pos: 0 | flags: 04002 | eventfd-count: 5a This feature is CONFIG_CHECKPOINT_RESTORE only. Signed-off-by: Cyrill Gorcunov CC: Al Viro CC: Alexey Dobriyan CC: Andrew Morton CC: Pavel Emelyanov CC: James Bottomley --- fs/eventfd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) Index: linux-2.6.git/fs/eventfd.c =================================================================== --- linux-2.6.git.orig/fs/eventfd.c +++ linux-2.6.git/fs/eventfd.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include struct eventfd_ctx { struct kref kref; @@ -433,3 +435,56 @@ SYSCALL_DEFINE1(eventfd, unsigned int, c return sys_eventfd2(count, 0); } +#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; + return *pos == 0 ? extra->f_file : NULL; +} + +static void *seq_next(struct seq_file *m, void *p, loff_t *pos) +{ + ++*pos; + return NULL; +} + +static int seq_show(struct seq_file *m, void *v) +{ + struct eventfd_ctx *ctx = ((struct file *)v)->private_data; + + spin_lock_irq(&ctx->wqh.lock); + seq_printf(m, "eventfd-count: %16llx\n", + (unsigned long long)ctx->count); + spin_unlock_irq(&ctx->wqh.lock); + + return 0; +} + +static void seq_stop(struct seq_file *p, void *v) { } + +static const struct seq_operations eventfd_fdinfo_ops = { + .start = seq_start, + .next = seq_next, + .stop = seq_stop, + .show = seq_show, +}; + +static int is_eventfd_file(struct file *file) +{ + return file->f_op == &eventfd_fops; +} + +static struct proc_fdinfo_driver eventfd_fdinfo = { + .name = "eventfd", + .ops = &eventfd_fdinfo_ops, + .probe = is_eventfd_file, +}; + +static int __init eventfd_init(void) +{ + return proc_register_fdinfo_driver(&eventfd_fdinfo); +} +fs_initcall(eventfd_init); + +#endif /* CONFIG_PROC_FS && CONFIG_CHECKPOINT_RESTORE */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/