mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Ballard <dan@mindstab.net>
To: peterz@infradead.org, Lennart Poettering <lennart@poettering.net>,
	kay.sievers@vrfy.org, Rob Landley <rob@landley.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Minto Joseph <mvaliyav@redhat.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Pavel Emelyanov <xemul@parallels.com>,
	Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Rik van Riel <riel@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Mel Gorman <mgorman@suse.de>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] v2 add StartTimeMonotomic, StartTimeBootTime to per pid  in  /proc
Date: Fri, 31 Jan 2014 07:38:26 -0800	[thread overview]
Message-ID: <7a44eaa41ee1e784a52924c595942617@mindstab.net> (raw)

starttime in /proc/$PID/stat is inaccurate by "clock tick" granularity.
The process starttime is useful for a variety of things, like figuring
out creation ordering of processes and it is useful to detect PID
reuses in a somewhat reliable way.

The kernel internally stores finer granularity values and this patch
exports them in the easily usable location /prod/$PID/status
as StartTimeMonotonic and StartTimeBootTime.

Signed-off-by: Dan Ballard <dan@mindstab.net>
---
  Documentation/filesystems/proc.txt |    6 +++++-
  fs/proc/array.c                    |    8 ++++++--
  2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/filesystems/proc.txt 
b/Documentation/filesystems/proc.txt
index 22d89aa3..6ed8001 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -158,6 +158,8 @@ read the file /proc/PID/status:
    TracerPid:      0                                            (2.4)
    Uid:    501     501     501     501
    Gid:    100     100     100     100
+  StartTimeMonotonic:     3766799643
+  StartTimeBootTime:      3766799643
    FDSize: 256
    Groups: 100 14 16
    VmPeak:     5004 kB
@@ -202,7 +204,7 @@ asynchronous manner and the vaule may not be very 
precise. To see a precise
  snapshot of a moment, you can see /proc/<pid>/smaps file and scan page 
table.
  It's slow but very precise.

-Table 1-2: Contents of the status files (as of 2.6.30-rc7)
+Table 1-2: Contents of the status files (as of 3.13.0-rc3)

..............................................................................
   Field                       Content
   Name                        filename of the executable
@@ -215,6 +217,8 @@ Table 1-2: Contents of the status files (as of 
2.6.30-rc7)
   TracerPid                   PID of process tracing this process (0 if 
not)
   Uid                         Real, effective, saved set, and  file 
system UIDs
   Gid                         Real, effective, saved set, and  file 
system GIDs
+ StartTimeMonotonic          Start time of process in nsec from 
CLOCK_MONOTONIC
+ StartTimeBootTime           Start time of process in nsec from 
CLOCK_BOOTTIME
   FDSize                      number of file descriptor slots currently 
allocated
   Groups                      supplementary group list
   VmPeak                      peak virtual memory size
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 1bd2077..34f4761 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -188,7 +188,9 @@ static inline void task_state(struct seq_file *m, 
struct pid_namespace *ns,
                 "PPid:\t%d\n"
                 "TracerPid:\t%d\n"
                 "Uid:\t%d\t%d\t%d\t%d\n"
-               "Gid:\t%d\t%d\t%d\t%d\n",
+               "Gid:\t%d\t%d\t%d\t%d\n"
+               "StartTimeMonotonic:\t%lld\n"
+               "StartTimeBootTime:\t%lld\n",
                 get_task_state(p),
                 task_tgid_nr_ns(p, ns),
                 task_numa_group_id(p),
@@ -201,7 +203,9 @@ static inline void task_state(struct seq_file *m, 
struct pid_namespace *ns,
                 from_kgid_munged(user_ns, cred->gid),
                 from_kgid_munged(user_ns, cred->egid),
                 from_kgid_munged(user_ns, cred->sgid),
-               from_kgid_munged(user_ns, cred->fsgid));
+               from_kgid_munged(user_ns, cred->fsgid),
+               timespec_to_ns(&p->start_time),
+               timespec_to_ns(&p->real_start_time));

         task_lock(p);
         if (p->files)
-- 
1.7.10.4

             reply	other threads:[~2014-01-31 15:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 15:38 Dan Ballard [this message]
2014-02-04 20:33 ` Thomas Gleixner

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=7a44eaa41ee1e784a52924c595942617@mindstab.net \
    --to=dan@mindstab.net \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=gorcunov@openvz.org \
    --cc=kay.sievers@vrfy.org \
    --cc=lennart@poettering.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mvaliyav@redhat.com \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=rob@landley.net \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®