From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754605Ab2ILVfU (ORCPT ); Wed, 12 Sep 2012 17:35:20 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:60723 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754517Ab2ILVfQ (ORCPT ); Wed, 12 Sep 2012 17:35:16 -0400 Message-Id: <20120912213507.621405561@openvz.org> User-Agent: quilt/0.48-1 Date: Thu, 13 Sep 2012 01:29:11 +0400 From: Cyrill Gorcunov To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Al Viro Cc: Alexey Dobriyan , Andrew Morton , Pavel Emelyanov , James Bottomley , Matthew Helsley , aneesh.kumar@linux.vnet.ibm.com, bfields@fieldses.org, Cyrill Gorcunov , Al Viro Subject: [patch 5/7] fs, eventfd: Add procfs fdinfo helper References: <20120912212906.407242774@openvz.org> Content-Disposition: inline; filename=seq-fdinfo-eventfd-7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allow us to print out raw counter value. The /proc/pid/fdinfo/fd output is | pos: 0 | flags: 04002 | eventfd-count: 5a Signed-off-by: Cyrill Gorcunov CC: Pavel Emelyanov CC: Al Viro CC: Alexey Dobriyan CC: Andrew Morton CC: James Bottomley CC: "Aneesh Kumar K.V" CC: Alexey Dobriyan CC: Matthew Helsley CC: "J. Bruce Fields" CC: "Aneesh Kumar K.V" --- fs/eventfd.c | 20 ++++++++++++++++++++ 1 file changed, 20 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; @@ -284,7 +286,25 @@ static ssize_t eventfd_write(struct file return res; } +#ifdef CONFIG_PROC_FS +static int eventfd_show_fdinfo(struct seq_file *m, struct file *f) +{ + struct eventfd_ctx *ctx = f->private_data; + int ret; + + spin_lock_irq(&ctx->wqh.lock); + ret = seq_printf(m, "eventfd-count: %16llx\n", + (unsigned long long)ctx->count); + spin_unlock_irq(&ctx->wqh.lock); + + return ret; +} +#endif + static const struct file_operations eventfd_fops = { +#ifdef CONFIG_PROC_FS + .show_fdinfo = eventfd_show_fdinfo, +#endif .release = eventfd_release, .poll = eventfd_poll, .read = eventfd_read,