提交 631fe154 编写于 作者: D Davidlohr Bueso 提交者: Ingo Molnar

perf/x86: Update rdpmc_always_available static key to the modern API

No changes in refcount semantics -- use DEFINE_STATIC_KEY_FALSE()
for initialization and replace:

  static_key_slow_inc|dec()   =>   static_branch_inc|dec()
  static_key_false()          =>   static_branch_unlikely()

Added a '_key' suffix to rdpmc_always_available, for better self-documentation.
Signed-off-by: NDavidlohr Bueso <dbueso@suse.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: akpm@linux-foundation.org
Link: http://lkml.kernel.org/r/20180326210929.5244-5-dave@stgolabs.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 a0ac7b3c
...@@ -48,7 +48,7 @@ DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { ...@@ -48,7 +48,7 @@ DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
.enabled = 1, .enabled = 1,
}; };
struct static_key rdpmc_always_available = STATIC_KEY_INIT_FALSE; DEFINE_STATIC_KEY_FALSE(rdpmc_always_available_key);
u64 __read_mostly hw_cache_event_ids u64 __read_mostly hw_cache_event_ids
[PERF_COUNT_HW_CACHE_MAX] [PERF_COUNT_HW_CACHE_MAX]
...@@ -2206,9 +2206,9 @@ static ssize_t set_attr_rdpmc(struct device *cdev, ...@@ -2206,9 +2206,9 @@ static ssize_t set_attr_rdpmc(struct device *cdev,
* but only root can trigger it, so it's okay. * but only root can trigger it, so it's okay.
*/ */
if (val == 2) if (val == 2)
static_key_slow_inc(&rdpmc_always_available); static_branch_inc(&rdpmc_always_available_key);
else else
static_key_slow_dec(&rdpmc_always_available); static_branch_dec(&rdpmc_always_available_key);
on_each_cpu(refresh_pce, NULL, 1); on_each_cpu(refresh_pce, NULL, 1);
} }
......
...@@ -24,11 +24,12 @@ static inline void paravirt_activate_mm(struct mm_struct *prev, ...@@ -24,11 +24,12 @@ static inline void paravirt_activate_mm(struct mm_struct *prev,
#endif /* !CONFIG_PARAVIRT */ #endif /* !CONFIG_PARAVIRT */
#ifdef CONFIG_PERF_EVENTS #ifdef CONFIG_PERF_EVENTS
extern struct static_key rdpmc_always_available;
DECLARE_STATIC_KEY_FALSE(rdpmc_always_available_key);
static inline void load_mm_cr4(struct mm_struct *mm) static inline void load_mm_cr4(struct mm_struct *mm)
{ {
if (static_key_false(&rdpmc_always_available) || if (static_branch_unlikely(&rdpmc_always_available_key) ||
atomic_read(&mm->context.perf_rdpmc_allowed)) atomic_read(&mm->context.perf_rdpmc_allowed))
cr4_set_bits(X86_CR4_PCE); cr4_set_bits(X86_CR4_PCE);
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册