lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Jun 2014 18:10:43 +0900
From:	Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
To:	linux-kernel@...r.kernel.org
CC:	Fernando Luis Vazquez Cao <fernando_b1@....ntt.co.jp>,
	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Oleg Nesterov <oleg@...hat.com>,
	Preeti U Murthy <preeti@...ux.vnet.ibm.com>,
	Denys Vlasenko <vda.linux@...glemail.com>
Subject: [PATCH 3/8] cputime: introduce account_idle_and_iowait

The current account_idle_time() cannot process mixed cputime which
contain both of idle cputime and iowait cputime.

So introduce new account_idle_and_iowait() to do paranoid work.
Following patches will add users of this new function.

Not-Tested-by: Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
---
 kernel/sched/cputime.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index a028604..283e011 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -240,14 +240,36 @@ void account_steal_time(cputime_t cputime)
 }
 
 /*
+ * Account for idle and iowait time in a dulation.
+ * @idle_enter: time stamp at idle entry
+ * @iowait_exit: time stamp when nr_iowait dropped to 0
+ * @idle_exit: time stamp at idle exit
+ */
+void account_idle_and_iowait(cputime_t idle_enter, cputime_t iowait_exit, cputime_t idle_exit)
+{
+	u64 *cpustat = kcpustat_this_cpu->cpustat;
+	struct rq *rq = this_rq();
+
+	if (rq->nr_iowait > 0 || iowait_exit > idle_exit) {
+		cpustat[CPUTIME_IOWAIT] += (__force u64) idle_exit - idle_enter;
+	} else if (iowait_exit > idle_enter) {
+		cpustat[CPUTIME_IOWAIT] += (__force u64) iowait_exit - idle_enter;
+		cpustat[CPUTIME_IDLE] += (__force u64) idle_exit - iowait_exit;
+	} else {
+		cpustat[CPUTIME_IDLE] += (__force u64) idle_exit - idle_enter;
+	}
+}
+
+/*
  * Account for idle time.
- * @cputime: the cpu time spent in idle wait
+ * @cputime: the cpu time spent in idle wait (sometimes include iowait time)
  */
 void account_idle_time(cputime_t cputime)
 {
 	u64 *cpustat = kcpustat_this_cpu->cpustat;
 	struct rq *rq = this_rq();
 
+	/* FIXME */
 	if (rq->nr_iowait > 0)
 		cpustat[CPUTIME_IOWAIT] += (__force u64) cputime;
 	else
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ