.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Definitions for measuring cputime on powerpc machines. |
---|
3 | 4 | * |
---|
4 | 5 | * 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 | 6 | * |
---|
11 | 7 | * If we have CONFIG_VIRT_CPU_ACCOUNTING_NATIVE, we measure cpu time in |
---|
12 | 8 | * the same units as the timebase. Otherwise we measure cpu time |
---|
.. | .. |
---|
40 | 36 | return mulhdu((__force u64) ct, __cputime_usec_factor); |
---|
41 | 37 | } |
---|
42 | 38 | |
---|
| 39 | +#define cputime_to_nsecs(cputime) tb_to_ns((__force u64)cputime) |
---|
| 40 | + |
---|
43 | 41 | /* |
---|
44 | 42 | * PPC64 uses PACA which is task independent for storing accounting data while |
---|
45 | 43 | * PPC32 uses struct thread_info, therefore at task switch the accounting data |
---|
.. | .. |
---|
47 | 45 | */ |
---|
48 | 46 | #ifdef CONFIG_PPC64 |
---|
49 | 47 | #define get_accounting(tsk) (&get_paca()->accounting) |
---|
| 48 | +#define raw_get_accounting(tsk) (&local_paca->accounting) |
---|
50 | 49 | static inline void arch_vtime_task_switch(struct task_struct *tsk) { } |
---|
| 50 | + |
---|
51 | 51 | #else |
---|
52 | 52 | #define get_accounting(tsk) (&task_thread_info(tsk)->accounting) |
---|
| 53 | +#define raw_get_accounting(tsk) get_accounting(tsk) |
---|
53 | 54 | /* |
---|
54 | 55 | * Called from the context switch with interrupts disabled, to charge all |
---|
55 | 56 | * accumulated times to the current process, and to prepare accounting on |
---|
.. | .. |
---|
61 | 62 | struct cpu_accounting_data *acct0 = get_accounting(prev); |
---|
62 | 63 | |
---|
63 | 64 | acct->starttime = acct0->starttime; |
---|
64 | | - acct->startspurr = acct0->startspurr; |
---|
65 | 65 | } |
---|
66 | 66 | #endif |
---|
67 | 67 | |
---|
| 68 | +/* |
---|
| 69 | + * account_cpu_user_entry/exit runs "unreconciled", so can't trace, |
---|
| 70 | + * can't use get_paca() |
---|
| 71 | + */ |
---|
| 72 | +static notrace inline void account_cpu_user_entry(void) |
---|
| 73 | +{ |
---|
| 74 | + unsigned long tb = mftb(); |
---|
| 75 | + struct cpu_accounting_data *acct = raw_get_accounting(current); |
---|
| 76 | + |
---|
| 77 | + acct->utime += (tb - acct->starttime_user); |
---|
| 78 | + acct->starttime = tb; |
---|
| 79 | +} |
---|
| 80 | + |
---|
| 81 | +static notrace inline void account_cpu_user_exit(void) |
---|
| 82 | +{ |
---|
| 83 | + unsigned long tb = mftb(); |
---|
| 84 | + struct cpu_accounting_data *acct = raw_get_accounting(current); |
---|
| 85 | + |
---|
| 86 | + acct->stime += (tb - acct->starttime); |
---|
| 87 | + acct->starttime_user = tb; |
---|
| 88 | +} |
---|
| 89 | + |
---|
| 90 | + |
---|
68 | 91 | #endif /* __KERNEL__ */ |
---|
| 92 | +#else /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ |
---|
| 93 | +static inline void account_cpu_user_entry(void) |
---|
| 94 | +{ |
---|
| 95 | +} |
---|
| 96 | +static inline void account_cpu_user_exit(void) |
---|
| 97 | +{ |
---|
| 98 | +} |
---|
69 | 99 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ |
---|
70 | 100 | #endif /* __POWERPC_CPUTIME_H */ |
---|