From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: Fernando Luis Vazquez Cao <fernando_b1@lab.ntt.co.jp>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Oleg Nesterov <oleg@redhat.com>,
Preeti U Murthy <preeti@linux.vnet.ibm.com>,
Denys Vlasenko <vda.linux@googlemail.com>
Subject: [PATCH 5/8] cputime, ia64: update iowait accounting
Date: Thu, 26 Jun 2014 18:13:06 +0900 [thread overview]
Message-ID: <53ABE422.1000000@jp.fujitsu.com> (raw)
In-Reply-To: <53ABE28F.6010402@jp.fujitsu.com>
Using VIRT_CPU_ACCOUNTING, ia64 utilize "timestamp at end of iowait"
like s390.
Not-Tested-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
arch/ia64/include/asm/cputime.h | 2 +
arch/ia64/kernel/time.c | 43 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h
index e2d3f5b..6089cbd 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -24,6 +24,8 @@
# include <asm/processor.h>
# include <asm-generic/cputime_nsecs.h>
extern void arch_vtime_task_switch(struct task_struct *tsk);
+extern void ia64_record_iowait_exit(int cpu);
+# define arch_record_iowait_exit(cpu) ia64_record_iowait_exit(cpu)
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
#endif /* __IA64_CPUTIME_H */
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 71c52bc..37c907d 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -138,9 +138,50 @@ void vtime_account_system(struct task_struct *tsk)
}
EXPORT_SYMBOL_GPL(vtime_account_system);
+/*
+ * Nasty trick to account iowait time as defined
+ */
+DEFINE_PER_CPU(u64, ia64_iowait_exit);
+
+void ia64_record_iowait_exit(int cpu)
+{
+ /* FIXME: ITC might not synchronized between cpus/sockets */
+ per_cpu(ia64_iowait_exit, cpu) = ia64_get_itc();
+}
+
void vtime_account_idle(struct task_struct *tsk)
{
- account_idle_time(vtime_delta(tsk));
+ struct thread_info *ti = task_thread_info(tsk);
+ cputime_t delta_stime, iowait_time;
+ __u64 now;
+
+ WARN_ON_ONCE(!irqs_disabled());
+
+ now = ia64_get_itc();
+
+ /*
+ * tsk must be idle process: its runtime is accumulated as system time
+ * (ac_utime must be 0) so convert it to idle time for accounting.
+ *
+ * in cycles:
+ * iowait_exit
+ * (idle_enter) | ac_stamp now(=idle_exit)
+ * -------+-------------------*------+------->
+ * <------- ac_stime ------->
+ *
+ * in cputime:
+ * (0)
+ * -------+-------------------*------+------->
+ * <----------- delta_stime --------->
+ * <-- iowait_time -->
+ */
+ delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp));
+ iowait_time = cycle_to_cputime(ti->ac_stime +
+ __ia64_per_cpu_var(ia64_iowait_exit) - ti->ac_stamp);
+ ti->ac_stime = 0;
+ ti->ac_stamp = now;
+
+ account_idle_and_iowait(0, iowait_time, delta_stime);
}
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
--
1.7.1
next prev parent reply other threads:[~2014-06-26 9:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 9:06 [RFC PATCH 0/8] rework iowait accounting Hidetoshi Seto
2014-06-26 9:08 ` [PATCH 1/8] cputime, sched: record last_iowait Hidetoshi Seto
2014-06-26 9:09 ` [PATCH 2/8] cputime, nohz: handle last_iowait for nohz Hidetoshi Seto
2014-06-26 9:10 ` [PATCH 3/8] cputime: introduce account_idle_and_iowait Hidetoshi Seto
2014-06-26 9:12 ` [PATCH 4/8] cputime, s390: introduce s390_get_idle_and_iowait Hidetoshi Seto
2014-06-26 9:13 ` Hidetoshi Seto [this message]
2014-06-26 9:14 ` [PATCH 6/8] cputime, ppc: update iowait accounting Hidetoshi Seto
2014-06-26 9:16 ` [PATCH 7/8] cputime: generic iowait accounting for VIRT_CPU_ACCOUNTING Hidetoshi Seto
2014-06-26 9:17 ` [PATCH 8/8] cputime: iowait aware idle tick accounting Hidetoshi Seto
2014-07-07 9:30 ` [RFC PATCH 0/8] rework iowait accounting Peter Zijlstra
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=53ABE422.1000000@jp.fujitsu.com \
--to=seto.hidetoshi@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=fernando_b1@lab.ntt.co.jp \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=peterz@infradead.org \
--cc=preeti@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=vda.linux@googlemail.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;
as well as URLs for NNTP newsgroup(s).