[PATCH 30/36] ia64: Convert vtime to use nsec units directly

From: Frederic Weisbecker
Date: Thu Nov 17 2016 - 13:10:09 EST


There is no need anymore for this cputime_t midlayer. Let's use nsec
units directly.

Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Cc: Tony Luck <tony.luck@xxxxxxxxx>
Cc: Fenghua Yu <fenghua.yu@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Stanislaw Gruszka <sgruszka@xxxxxxxxxx>
Cc: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---
arch/ia64/kernel/head.S | 4 ++--
arch/ia64/kernel/time.c | 17 ++++++++---------
2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index c9b5e94..3204fdd 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -1031,7 +1031,7 @@ GLOBAL_ENTRY(ia64_native_sched_clock)
END(ia64_native_sched_clock)

#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-GLOBAL_ENTRY(cycle_to_cputime)
+GLOBAL_ENTRY(cycle_to_nsec)
alloc r16=ar.pfs,1,0,0,0
addl r8=THIS_CPU(ia64_cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0
;;
@@ -1047,7 +1047,7 @@ GLOBAL_ENTRY(cycle_to_cputime)
;;
shrp r8=r9,r8,IA64_NSEC_PER_CYC_SHIFT
br.ret.sptk.many rp
-END(cycle_to_cputime)
+END(cycle_to_nsec)
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */

#ifdef CONFIG_IA64_BRL_EMU
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 0aba18e..03eb959 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -59,7 +59,7 @@ static struct clocksource *itc_clocksource;

#include <linux/kernel_stat.h>

-extern cputime_t cycle_to_cputime(u64 cyc);
+extern u64 cycle_to_nsec(u64 cyc);

void vtime_account_user(struct task_struct *tsk)
{
@@ -67,8 +67,7 @@ void vtime_account_user(struct task_struct *tsk)
struct thread_info *ti = task_thread_info(tsk);

if (ti->ac_utime) {
- /* TODO: cycle_to_ns */
- delta_utime = cputime_to_nsecs(cycle_to_cputime(ti->ac_utime));
+ delta_utime = cycle_to_nsec(ti->ac_utime);
account_user_time(tsk, delta_utime);
ti->ac_utime = 0;
}
@@ -92,17 +91,17 @@ void arch_vtime_task_switch(struct task_struct *prev)
* Account time for a transition between system, hard irq or soft irq state.
* Note that this function is called with interrupts enabled.
*/
-static cputime_t vtime_delta(struct task_struct *tsk)
+static u64 vtime_delta(struct task_struct *tsk)
{
struct thread_info *ti = task_thread_info(tsk);
- cputime_t delta_stime;
+ u64 delta_stime;
__u64 now;

WARN_ON_ONCE(!irqs_disabled());

now = ia64_get_itc();

- delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp));
+ delta_stime = cycle_to_nsec(ti->ac_stime + (now - ti->ac_stamp));
ti->ac_stime = 0;
ti->ac_stamp = now;

@@ -111,15 +110,15 @@ static cputime_t vtime_delta(struct task_struct *tsk)

void vtime_account_system(struct task_struct *tsk)
{
- cputime_t delta = vtime_delta(tsk);
+ u64 delta = vtime_delta(tsk);

- account_system_time(tsk, 0, cputime_to_nsecs(delta));
+ account_system_time(tsk, 0, delta);
}
EXPORT_SYMBOL_GPL(vtime_account_system);

void vtime_account_idle(struct task_struct *tsk)
{
- account_idle_time(cputime_to_nsecs(vtime_delta(tsk)));
+ account_idle_time(vtime_delta(tsk));
}

#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
--
2.7.4