hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/vtime.h
....@@ -11,11 +11,15 @@
1111 struct task_struct;
1212
1313 /*
14
- * vtime_accounting_cpu_enabled() definitions/declarations
14
+ * vtime_accounting_enabled_this_cpu() definitions/declarations
1515 */
1616 #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE)
17
-static inline bool vtime_accounting_cpu_enabled(void) { return true; }
17
+
18
+static inline bool vtime_accounting_enabled_this_cpu(void) { return true; }
19
+extern void vtime_task_switch(struct task_struct *prev);
20
+
1821 #elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN)
22
+
1923 /*
2024 * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
2125 * in that case and compute the tickless cputime.
....@@ -24,46 +28,43 @@
2428 */
2529 static inline bool vtime_accounting_enabled(void)
2630 {
27
- return context_tracking_is_enabled();
31
+ return context_tracking_enabled();
2832 }
2933
30
-static inline bool vtime_accounting_cpu_enabled(void)
34
+static inline bool vtime_accounting_enabled_cpu(int cpu)
3135 {
32
- if (vtime_accounting_enabled()) {
33
- if (context_tracking_cpu_is_enabled())
34
- return true;
35
- }
36
-
37
- return false;
36
+ return context_tracking_enabled_cpu(cpu);
3837 }
39
-#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
40
-static inline bool vtime_accounting_cpu_enabled(void) { return false; }
41
-#endif
4238
39
+static inline bool vtime_accounting_enabled_this_cpu(void)
40
+{
41
+ return context_tracking_enabled_this_cpu();
42
+}
43
+
44
+extern void vtime_task_switch_generic(struct task_struct *prev);
45
+
46
+static inline void vtime_task_switch(struct task_struct *prev)
47
+{
48
+ if (vtime_accounting_enabled_this_cpu())
49
+ vtime_task_switch_generic(prev);
50
+}
51
+
52
+#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
53
+
54
+static inline bool vtime_accounting_enabled_cpu(int cpu) {return false; }
55
+static inline bool vtime_accounting_enabled_this_cpu(void) { return false; }
56
+static inline void vtime_task_switch(struct task_struct *prev) { }
57
+
58
+#endif
4359
4460 /*
4561 * Common vtime APIs
4662 */
4763 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
48
-
49
-#ifdef __ARCH_HAS_VTIME_TASK_SWITCH
50
-extern void vtime_task_switch(struct task_struct *prev);
51
-#else
52
-extern void vtime_common_task_switch(struct task_struct *prev);
53
-static inline void vtime_task_switch(struct task_struct *prev)
54
-{
55
- if (vtime_accounting_cpu_enabled())
56
- vtime_common_task_switch(prev);
57
-}
58
-#endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
59
-
60
-extern void vtime_account_system(struct task_struct *tsk);
64
+extern void vtime_account_kernel(struct task_struct *tsk);
6165 extern void vtime_account_idle(struct task_struct *tsk);
62
-
6366 #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
64
-
65
-static inline void vtime_task_switch(struct task_struct *prev) { }
66
-static inline void vtime_account_system(struct task_struct *tsk) { }
67
+static inline void vtime_account_kernel(struct task_struct *tsk) { }
6768 #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
6869
6970 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
....@@ -82,36 +83,46 @@
8283 #endif
8384
8485 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
85
-extern void vtime_account_irq_enter(struct task_struct *tsk);
86
-static inline void vtime_account_irq_exit(struct task_struct *tsk)
87
-{
88
- /* On hard|softirq exit we always account to hard|softirq cputime */
89
- vtime_account_system(tsk);
90
-}
86
+extern void vtime_account_irq(struct task_struct *tsk, unsigned int offset);
87
+extern void vtime_account_softirq(struct task_struct *tsk);
88
+extern void vtime_account_hardirq(struct task_struct *tsk);
9189 extern void vtime_flush(struct task_struct *tsk);
9290 #else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
93
-static inline void vtime_account_irq_enter(struct task_struct *tsk) { }
94
-static inline void vtime_account_irq_exit(struct task_struct *tsk) { }
91
+static inline void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { }
92
+static inline void vtime_account_softirq(struct task_struct *tsk) { }
93
+static inline void vtime_account_hardirq(struct task_struct *tsk) { }
9594 static inline void vtime_flush(struct task_struct *tsk) { }
9695 #endif
9796
9897
9998 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
100
-extern void irqtime_account_irq(struct task_struct *tsk);
99
+extern void irqtime_account_irq(struct task_struct *tsk, unsigned int offset);
101100 #else
102
-static inline void irqtime_account_irq(struct task_struct *tsk) { }
101
+static inline void irqtime_account_irq(struct task_struct *tsk, unsigned int offset) { }
103102 #endif
104103
105
-static inline void account_irq_enter_time(struct task_struct *tsk)
104
+static inline void account_softirq_enter(struct task_struct *tsk)
106105 {
107
- vtime_account_irq_enter(tsk);
108
- irqtime_account_irq(tsk);
106
+ vtime_account_irq(tsk, SOFTIRQ_OFFSET);
107
+ irqtime_account_irq(tsk, SOFTIRQ_OFFSET);
109108 }
110109
111
-static inline void account_irq_exit_time(struct task_struct *tsk)
110
+static inline void account_softirq_exit(struct task_struct *tsk)
112111 {
113
- vtime_account_irq_exit(tsk);
114
- irqtime_account_irq(tsk);
112
+ vtime_account_softirq(tsk);
113
+ irqtime_account_irq(tsk, 0);
114
+}
115
+
116
+static inline void account_hardirq_enter(struct task_struct *tsk)
117
+{
118
+ vtime_account_irq(tsk, HARDIRQ_OFFSET);
119
+ irqtime_account_irq(tsk, HARDIRQ_OFFSET);
120
+}
121
+
122
+static inline void account_hardirq_exit(struct task_struct *tsk)
123
+{
124
+ vtime_account_hardirq(tsk);
125
+ irqtime_account_irq(tsk, 0);
115126 }
116127
117128 #endif /* _LINUX_KERNEL_VTIME_H */