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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Jun 2014 18:14:38 +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 6/8] cputime, ppc: update iowait accounting

Like s390 and ia64, ppc also has VIRT_CPU_ACCOUNTING.
Check "timestamp at end of iowait" for idle/iowait accounting.

Not-Tested-by: Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
---
 arch/powerpc/include/asm/cputime.h |    3 +++
 arch/powerpc/kernel/time.c         |   21 +++++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index 607559a..f33a801 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -230,6 +230,9 @@ static inline cputime_t clock_t_to_cputime(const unsigned long clk)
 
 static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
 
+void ppc_record_iowait_exit(int cpu);
+#define arch_record_iowait_exit(cpu) ppc_record_iowait_exit(cpu)
+
 #endif /* __KERNEL__ */
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
 #endif /* __POWERPC_CPUTIME_H */
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 9fff9cd..879d97a 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -293,7 +293,7 @@ static inline u64 calculate_stolen_time(u64 stop_tb)
  * or soft irq state.
  */
 static u64 vtime_delta(struct task_struct *tsk,
-			u64 *sys_scaled, u64 *stolen)
+			u64 *sys_scaled, u64 *stolen, u64 *stamp)
 {
 	u64 now, nowscaled, deltascaled;
 	u64 udelta, delta, user_scaled;
@@ -336,6 +336,9 @@ static u64 vtime_delta(struct task_struct *tsk,
 	}
 	get_paca()->user_time_scaled += user_scaled;
 
+	if (stamp)
+		*stamp = now;
+
 	return delta;
 }
 
@@ -343,19 +346,29 @@ void vtime_account_system(struct task_struct *tsk)
 {
 	u64 delta, sys_scaled, stolen;
 
-	delta = vtime_delta(tsk, &sys_scaled, &stolen);
+	delta = vtime_delta(tsk, &sys_scaled, &stolen, NULL);
 	account_system_time(tsk, 0, delta, sys_scaled);
 	if (stolen)
 		account_steal_time(stolen);
 }
 EXPORT_SYMBOL_GPL(vtime_account_system);
 
+DEFINE_PER_CPU(u64, vtime_iowait_exit);
+
+void ppc_record_iowait_exit(int cpu)
+{
+	per_cpu(vtime_iowait_exit, cpu) = mftb();
+}
+
 void vtime_account_idle(struct task_struct *tsk)
 {
 	u64 delta, sys_scaled, stolen;
+	u64 now;
 
-	delta = vtime_delta(tsk, &sys_scaled, &stolen);
-	account_idle_time(delta + stolen);
+	delta = vtime_delta(tsk, &sys_scaled, &stolen, &now);
+	delta += stolen;
+	account_idle_and_iowait(0, delta + per_cpu_var(vtime_iowait_exit) - now,
+				delta);
 }
 
 /*
-- 
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