linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave.bueso@gmail.com>
To: torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [RFC] [PATCH procfs] Add process age
Date: Fri, 23 Jul 2010 13:47:51 -0400	[thread overview]
Message-ID: <1279907271.4335.3.camel@cowboy> (raw)

Hi,

This patch exports a process's age, in seconds, adding a /proc/#/age file.

Thanks,
Davidlohr

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 fs/proc/base.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index acb7ef8..a5a4832 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -38,13 +38,16 @@
  *  ChangeLog:
  *  10-Mar-2005
  *  10LE Instituto Nokia de Tecnologia - INdT:
- *  A better way to walks through the page table as suggested by Hugh Dickins.
+ *  A better way to walk through the page table as suggested by Hugh Dickins.
  *
  *  Simo Piiroinen <simo.piiroinen@nokia.com>:
  *  Smaps information related to shared, private, clean and dirty pages.
  *
  *  Paul Mundt <paul.mundt@nokia.com>:
  *  Overall revision about smaps.
+ *
+ *  2010 - Davidlohr Bueso <dave@gnu.org>:
+ *  Added process age (/proc/#/age), in seconds.
  */
 
 #include <asm/uaccess.h>
@@ -2558,6 +2561,18 @@ static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns,
 	return 0;
 }
 
+static int proc_pid_age(struct seq_file *m, struct pid_namespace *ns,
+			struct pid *pid, struct task_struct *task)
+{
+	struct timespec uptime;
+
+	do_posix_clock_monotonic_gettime(&uptime);
+	monotonic_to_bootbased(&uptime);
+	seq_printf(m, "%lu\n", uptime.tv_sec - task->real_start_time.tv_sec);
+
+	return 0;
+}
+
 /*
  * Thread groups
  */
@@ -2575,6 +2590,7 @@ static const struct pid_entry tgid_base_stuff[] = {
 	INF("auxv",       S_IRUSR, proc_pid_auxv),
 	ONE("status",     S_IRUGO, proc_pid_status),
 	ONE("personality", S_IRUSR, proc_pid_personality),
+	ONE("age",        S_IRUSR, proc_pid_age),
 	INF("limits",	  S_IRUSR, proc_pid_limits),
 #ifdef CONFIG_SCHED_DEBUG
 	REG("sched",      S_IRUGO|S_IWUSR, proc_pid_sched_operations),
@@ -2910,6 +2926,7 @@ static const struct pid_entry tid_base_stuff[] = {
 	INF("auxv",      S_IRUSR, proc_pid_auxv),
 	ONE("status",    S_IRUGO, proc_pid_status),
 	ONE("personality", S_IRUSR, proc_pid_personality),
+	ONE("age",        S_IRUSR, proc_pid_age),
 	INF("limits",	 S_IRUSR, proc_pid_limits),
 #ifdef CONFIG_SCHED_DEBUG
 	REG("sched",     S_IRUGO|S_IWUSR, proc_pid_sched_operations),
-- 
1.7.0.4


             reply	other threads:[~2010-07-23 17:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-23 17:47 Davidlohr Bueso [this message]
2010-07-23 18:35 ` [RFC] [PATCH procfs] Add process age Alexey Dobriyan
2010-07-23 18:47   ` Davidlohr Bueso
2010-07-23 23:16     ` Sergey V.
2010-07-26  7:47     ` Andi Kleen
2010-07-26 13:57       ` Davidlohr Bueso
2010-07-26 14:48         ` Andi Kleen
2010-07-26 15:10           ` Davidlohr Bueso
2010-07-28  6:56             ` Américo Wang
2010-07-30 14:58               ` Davidlohr Bueso

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=1279907271.4335.3.camel@cowboy \
    --to=dave.bueso@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).