diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2015-03-04 12:06:33 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2015-03-09 10:42:50 -0400 |
commit | c467ea763fd5d8795b7d1b5a78eb94b6ad8f66ad (patch) | |
tree | 581f519cb6c9b442f26ee3b57c9f681419d918f5 | |
parent | c5ae732a443e2600823b930457eaab6e25f69b32 (diff) |
context_tracking: Rename context symbols to prepare for transition state
Current context tracking symbols are designed to express living state.
As such they are prefixed with "IN_": IN_USER, IN_KERNEL.
Now we are going to use these symbols to also express state transitions
such as context_tracking_enter(IN_USER) or context_tracking_exit(IN_USER).
But while the "IN_" prefix works well to express entering a context, it's
confusing to depict a context exit: context_tracking_exit(IN_USER)
could mean two things:
1) We are exiting the current context to enter user context.
2) We are exiting the user context
We want 2) but the reviewer may be confused and understand 1)
So lets disambiguate these symbols and rename them to CONTEXT_USER and
CONTEXT_KERNEL.
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Will deacon <will.deacon@arm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r-- | arch/x86/kernel/traps.c | 2 | ||||
-rw-r--r-- | include/linux/context_tracking.h | 2 | ||||
-rw-r--r-- | include/linux/context_tracking_state.h | 6 | ||||
-rw-r--r-- | kernel/context_tracking.c | 8 | ||||
-rw-r--r-- | kernel/sched/core.c | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 9d2073e2ecc9..756f74eed35d 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -123,7 +123,7 @@ enum ctx_state ist_enter(struct pt_regs *regs) | |||
123 | * but we need to notify RCU. | 123 | * but we need to notify RCU. |
124 | */ | 124 | */ |
125 | rcu_nmi_enter(); | 125 | rcu_nmi_enter(); |
126 | prev_state = IN_KERNEL; /* the value is irrelevant. */ | 126 | prev_state = CONTEXT_KERNEL; /* the value is irrelevant. */ |
127 | } | 127 | } |
128 | 128 | ||
129 | /* | 129 | /* |
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index 37b81bd51ec0..427b056dfd3d 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h | |||
@@ -43,7 +43,7 @@ static inline enum ctx_state exception_enter(void) | |||
43 | static inline void exception_exit(enum ctx_state prev_ctx) | 43 | static inline void exception_exit(enum ctx_state prev_ctx) |
44 | { | 44 | { |
45 | if (context_tracking_is_enabled()) { | 45 | if (context_tracking_is_enabled()) { |
46 | if (prev_ctx == IN_USER) | 46 | if (prev_ctx == CONTEXT_USER) |
47 | context_tracking_user_enter(); | 47 | context_tracking_user_enter(); |
48 | } | 48 | } |
49 | } | 49 | } |
diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 97a81225d037..8076f875c324 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h | |||
@@ -13,8 +13,8 @@ struct context_tracking { | |||
13 | */ | 13 | */ |
14 | bool active; | 14 | bool active; |
15 | enum ctx_state { | 15 | enum ctx_state { |
16 | IN_KERNEL = 0, | 16 | CONTEXT_KERNEL = 0, |
17 | IN_USER, | 17 | CONTEXT_USER, |
18 | } state; | 18 | } state; |
19 | }; | 19 | }; |
20 | 20 | ||
@@ -34,7 +34,7 @@ static inline bool context_tracking_cpu_is_enabled(void) | |||
34 | 34 | ||
35 | static inline bool context_tracking_in_user(void) | 35 | static inline bool context_tracking_in_user(void) |
36 | { | 36 | { |
37 | return __this_cpu_read(context_tracking.state) == IN_USER; | 37 | return __this_cpu_read(context_tracking.state) == CONTEXT_USER; |
38 | } | 38 | } |
39 | #else | 39 | #else |
40 | static inline bool context_tracking_in_user(void) { return false; } | 40 | static inline bool context_tracking_in_user(void) { return false; } |
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 937ecdfdf258..8ad53c9d38b6 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c | |||
@@ -75,7 +75,7 @@ void context_tracking_user_enter(void) | |||
75 | WARN_ON_ONCE(!current->mm); | 75 | WARN_ON_ONCE(!current->mm); |
76 | 76 | ||
77 | local_irq_save(flags); | 77 | local_irq_save(flags); |
78 | if ( __this_cpu_read(context_tracking.state) != IN_USER) { | 78 | if ( __this_cpu_read(context_tracking.state) != CONTEXT_USER) { |
79 | if (__this_cpu_read(context_tracking.active)) { | 79 | if (__this_cpu_read(context_tracking.active)) { |
80 | trace_user_enter(0); | 80 | trace_user_enter(0); |
81 | /* | 81 | /* |
@@ -101,7 +101,7 @@ void context_tracking_user_enter(void) | |||
101 | * OTOH we can spare the calls to vtime and RCU when context_tracking.active | 101 | * OTOH we can spare the calls to vtime and RCU when context_tracking.active |
102 | * is false because we know that CPU is not tickless. | 102 | * is false because we know that CPU is not tickless. |
103 | */ | 103 | */ |
104 | __this_cpu_write(context_tracking.state, IN_USER); | 104 | __this_cpu_write(context_tracking.state, CONTEXT_USER); |
105 | } | 105 | } |
106 | local_irq_restore(flags); | 106 | local_irq_restore(flags); |
107 | } | 107 | } |
@@ -129,7 +129,7 @@ void context_tracking_user_exit(void) | |||
129 | return; | 129 | return; |
130 | 130 | ||
131 | local_irq_save(flags); | 131 | local_irq_save(flags); |
132 | if (__this_cpu_read(context_tracking.state) == IN_USER) { | 132 | if (__this_cpu_read(context_tracking.state) == CONTEXT_USER) { |
133 | if (__this_cpu_read(context_tracking.active)) { | 133 | if (__this_cpu_read(context_tracking.active)) { |
134 | /* | 134 | /* |
135 | * We are going to run code that may use RCU. Inform | 135 | * We are going to run code that may use RCU. Inform |
@@ -139,7 +139,7 @@ void context_tracking_user_exit(void) | |||
139 | vtime_user_exit(current); | 139 | vtime_user_exit(current); |
140 | trace_user_exit(0); | 140 | trace_user_exit(0); |
141 | } | 141 | } |
142 | __this_cpu_write(context_tracking.state, IN_KERNEL); | 142 | __this_cpu_write(context_tracking.state, CONTEXT_KERNEL); |
143 | } | 143 | } |
144 | local_irq_restore(flags); | 144 | local_irq_restore(flags); |
145 | } | 145 | } |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f0f831e8a345..06b9a00871e0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -2818,7 +2818,7 @@ asmlinkage __visible void __sched schedule_user(void) | |||
2818 | * we find a better solution. | 2818 | * we find a better solution. |
2819 | * | 2819 | * |
2820 | * NB: There are buggy callers of this function. Ideally we | 2820 | * NB: There are buggy callers of this function. Ideally we |
2821 | * should warn if prev_state != IN_USER, but that will trigger | 2821 | * should warn if prev_state != CONTEXT_USER, but that will trigger |
2822 | * too frequently to make sense yet. | 2822 | * too frequently to make sense yet. |
2823 | */ | 2823 | */ |
2824 | enum ctx_state prev_state = exception_enter(); | 2824 | enum ctx_state prev_state = exception_enter(); |