From: Venkatesh Pallipadi <venki@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Paul Menage <menage@google.com>
Cc: linux-kernel@vger.kernel.org, Paul Turner <pjt@google.com>,
Venkatesh Pallipadi <venki@google.com>
Subject: [RFC PATCH 4/4] sched: Export irq times through cpuacct cgroup
Date: Mon, 24 May 2010 17:11:22 -0700 [thread overview]
Message-ID: <1274746282-21533-5-git-send-email-venki@google.com> (raw)
In-Reply-To: <1274746282-21533-4-git-send-email-venki@google.com>
Adds hi_time, si_time, hi_time_percpu and si_time_percpu info in cpuacct
cgroup.
The info will be fine granularity timings when either
CONFIG_IRQ_TIME_ACCOUNTING or CONFIG_VIRT_CPU_ACCOUNTING is enabled.
Otherwise the info will be based on tick samples.
Looked at adding this under cpuacct.stat. But, this information is useful
to the administrator in percpu format, so that any hi or si activity
on a particular CPU can be noted and some config change
(move the irq away, assign a different CPU to this cgroup, etc)
may be done based on that info.
Signed-off-by: Venkatesh Pallipadi <venki@google.com>
---
kernel/sched.c | 55 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index d7d7efe..19e4d5d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1404,6 +1404,8 @@ enum cpuacct_stat_index {
enum cpuacct_charge_index {
CPUACCT_CHARGE_USAGE, /* ... execution time */
+ CPUACCT_CHARGE_SI_TIME, /* ... softirq time */
+ CPUACCT_CHARGE_HI_TIME, /* ... hardirq time */
CPUACCT_CHARGE_NCHARGES,
};
@@ -3238,9 +3240,15 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime,
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
/* In this case, we charge the task at irq time for finer accounting */
-#define TASK_IRQ_CHARGE_AT_TICK(x, y) (x)
+static inline void task_cpuacct_irq_charge(struct task_struct *p,
+ cputime64_t *ptime, int idx, cputime64_t delta) { }
#else
-#define TASK_IRQ_CHARGE_AT_TICK(x, y) cputime64_add(x, y)
+static inline void task_cpuacct_irq_charge(struct task_struct *p,
+ cputime64_t *ptime, int idx, cputime64_t delta)
+{
+ *ptime = cputime64_add(*ptime, delta);
+ cpuacct_charge(p, idx, delta);
+}
#endif
/*
@@ -3270,10 +3278,12 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
tmp = cputime_to_cputime64(cputime);
if (hardirq_count() - hardirq_offset) {
cpustat->irq = cputime64_add(cpustat->irq, tmp);
- p->hi_time = TASK_IRQ_CHARGE_AT_TICK(p->hi_time, tmp);
+ task_cpuacct_irq_charge(p, &p->hi_time,
+ CPUACCT_CHARGE_HI_TIME, tmp);
} else if (softirq_count()) {
cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
- p->si_time = TASK_IRQ_CHARGE_AT_TICK(p->si_time, tmp);
+ task_cpuacct_irq_charge(p, &p->si_time,
+ CPUACCT_CHARGE_SI_TIME, tmp);
} else {
cpustat->system = cputime64_add(cpustat->system, tmp);
}
@@ -8832,6 +8842,28 @@ static struct cftype files[] = {
.private = CPUACCT_CHARGE_USAGE,
},
{
+ .name = "si_time",
+ .read_u64 = cpuusage_read,
+ .write_u64 = cpuusage_write,
+ .private = CPUACCT_CHARGE_SI_TIME,
+ },
+ {
+ .name = "si_time_percpu",
+ .read_seq_string = cpuacct_percpu_seq_read,
+ .private = CPUACCT_CHARGE_SI_TIME,
+ },
+ {
+ .name = "hi_time",
+ .read_u64 = cpuusage_read,
+ .write_u64 = cpuusage_write,
+ .private = CPUACCT_CHARGE_HI_TIME,
+ },
+ {
+ .name = "hi_time_percpu",
+ .read_seq_string = cpuacct_percpu_seq_read,
+ .private = CPUACCT_CHARGE_HI_TIME,
+ },
+ {
.name = "stat",
.read_map = cpuacct_stats_show,
},
@@ -8996,17 +9028,20 @@ void account_system_vtime(struct task_struct *tsk)
{
unsigned long flags;
int cpu;
- u64 now;
+ u64 now, delta;
local_irq_save(flags);
cpu = task_cpu(tsk);
now = sched_clock_cpu(cpu);
- if (hardirq_count())
- tsk->hi_time += now - per_cpu(irq_start_time, cpu);
- else if (softirq_count())
- tsk->si_time += now - per_cpu(irq_start_time, cpu);
-
+ delta = now - per_cpu(irq_start_time, cpu);
per_cpu(irq_start_time, cpu) = now;
+ if (hardirq_count()) {
+ tsk->hi_time += delta;
+ cpuacct_charge(tsk, CPUACCT_CHARGE_HI_TIME, delta);
+ } else if (softirq_count()) {
+ tsk->si_time += delta;
+ cpuacct_charge(tsk, CPUACCT_CHARGE_SI_TIME, delta);
+ }
local_irq_restore(flags);
}
--
1.7.0.1
next prev parent reply other threads:[~2010-05-25 0:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-25 0:11 [RFC PATCH 0/4] Finer granularity and task/cgroup irq time accounting Venkatesh Pallipadi
2010-05-25 0:11 ` [RFC PATCH 1/4] sched: Track and export per task [hard|soft]irq time Venkatesh Pallipadi
2010-05-25 0:11 ` [RFC PATCH 2/4] x86: Add IRQ_TIME_ACCOUNTING, finer accounting of irq time to task Venkatesh Pallipadi
2010-05-25 0:11 ` [RFC PATCH 3/4] sched: Generalize cpuacct usage tracking making it simpler to add new stats Venkatesh Pallipadi
2010-05-25 0:11 ` Venkatesh Pallipadi [this message]
2010-05-25 6:35 ` [RFC PATCH 2/4] x86: Add IRQ_TIME_ACCOUNTING, finer accounting of irq time to task Peter Zijlstra
2010-05-25 21:40 ` Venkatesh Pallipadi
2010-05-26 6:54 ` Peter Zijlstra
2010-05-25 9:13 ` [RFC PATCH 1/4] sched: Track and export per task [hard|soft]irq time Balbir Singh
2010-05-25 21:45 ` Venkatesh Pallipadi
2010-05-25 7:00 ` [RFC PATCH 0/4] Finer granularity and task/cgroup irq time accounting Balbir Singh
2010-05-25 8:14 ` Peter Zijlstra
2010-05-25 17:05 ` Venkatesh Pallipadi
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=1274746282-21533-5-git-send-email-venki@google.com \
--to=venki@google.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=tglx@linutronix.de \
/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