diff options
Diffstat (limited to 'include/linux/context_tracking.h')
-rw-r--r-- | include/linux/context_tracking.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index 365f4a61bf04..fc09d7b0dacf 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/sched.h> | 4 | #include <linux/sched.h> |
5 | #include <linux/percpu.h> | 5 | #include <linux/percpu.h> |
6 | #include <linux/vtime.h> | ||
6 | #include <asm/ptrace.h> | 7 | #include <asm/ptrace.h> |
7 | 8 | ||
8 | struct context_tracking { | 9 | struct context_tracking { |
@@ -19,6 +20,26 @@ struct context_tracking { | |||
19 | } state; | 20 | } state; |
20 | }; | 21 | }; |
21 | 22 | ||
23 | static inline void __guest_enter(void) | ||
24 | { | ||
25 | /* | ||
26 | * This is running in ioctl context so we can avoid | ||
27 | * the call to vtime_account() with its unnecessary idle check. | ||
28 | */ | ||
29 | vtime_account_system(current); | ||
30 | current->flags |= PF_VCPU; | ||
31 | } | ||
32 | |||
33 | static inline void __guest_exit(void) | ||
34 | { | ||
35 | /* | ||
36 | * This is running in ioctl context so we can avoid | ||
37 | * the call to vtime_account() with its unnecessary idle check. | ||
38 | */ | ||
39 | vtime_account_system(current); | ||
40 | current->flags &= ~PF_VCPU; | ||
41 | } | ||
42 | |||
22 | #ifdef CONFIG_CONTEXT_TRACKING | 43 | #ifdef CONFIG_CONTEXT_TRACKING |
23 | DECLARE_PER_CPU(struct context_tracking, context_tracking); | 44 | DECLARE_PER_CPU(struct context_tracking, context_tracking); |
24 | 45 | ||
@@ -35,6 +56,9 @@ static inline bool context_tracking_active(void) | |||
35 | extern void user_enter(void); | 56 | extern void user_enter(void); |
36 | extern void user_exit(void); | 57 | extern void user_exit(void); |
37 | 58 | ||
59 | extern void guest_enter(void); | ||
60 | extern void guest_exit(void); | ||
61 | |||
38 | static inline enum ctx_state exception_enter(void) | 62 | static inline enum ctx_state exception_enter(void) |
39 | { | 63 | { |
40 | enum ctx_state prev_ctx; | 64 | enum ctx_state prev_ctx; |
@@ -57,6 +81,17 @@ extern void context_tracking_task_switch(struct task_struct *prev, | |||
57 | static inline bool context_tracking_in_user(void) { return false; } | 81 | static inline bool context_tracking_in_user(void) { return false; } |
58 | static inline void user_enter(void) { } | 82 | static inline void user_enter(void) { } |
59 | static inline void user_exit(void) { } | 83 | static inline void user_exit(void) { } |
84 | |||
85 | static inline void guest_enter(void) | ||
86 | { | ||
87 | __guest_enter(); | ||
88 | } | ||
89 | |||
90 | static inline void guest_exit(void) | ||
91 | { | ||
92 | __guest_exit(); | ||
93 | } | ||
94 | |||
60 | static inline enum ctx_state exception_enter(void) { return 0; } | 95 | static inline enum ctx_state exception_enter(void) { return 0; } |
61 | static inline void exception_exit(enum ctx_state prev_ctx) { } | 96 | static inline void exception_exit(enum ctx_state prev_ctx) { } |
62 | static inline void context_tracking_task_switch(struct task_struct *prev, | 97 | static inline void context_tracking_task_switch(struct task_struct *prev, |