Skip to content

Commit

Permalink
context_tracking: Wrap static key check into more intuitive function …
Browse files Browse the repository at this point in the history
…name

Use a function with a meaningful name to check the global context
tracking state. static_key_false() is a bit confusing for reviewers.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
fweisbec committed Dec 2, 2013
1 parent 99c8b1e commit 58135f5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions include/linux/context_tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ extern void __context_tracking_task_switch(struct task_struct *prev,

static inline void user_enter(void)
{
if (static_key_false(&context_tracking_enabled))
if (context_tracking_is_enabled())
context_tracking_user_enter();

}
static inline void user_exit(void)
{
if (static_key_false(&context_tracking_enabled))
if (context_tracking_is_enabled())
context_tracking_user_exit();
}

static inline enum ctx_state exception_enter(void)
{
enum ctx_state prev_ctx;

if (!static_key_false(&context_tracking_enabled))
if (!context_tracking_is_enabled())
return 0;

prev_ctx = this_cpu_read(context_tracking.state);
Expand All @@ -42,7 +42,7 @@ static inline enum ctx_state exception_enter(void)

static inline void exception_exit(enum ctx_state prev_ctx)
{
if (static_key_false(&context_tracking_enabled)) {
if (context_tracking_is_enabled()) {
if (prev_ctx == IN_USER)
context_tracking_user_enter();
}
Expand All @@ -51,7 +51,7 @@ static inline void exception_exit(enum ctx_state prev_ctx)
static inline void context_tracking_task_switch(struct task_struct *prev,
struct task_struct *next)
{
if (static_key_false(&context_tracking_enabled))
if (context_tracking_is_enabled())
__context_tracking_task_switch(prev, next);
}
#else
Expand Down
4 changes: 4 additions & 0 deletions include/linux/context_tracking_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ struct context_tracking {
extern struct static_key context_tracking_enabled;
DECLARE_PER_CPU(struct context_tracking, context_tracking);

static inline bool context_tracking_is_enabled(void)
{
return static_key_false(&context_tracking_enabled);
}
static inline bool context_tracking_in_user(void)
{
return __this_cpu_read(context_tracking.state) == IN_USER;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/tick.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ extern cpumask_var_t tick_nohz_full_mask;

static inline bool tick_nohz_full_enabled(void)
{
if (!static_key_false(&context_tracking_enabled))
if (!context_tracking_is_enabled())
return false;

return tick_nohz_full_running;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/vtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static inline bool vtime_accounting_enabled(void) { return true; }
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
static inline bool vtime_accounting_enabled(void)
{
if (static_key_false(&context_tracking_enabled)) {
if (context_tracking_is_enabled()) {
if (context_tracking_active())
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions kernel/context_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ void context_tracking_user_enter(void)
/*
* Repeat the user_enter() check here because some archs may be calling
* this from asm and if no CPU needs context tracking, they shouldn't
* go further. Repeat the check here until they support the static key
* check.
* go further. Repeat the check here until they support the inline static
* key check.
*/
if (!static_key_false(&context_tracking_enabled))
if (!context_tracking_is_enabled())
return;

/*
Expand Down Expand Up @@ -160,7 +160,7 @@ void context_tracking_user_exit(void)
{
unsigned long flags;

if (!static_key_false(&context_tracking_enabled))
if (!context_tracking_is_enabled())
return;

if (in_interrupt())
Expand Down

0 comments on commit 58135f5

Please sign in to comment.