hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/powerpc/include/asm/cputime.h
....@@ -1,12 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Definitions for measuring cputime on powerpc machines.
34 *
45 * 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.
106 *
117 * If we have CONFIG_VIRT_CPU_ACCOUNTING_NATIVE, we measure cpu time in
128 * the same units as the timebase. Otherwise we measure cpu time
....@@ -40,6 +36,8 @@
4036 return mulhdu((__force u64) ct, __cputime_usec_factor);
4137 }
4238
39
+#define cputime_to_nsecs(cputime) tb_to_ns((__force u64)cputime)
40
+
4341 /*
4442 * PPC64 uses PACA which is task independent for storing accounting data while
4543 * PPC32 uses struct thread_info, therefore at task switch the accounting data
....@@ -47,9 +45,12 @@
4745 */
4846 #ifdef CONFIG_PPC64
4947 #define get_accounting(tsk) (&get_paca()->accounting)
48
+#define raw_get_accounting(tsk) (&local_paca->accounting)
5049 static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
50
+
5151 #else
5252 #define get_accounting(tsk) (&task_thread_info(tsk)->accounting)
53
+#define raw_get_accounting(tsk) get_accounting(tsk)
5354 /*
5455 * Called from the context switch with interrupts disabled, to charge all
5556 * accumulated times to the current process, and to prepare accounting on
....@@ -61,10 +62,39 @@
6162 struct cpu_accounting_data *acct0 = get_accounting(prev);
6263
6364 acct->starttime = acct0->starttime;
64
- acct->startspurr = acct0->startspurr;
6565 }
6666 #endif
6767
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
+
6891 #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
+}
6999 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
70100 #endif /* __POWERPC_CPUTIME_H */