From patchwork Wed Apr 22 10:24:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Naveen N. Rao" X-Patchwork-Id: 463639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D857514007D for ; Wed, 22 Apr 2015 20:25:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbbDVKZH (ORCPT ); Wed, 22 Apr 2015 06:25:07 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:48092 "EHLO e28smtp02.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751697AbbDVKZB (ORCPT ); Wed, 22 Apr 2015 06:25:01 -0400 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Apr 2015 15:54:58 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp02.in.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 22 Apr 2015 15:54:55 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 89C7DE0061; Wed, 22 Apr 2015 15:57:33 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay02.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3MAOrP852035618; Wed, 22 Apr 2015 15:54:53 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3MAOqNB029129; Wed, 22 Apr 2015 15:54:53 +0530 Received: from naverao1-tp.in.ibm.com (naverao1-tp.in.ibm.com [9.124.35.83]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t3MAOpDq029034; Wed, 22 Apr 2015 15:54:52 +0530 From: "Naveen N. Rao" To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: paulus@samba.org, mpe@ellerman.id.au, agraf@suse.de, mingo@redhat.com, ego@linux.vnet.ibm.com Subject: [RFC PATCH 1/3] procfs: add guest steal time in /proc//stat Date: Wed, 22 Apr 2015 15:54:34 +0530 Message-Id: <4201f462f6e0ce67a7c822e62999ac58e59f3ffd.1429696326.git.naveen.n.rao@linux.vnet.ibm.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: References: In-Reply-To: References: X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15042210-0005-0000-0000-000004E653E4 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Introduce a field in /proc//stat to expose guest steal time. Signed-off-by: Naveen N. Rao --- fs/proc/array.c | 6 ++++++ include/linux/sched.h | 7 +++++++ kernel/fork.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 1295a00..d86f00e 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -363,6 +363,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, unsigned long rsslim = 0; char tcomm[sizeof(task->comm)]; unsigned long flags; + cputime_t gstime; state = *get_task_state(task); vsize = eip = esp = 0; @@ -382,6 +383,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, sigemptyset(&sigcatch); cutime = cstime = utime = stime = 0; cgtime = gtime = 0; + gstime = 0; if (lock_task_sighand(task, &flags)) { struct signal_struct *sig = task->signal; @@ -410,6 +412,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, min_flt += t->min_flt; maj_flt += t->maj_flt; gtime += task_gtime(t); + gstime += task_gstime(t); } while_each_thread(task, t); min_flt += sig->min_flt; @@ -432,6 +435,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, maj_flt = task->maj_flt; task_cputime_adjusted(task, &utime, &stime); gtime = task_gtime(task); + gstime = task_gstime(task); } /* scale priority and nice values from timeslices to -20..20 */ @@ -505,6 +509,8 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, else seq_put_decimal_ll(m, ' ', 0); + seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gstime)); + seq_putc(m, '\n'); if (mm) mmput(mm); diff --git a/include/linux/sched.h b/include/linux/sched.h index 0eabab9..cb57954 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1429,6 +1429,7 @@ struct task_struct { cputime_t utime, stime, utimescaled, stimescaled; cputime_t gtime; + cputime_t gstime; #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE struct cputime prev_cputime; #endif @@ -1955,6 +1956,12 @@ static inline cputime_t task_gtime(struct task_struct *t) return t->gtime; } #endif + +static inline cputime_t task_gstime(struct task_struct *t) +{ + return t->gstime; +} + extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); diff --git a/kernel/fork.c b/kernel/fork.c index cf65139..529ebe5 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1293,7 +1293,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, init_sigpending(&p->pending); - p->utime = p->stime = p->gtime = 0; + p->utime = p->stime = p->gtime = p->gstime = 0; p->utimescaled = p->stimescaled = 0; #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE p->prev_cputime.utime = p->prev_cputime.stime = 0;