powerpc/mm: Fix build error with FLATMEM book3s64 config
[linux-2.6-block.git] / arch / powerpc / include / asm / cputime.h
CommitLineData
c6622f63
PM
1/*
2 * Definitions for measuring cputime on powerpc machines.
3 *
4 * Copyright (C) 2006 Paul Mackerras, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
abf917cd 11 * If we have CONFIG_VIRT_CPU_ACCOUNTING_NATIVE, we measure cpu time in
c6622f63
PM
12 * the same units as the timebase. Otherwise we measure cpu time
13 * in jiffies using the generic definitions.
14 */
15
16#ifndef __POWERPC_CPUTIME_H
17#define __POWERPC_CPUTIME_H
18
b672592f 19#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
c6622f63
PM
20
21#include <linux/types.h>
22#include <linux/time.h>
23#include <asm/div64.h>
24#include <asm/time.h>
25#include <asm/param.h>
26
64861634
MS
27typedef u64 __nocast cputime_t;
28typedef u64 __nocast cputime64_t;
c6622f63 29
347abad9
RR
30#define cmpxchg_cputime(ptr, old, new) cmpxchg(ptr, old, new)
31
c6622f63 32#ifdef __KERNEL__
c6622f63 33/*
d57af9b2 34 * Convert cputime <-> microseconds
c6622f63 35 */
9f5072d4 36extern u64 __cputime_usec_factor;
c6622f63 37
d57af9b2 38static inline unsigned long cputime_to_usecs(const cputime_t ct)
c6622f63 39{
e4e88f31 40 return mulhdu((__force u64) ct, __cputime_usec_factor);
c6622f63
PM
41}
42
c223c903
CL
43/*
44 * PPC64 uses PACA which is task independent for storing accounting data while
45 * PPC32 uses struct thread_info, therefore at task switch the accounting data
46 * has to be populated in the new task
47 */
48#ifdef CONFIG_PPC64
60f1d289 49#define get_accounting(tsk) (&get_paca()->accounting)
e3942ba0 50static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
c223c903 51#else
60f1d289
CL
52#define get_accounting(tsk) (&task_thread_info(tsk)->accounting)
53/*
54 * Called from the context switch with interrupts disabled, to charge all
55 * accumulated times to the current process, and to prepare accounting on
56 * the next process.
57 */
58static inline void arch_vtime_task_switch(struct task_struct *prev)
59{
60 struct cpu_accounting_data *acct = get_accounting(current);
61 struct cpu_accounting_data *acct0 = get_accounting(prev);
62
63 acct->starttime = acct0->starttime;
60f1d289 64}
c223c903 65#endif
e3942ba0 66
c6622f63 67#endif /* __KERNEL__ */
abf917cd 68#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
c6622f63 69#endif /* __POWERPC_CPUTIME_H */