update static key users to modern api
Subsystems (11)
PATCH v2 1/6 drivers/i2c: Update i2c_trace_msg static key to modern api
In reply to Davidlohr BuesoNo changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely
Added a '_key' suffix to i2c_trace_msg, for better self documentation.
--- drivers/i2c/i2c-core-base.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/i2c/i2c-core-base.c +7 -6
@@ -69,18 +69,18 @@ static DEFINE_IDR(i2c_adapter_idr);static int i2c_detect (struct i2c_adapter *adapter,struct i2c_driver *driver); -static struct static_key i2c_trace_msg =STATIC_KEY_INIT_FALSE ; +static DEFINE_STATIC_KEY_FALSE (i2c_trace_msg_key);static bool is_registered;int i2c_transfer_trace_reg (void ) { -static_key_slow_inc (&i2c_trace_msg); +static_branch_inc (&i2c_trace_msg_key);return 0 ; }void i2c_transfer_trace_unreg (void ) { -static_key_slow_dec (&i2c_trace_msg); +static_branch_dec (&i2c_trace_msg_key); } const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
@@ -1848,11 +1848,12 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)if (adap->quirks &&i2c_check_for_quirks (adap, msgs, num))return -EOPNOTSUPP ; -/* i2c_trace_msg gets enabled when tracepoint i2c_transfer gets +/* +* i2c_trace_msg_key gets enabled when tracepoint i2c_transfer gets * enabled. This is an efficient way of keeping the for-loop from * being executed when not needed. */ -if (static_key_false (&i2c_trace_msg)) { +if (static_branch_unlikely (&i2c_trace_msg_key)) {int i;for (i =0 ; i < num; i++)if (msgs[i].flags &I2C_M_RD )
@@ -1871,7 +1872,7 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)break ; } -if (static_key_false (&i2c_trace_msg)) { +if (static_branch_unlikely (&i2c_trace_msg_key)) {int i;for (i =0 ; i < ret; i++)if (msgs[i].flags &I2C_M_RD )
Signature · 1 line
2.13.6
PATCH v2 5/6 net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
In reply to Davidlohr BuesoNo changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely
Added a '_key' suffix to i2c_trace_msg, for better self documentation.
--- include/net/ip_tunnels.h | 4 ++-- net/ipv4/ip_tunnel_core.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
include/net/ip_tunnels.h +2 -2
@@ -466,12 +466,12 @@ static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstatreturn (struct ip_tunnel_info *)lwtstate->data; } -extern struct static_key ip_tunnel_metadata_cnt; +DECLARE_STATIC_KEY_FALSE (ip_tunnel_metadata_cnt);/* Returns > 0 if metadata should be collected */ static inline int ip_tunnel_collect_metadata (void ) { -return static_key_false (&ip_tunnel_metadata_cnt); +return static_branch_unlikely (&ip_tunnel_metadata_cnt); }void __init ip_tunnel_core_init (void );
net/ipv4/ip_tunnel_core.c +3 -3
@@ -423,17 +423,17 @@ void __init ip_tunnel_core_init(void)lwtunnel_encap_add_ops (&ip6_tun_lwt_ops,LWTUNNEL_ENCAP_IP6 ); } -struct static_key ip_tunnel_metadata_cnt =STATIC_KEY_INIT_FALSE ; +DEFINE_STATIC_KEY_FALSE (ip_tunnel_metadata_cnt);EXPORT_SYMBOL (ip_tunnel_metadata_cnt);void ip_tunnel_need_metadata (void ) { -static_key_slow_inc (&ip_tunnel_metadata_cnt); +static_branch_inc (&ip_tunnel_metadata_cnt); }EXPORT_SYMBOL_GPL (ip_tunnel_need_metadata);void ip_tunnel_unneed_metadata (void ) { -static_key_slow_dec (&ip_tunnel_metadata_cnt); +static_branch_dec (&ip_tunnel_metadata_cnt); }EXPORT_SYMBOL_GPL (ip_tunnel_unneed_metadata);
Signature · 1 line
2.13.6
PATCH v2 6/6 net/sock: Update memalloc_socks static key to modern api
In reply to Davidlohr BuesoNo changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely
Added a '_key' suffix to memalloc_socks, for better self documentation.
--- include/net/sock.h | 4 ++-- net/core/sock.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/sock.h +2 -2
@@ -803,10 +803,10 @@ static inline bool sock_flag(const struct sock *sk, enum sock_flags flag) }#ifdef CONFIG_NET -extern struct static_key memalloc_socks; +DECLARE_STATIC_KEY_FALSE (memalloc_socks_key);static inline int sk_memalloc_socks (void ) { -return static_key_false (&memalloc_socks); +return static_branch_unlikely (&memalloc_socks_key); }#else
net/core/sock.c +4 -4
@@ -323,8 +323,8 @@ EXPORT_SYMBOL(sysctl_optmem_max);int sysctl_tstamp_allow_data__read_mostly =1 ; -struct static_key memalloc_socks =STATIC_KEY_INIT_FALSE ; -EXPORT_SYMBOL_GPL (memalloc_socks); +DEFINE_STATIC_KEY_FALSE (memalloc_socks_key); +EXPORT_SYMBOL_GPL (memalloc_socks_key);/** * sk_set_memalloc - sets %SOCK_MEMALLOC
@@ -338,7 +338,7 @@ void sk_set_memalloc(struct sock *sk) {sock_set_flag (sk,SOCK_MEMALLOC ); sk->sk_allocation |= __GFP_MEMALLOC; -static_key_slow_inc (&memalloc_socks); +static_branch_inc (&memalloc_socks_key); }EXPORT_SYMBOL_GPL (sk_set_memalloc);
@@ -346,7 +346,7 @@ void sk_clear_memalloc(struct sock *sk) {sock_reset_flag (sk,SOCK_MEMALLOC ); sk->sk_allocation &= ~__GFP_MEMALLOC; -static_key_slow_dec (&memalloc_socks); +static_branch_dec (&memalloc_socks_key);/* * SOCK_MEMALLOC is allowed to ignore rmem limits to ensure forward
Signature · 1 line
2.13.6
v2 cover update static key users to modern api
Changes from v1:
- added the 'static' keyword where it belongs.
- added networking and x86-perf patches. Unlike the first three, these these use the global/extern variants.
Hi,
I noticed a few users in the kernel calling stale static key api. Patches are straightforward; note that the irqchip was also changed to not use refcounting functions as it only 'disables' the feature.
Applies on today's -next. Compile-tested.
Thanks!
Davidlohr Bueso (6):
drivers/i2c: Update i2c_trace_msg static key to modern api drivers/irqchip: Update supports_deactivate static key to modern api sched/core: Update preempt_notifier_key to modern api perf,x86: Update rdpmc_always_available static key to modern api net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api net/sock: Update memalloc_socks static key to modern api
arch/x86/events/core.c | 6 +++--- arch/x86/include/asm/mmu_context.h | 5 +++-- drivers/i2c/i2c-core-base.c | 13 +++++++------ drivers/irqchip/irq-gic-v3.c | 20 ++++++++++---------- drivers/irqchip/irq-gic.c | 22 +++++++++++----------- include/net/ip_tunnels.h | 4 ++-- include/net/sock.h | 4 ++-- kernel/sched/core.c | 12 ++++++------ net/core/sock.c | 8 ++++---- net/ipv4/ip_tunnel_core.c | 6 +++--- 10 files changed, 51 insertions(+), 49 deletions(-)
Signature · 1 line
2.13.6
PATCH v2 3/6 sched/core: Update preempt_notifier_key to modern api
No changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely
--- kernel/sched/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/sched/core.c +6 -6
@@ -2462,17 +2462,17 @@ void wake_up_new_task(struct task_struct *p)#ifdef CONFIG_PREEMPT_NOTIFIERS -static struct static_key preempt_notifier_key =STATIC_KEY_INIT_FALSE ; +static DEFINE_STATIC_KEY_FALSE (preempt_notifier_key);void preempt_notifier_inc (void ) { -static_key_slow_inc (&preempt_notifier_key); +static_branch_inc (&preempt_notifier_key); }EXPORT_SYMBOL_GPL (preempt_notifier_inc);void preempt_notifier_dec (void ) { -static_key_slow_dec (&preempt_notifier_key); +static_branch_dec (&preempt_notifier_key); }EXPORT_SYMBOL_GPL (preempt_notifier_dec);
@@ -2482,7 +2482,7 @@ EXPORT_SYMBOL_GPL(preempt_notifier_dec);*/ void preempt_notifier_register (struct preempt_notifier *notifier) { -if (!static_key_false (&preempt_notifier_key)) +if (!static_branch_unlikely (&preempt_notifier_key))WARN (1 ,"registering preempt_notifier while notifiers disabled\n" );hlist_add_head (¬ifier->link, ¤t->preempt_notifiers);
@@ -2511,7 +2511,7 @@ static void __fire_sched_in_preempt_notifiers(struct task_struct *curr) static __always_inline void fire_sched_in_preempt_notifiers(struct task_struct *curr) { -if (static_key_false (&preempt_notifier_key)) +if (static_branch_unlikely (&preempt_notifier_key))__fire_sched_in_preempt_notifiers (curr); }
@@ -2529,7 +2529,7 @@ static __always_inline void fire_sched_out_preempt_notifiers(struct task_struct *curr, struct task_struct *next) { - if (static_key_false(&preempt_notifier_key)) + if (static_branch_unlikely(&preempt_notifier_key)) __fire_sched_out_preempt_notifiers(curr, next); }
Signature · 1 line
2.13.6
PATCH v2 4/6 perf,x86: Update rdpmc_always_available static key to modern api
In reply to Davidlohr BuesoNo changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely
Added a '_key' suffix to rdpmc_always_available, for better self documentation.
--- arch/x86/events/core.c | 6 +++--- arch/x86/include/asm/mmu_context.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/events/core.c +3 -3
@@ -48,7 +48,7 @@ DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .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 [PERF_COUNT_HW_CACHE_MAX ]
@@ -2206,9 +2206,9 @@ static ssize_t set_attr_rdpmc(struct device *cdev,* but only root can trigger it, so it's okay. */ if (val ==2 ) -static_key_slow_inc (&rdpmc_always_available); +static_branch_inc (&rdpmc_always_available_key);else -static_key_slow_dec (&rdpmc_always_available); +static_branch_dec (&rdpmc_always_available_key);on_each_cpu (refresh_pce,NULL ,1 ); }
arch/x86/include/asm/mmu_context.h +3 -2
@@ -24,11 +24,12 @@ static inline void paravirt_activate_mm(struct mm_struct *prev,#endif /* !CONFIG_PARAVIRT */ #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) { -if (static_key_false (&rdpmc_always_available) || +if (static_branch_unlikely (&rdpmc_always_available_key) ||atomic_read (&mm->context.perf_rdpmc_allowed))cr4_set_bits (X86_CR4_PCE );else
Signature · 1 line
2.13.6
PATCH v2 2/6 drivers/irqchip: Update supports_deactivate static key to modern api
In reply to Davidlohr BuesoNo changes in semantics -- key init is true; replace
static_key_slow_dec with static_branch_disable static_key_true with static_branch_likely
The first is because we never actually do any couterpart incs, thus there is really no reference counting semantics going on. Use the more proper static_branch_disable() construct.
Also added a '_key' suffix to supports_deactivate, for better self documentation.
--- drivers/irqchip/irq-gic-v3.c | 20 ++++++++++---------- drivers/irqchip/irq-gic.c | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-)
drivers/irqchip/irq-gic-v3.c +10 -10
@@ -61,7 +61,7 @@ struct gic_chip_data { };static struct gic_chip_data gic_data__read_mostly ; -static struct static_key supports_deactivate =STATIC_KEY_INIT_TRUE ; +static DEFINE_STATIC_KEY_TRUE (supports_deactivate_key);static struct gic_kvm_info gic_v3_kvm_info; static DEFINE_PER_CPU(bool, has_rss);
@@ -354,7 +354,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regsif (likely (irqnr >15 && irqnr <1020 ) || irqnr >=8192 ) {int err; -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))gic_write_eoir (irqnr);else isb ();
@@ -362,7 +362,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs err =handle_domain_irq (gic_data.domain, irqnr, regs);if (err) {WARN_ONCE (true,"Unexpected interrupt received!\n" ); -if (static_key_true (&supports_deactivate)) { +if (static_branch_likely (&supports_deactivate_key)) {if (irqnr <8192 )gic_write_dir (irqnr); }else {
@@ -373,7 +373,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs }if (irqnr <16 ) {gic_write_eoir (irqnr); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))gic_write_dir (irqnr);#ifdef CONFIG_SMP /*
@@ -576,7 +576,7 @@ static void gic_cpu_sys_reg_init(void)*/ gic_write_bpr1 (0 ); -if (static_key_true (&supports_deactivate)) { +if (static_branch_likely (&supports_deactivate_key)) {/* EOI drops priority only (mode 1) */ gic_write_ctlr (ICC_CTLR_EL1_EOImode_drop); }else {
@@ -884,7 +884,7 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq, {struct irq_chip *chip = &gic_chip; -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key)) chip = &gic_eoimode1_chip;/* SGIs are private to the core kernel */
@@ -1075,9 +1075,9 @@ static int __init gic_init_bases(void __iomem *dist_base,int err;if (!is_hyp_mode_available ()) -static_key_slow_dec (&supports_deactivate); +static_branch_disable (&supports_deactivate_key); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))pr_info ("GIC: Using split EOI/Deactivate mode\n" ); gic_data.fwnode = handle;
@@ -1312,7 +1312,7 @@ static int __init gic_of_init(struct device_node *node, struct device_node *paregic_populate_ppi_partitions (node); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))gic_of_setup_kvm_info (node);return 0 ;
@@ -1614,7 +1614,7 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end)acpi_set_irq_model (ACPI_IRQ_MODEL_GIC , domain_handle); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))gic_acpi_setup_kvm_info ();return 0 ;
drivers/irqchip/irq-gic.c +11 -11
@@ -121,7 +121,7 @@ static DEFINE_RAW_SPINLOCK(cpu_map_lock);#define NR_GIC_CPU_IF 8static u8 gic_cpu_map[NR_GIC_CPU_IF ]__read_mostly ; -static struct static_key supports_deactivate =STATIC_KEY_INIT_TRUE ; +static DEFINE_STATIC_KEY_TRUE (supports_deactivate_key);static struct gic_chip_data gic_data[CONFIG_ARM_GIC_MAX_NR ]__read_mostly ;
@@ -361,7 +361,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) irqnr = irqstat &GICC_IAR_INT_ID_MASK ;if (likely (irqnr >15 && irqnr <1020 )) { -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))writel_relaxed (irqstat, cpu_base +GIC_CPU_EOI );isb ();handle_domain_irq (gic->domain, irqnr, regs);
@@ -369,7 +369,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) }if (irqnr <16 ) {writel_relaxed (irqstat, cpu_base +GIC_CPU_EOI ); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))writel_relaxed (irqstat, cpu_base +GIC_CPU_DEACTIVATE );#ifdef CONFIG_SMP /*
@@ -466,7 +466,7 @@ static void gic_cpu_if_up(struct gic_chip_data *gic)u32 mode =0 ;int i; -if (gic == &gic_data[0 ] &&static_key_true (&supports_deactivate)) +if (gic == &gic_data[0 ] &&static_branch_likely (&supports_deactivate_key)) mode = GIC_CPU_CTRL_EOImodeNS;if (gic_check_gicv2 (cpu_base))
@@ -1219,11 +1219,11 @@ static int __init __gic_init_bases(struct gic_chip_data *gic,"irqchip/arm/gic:starting" , gic_starting_cpu, NULL);set_handle_irq (gic_handle_irq); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))pr_info ("GIC: Using split EOI/Deactivate mode\n" ); } -if (static_key_true (&supports_deactivate) && gic == &gic_data[0 ]) { +if (static_branch_likely (&supports_deactivate_key) && gic == &gic_data[0 ]) { name =kasprintf (GFP_KERNEL ,"GICv2" );gic_init_chip (gic,NULL , name, true); }else {
@@ -1250,7 +1250,7 @@ void __init gic_init(unsigned int gic_nr, int irq_start,* Non-DT/ACPI systems won't run a hypervisor, so let's not * bother with these... */ -static_key_slow_dec (&supports_deactivate); +static_branch_disable (&supports_deactivate_key); gic = &gic_data[gic_nr]; gic->raw_dist_base = dist_base;
@@ -1430,7 +1430,7 @@ static void __init gic_of_setup_kvm_info(struct device_node *node)if (ret)return ; -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))gic_set_kvm_info (&gic_v2_kvm_info); }
@@ -1457,7 +1457,7 @@ gic_of_init(struct device_node *node, struct device_node *parent)* or the CPU interface is too small. */ if (gic_cnt ==0 && !gic_check_eoimode (node, &gic->raw_cpu_base)) -static_key_slow_dec (&supports_deactivate); +static_branch_disable (&supports_deactivate_key); ret =__gic_init_bases (gic,-1 , &node->fwnode);if (ret) {
@@ -1638,7 +1638,7 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header,* interface will always be the right size. */ if (!is_hyp_mode_available ()) -static_key_slow_dec (&supports_deactivate); +static_branch_disable (&supports_deactivate_key);/* * Initialize GIC instance zero (no multi-GIC support).
@@ -1663,7 +1663,7 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header,if (IS_ENABLED (CONFIG_ARM_GIC_V2M ))gicv2m_init (NULL , gic_data[0 ].domain); -if (static_key_true (&supports_deactivate)) +if (static_branch_likely (&supports_deactivate_key))gic_acpi_setup_kvm_info ();return 0 ;
Signature · 1 line
2.13.6
Quoted 5 lines · Davidlohr Bueso
Changes from v1:
- added the 'static' keyword where it belongs.
- added networking and x86-perf patches. Unlike the first three, these these use the global/extern variants.
Quoted 8 lines
Hi,
I noticed a few users in the kernel calling stale static key api. Patches are straightforward; note that the irqchip was also changed to not use refcounting functions as it only 'disables' the feature.
Applies on today's -next. Compile-tested.
Thanks!
tip-bot for Davidlohr Bueso
merge bot[tip:sched/core] sched/core: Update preempt_notifier_key to modern API
In reply to Davidlohr Buesosched/core: Update preempt_notifier_key to modern API
Commit-ID: b720342849fe685310fca01748a32730a6eca5aa Gitweb: https://git.kernel.org/tip/b720342849fe685310fca01748a32730a6eca5aa Author: Davidlohr Bueso <[email protected]> AuthorDate: Mon, 26 Mar 2018 14:09:26 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 27 Mar 2018 07:51:45 +0200
sched/core: Update preempt_notifier_key to 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()
--- kernel/sched/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/sched/core.c +6 -6
@@ -2462,17 +2462,17 @@ void wake_up_new_task(struct task_struct *p)#ifdef CONFIG_PREEMPT_NOTIFIERS -static struct static_key preempt_notifier_key =STATIC_KEY_INIT_FALSE ; +static DEFINE_STATIC_KEY_FALSE (preempt_notifier_key);void preempt_notifier_inc (void ) { -static_key_slow_inc (&preempt_notifier_key); +static_branch_inc (&preempt_notifier_key); }EXPORT_SYMBOL_GPL (preempt_notifier_inc);void preempt_notifier_dec (void ) { -static_key_slow_dec (&preempt_notifier_key); +static_branch_dec (&preempt_notifier_key); }EXPORT_SYMBOL_GPL (preempt_notifier_dec);
@@ -2482,7 +2482,7 @@ EXPORT_SYMBOL_GPL(preempt_notifier_dec);*/ void preempt_notifier_register (struct preempt_notifier *notifier) { -if (!static_key_false (&preempt_notifier_key)) +if (!static_branch_unlikely (&preempt_notifier_key))WARN (1 ,"registering preempt_notifier while notifiers disabled\n" );hlist_add_head (¬ifier->link, ¤t->preempt_notifiers);
@@ -2511,7 +2511,7 @@ static void __fire_sched_in_preempt_notifiers(struct task_struct *curr) static __always_inline void fire_sched_in_preempt_notifiers(struct task_struct *curr) { -if (static_key_false (&preempt_notifier_key)) +if (static_branch_unlikely (&preempt_notifier_key))__fire_sched_in_preempt_notifiers (curr); }
@@ -2529,7 +2529,7 @@ static __always_inline void fire_sched_out_preempt_notifiers(struct task_struct *curr, struct task_struct *next) { - if (static_key_false(&preempt_notifier_key)) + if (static_branch_unlikely(&preempt_notifier_key)) __fire_sched_out_preempt_notifiers(curr, next); }
tip-bot for Davidlohr Bueso
merge bot[tip:perf/core] perf/x86: Update rdpmc_always_available static key to the modern API
In reply to Davidlohr Buesoperf/x86: Update rdpmc_always_available static key to the modern API
Commit-ID: 631fe154edb0a37308d0116a0f9b7bba9dca6218 Gitweb: https://git.kernel.org/tip/631fe154edb0a37308d0116a0f9b7bba9dca6218 Author: Davidlohr Bueso <[email protected]> AuthorDate: Mon, 26 Mar 2018 14:09:27 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 27 Mar 2018 07:53:00 +0200
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.
--- arch/x86/events/core.c | 6 +++--- arch/x86/include/asm/mmu_context.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/events/core.c +3 -3
@@ -48,7 +48,7 @@ DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .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 [PERF_COUNT_HW_CACHE_MAX ]
@@ -2206,9 +2206,9 @@ static ssize_t set_attr_rdpmc(struct device *cdev,* but only root can trigger it, so it's okay. */ if (val ==2 ) -static_key_slow_inc (&rdpmc_always_available); +static_branch_inc (&rdpmc_always_available_key);else -static_key_slow_dec (&rdpmc_always_available); +static_branch_dec (&rdpmc_always_available_key);on_each_cpu (refresh_pce,NULL ,1 ); }
arch/x86/include/asm/mmu_context.h +3 -2
@@ -24,11 +24,12 @@ static inline void paravirt_activate_mm(struct mm_struct *prev,#endif /* !CONFIG_PARAVIRT */ #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) { -if (static_key_false (&rdpmc_always_available) || +if (static_branch_unlikely (&rdpmc_always_available_key) ||atomic_read (&mm->context.perf_rdpmc_allowed))cr4_set_bits (X86_CR4_PCE );else
Re: [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
In reply to David MillerQuoted 5 lines · David Miller
From: Davidlohr Bueso <[email protected]>
Date: Mon, 26 Mar 2018 14:09:28 -0700Quoted 2 lines
No changes in refcount semantics -- key init is false; replace
Quoted 7 lines
Quoted 5 lines
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikelyAdded a '
_key' suffix toi2c_trace_msg, for better self documentation.I see no reference to
i2c_trace_msgin this patch.
Sorry, that was from a previous changelog. The reason why it was not updated was because I chose not to rename to ip_tunnel_metadata_cnt_key, so the whole sentence needed removal. Do you want a v3 or can you pick up as is?
Thanks,
Davidlohr
David Miller
maintainerRe: [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
In reply to Davidlohr BuesoFrom: Davidlohr Bueso <[email protected]>
Date: Mon, 26 Mar 2018 14:09:28 -0700
Quoted 7 lines
No changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikelyAdded a '
_key' suffix toi2c_trace_msg, for better self documentation.
I see no reference to i2c_trace_msg in this patch.
Re: [PATCH 2/6] drivers/irqchip: Update supports_deactivate static key to modern api
In reply to Davidlohr BuesoQuoted 9 lines · Davidlohr Bueso
No changes in semantics -- key init is true; replace
static_key_slow_dec with static_branch_disable static_key_true with static_branch_likelyThe first is because we never actually do any couterpart incs, thus there is really no reference counting semantics going on. Use the more proper
static_branch_disable()construct.
Quoted 7 lines
Also added a '
_key' suffix tosupports_deactivate, for better self documentation.Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>
Looks good to me. How do you want to get this patch merged? Either you deal with it as part of this series, (and in which case please add my Ack on it), or I can take it via the irqchip tree.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH 2/6] drivers/irqchip: Update supports_deactivate static key to modern api
Quoted 3 lines · Marc Zyngier
Looks good to me. How do you want to get this patch merged? Either you deal with it as part of this series, (and in which case please add my Ack on it), or I can take it via the irqchip tree.
Considering Ingo picked up the patches in his jurisdiction, I think it is preferable if you pick this one up yourself.
Thanks,
Davidlohr
Re: [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
In reply to Davidlohr BuesoQuoted 8 lines · Davidlohr Bueso
No changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikelyAdded a '
_key' suffix toi2c_trace_msg, for better self documentation.
CCing David who wrote the original code
Quoted 60 lines
Cc Wolfram Sang <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>--- drivers/i2c/i2c-core-base.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)drivers/i2c/i2c-core-base.c +7
-6@@ -69,18 +69,18 @@ static DEFINE_IDR(i2c_adapter_idr);static int i2c_detect (struct i2c_adapter *adapter,struct i2c_driver *driver); -static struct static_key i2c_trace_msg =STATIC_KEY_INIT_FALSE ; +static DEFINE_STATIC_KEY_FALSE (i2c_trace_msg_key);static bool is_registered;int i2c_transfer_trace_reg (void ) { -static_key_slow_inc (&i2c_trace_msg); +static_branch_inc (&i2c_trace_msg_key);return 0 ; }void i2c_transfer_trace_unreg (void ) { -static_key_slow_dec (&i2c_trace_msg); +static_branch_dec (&i2c_trace_msg_key); } const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,@@ -1848,11 +1848,12 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)if (adap->quirks &&i2c_check_for_quirks (adap, msgs, num))return -EOPNOTSUPP ; -/* i2c_trace_msg gets enabled when tracepoint i2c_transfer gets +/* +* i2c_trace_msg_key gets enabled when tracepoint i2c_transfer gets * enabled. This is an efficient way of keeping the for-loop from * being executed when not needed. */ -if (static_key_false (&i2c_trace_msg)) { +if (static_branch_unlikely (&i2c_trace_msg_key)) {int i;for (i =0 ; i < num; i++)if (msgs[i].flags &I2C_M_RD )@@ -1871,7 +1872,7 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)break ; } -if (static_key_false (&i2c_trace_msg)) { +if (static_branch_unlikely (&i2c_trace_msg_key)) {int i;for (i =0 ; i < ret; i++)if (msgs[i].flags &I2C_M_RD )Signature · 1 line
2.13.6
David Howells
Reviewed-byRe: [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
Quoted 11 lines · Wolfram Sang
Quoted 11 lines
No changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikelyAdded a '
_key' suffix toi2c_trace_msg, for better self documentation.Cc Wolfram Sang <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>
Wolfram Sang
AppliedRe: [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
In reply to Davidlohr BuesoQuoted 11 lines · Davidlohr Bueso
No changes in refcount semantics -- key init is false; replace
static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikelyAdded a '
_key' suffix toi2c_trace_msg, for better self documentation.Cc Wolfram Sang <[email protected]>Signed-off-by Davidlohr Bueso <[email protected]>
Applied to for-next, thanks!