All of lore.kernel.org
 help / color / mirror / Atom feed
* + taskstats-add-e-u-stime-for-tgid-command.patch added to -mm tree
@ 2017-03-06 22:40 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2017-03-06 22:40 UTC (permalink / raw)
  To: xiao.zhang, bsingharora, oleg, mm-commits


The patch titled
     Subject: taskstats: add e/u/stime for TGID command
has been added to the -mm tree.  Its filename is
     taskstats-add-e-u-stime-for-tgid-command.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/taskstats-add-e-u-stime-for-tgid-command.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/taskstats-add-e-u-stime-for-tgid-command.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Zhang Xiao <xiao.zhang@windriver.com>
Subject: taskstats: add e/u/stime for TGID command

The elapsed time, user CPU time and system CPU time for the thread group
status request are presently left at zero.  Fill these in.

Link: http://lkml.kernel.org/r/1488508424-12322-1-git-send-email-xiao.zhang@windriver.com
Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/taskstats.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff -puN kernel/taskstats.c~taskstats-add-e-u-stime-for-tgid-command kernel/taskstats.c
--- a/kernel/taskstats.c~taskstats-add-e-u-stime-for-tgid-command
+++ a/kernel/taskstats.c
@@ -210,6 +210,7 @@ static int fill_stats_for_tgid(pid_t tgi
 	struct task_struct *tsk, *first;
 	unsigned long flags;
 	int rc = -ESRCH;
+	u64 delta, utime, stime;
 
 	/*
 	 * Add additional stats from live tasks except zombie thread group
@@ -238,6 +239,16 @@ static int fill_stats_for_tgid(pid_t tgi
 		 */
 		delayacct_add_tsk(stats, tsk);
 
+		/* calculate task elapsed time in nsec */
+		delta = ktime_get_ns() - tsk->start_time;
+		/* Convert to micro seconds */
+		do_div(delta, NSEC_PER_USEC);
+		stats->ac_etime += delta;
+
+		task_cputime(tsk, &utime, &stime);
+		stats->ac_utime += div_u64(utime, NSEC_PER_USEC);
+		stats->ac_stime += div_u64(stime, NSEC_PER_USEC);
+
 		stats->nvcsw += tsk->nvcsw;
 		stats->nivcsw += tsk->nivcsw;
 	} while_each_thread(first, tsk);
_

Patches currently in -mm which might be from xiao.zhang@windriver.com are

taskstats-add-e-u-stime-for-tgid-command.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-07  0:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-06 22:40 + taskstats-add-e-u-stime-for-tgid-command.patch added to -mm tree akpm

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.