linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 -next 0/6] update static key users to modern api
@ 2018-03-26 21:09 Davidlohr Bueso
  2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm; +Cc: linux-kernel, 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.

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(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
@ 2018-03-26 21:09 ` Davidlohr Bueso
  2018-04-03 13:20   ` Wolfram Sang
                     ` (2 more replies)
  2018-03-26 21:09 ` [PATCH 2/6] drivers/irqchip: Update supports_deactivate " Davidlohr Bueso
                   ` (5 subsequent siblings)
  6 siblings, 3 replies; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm
  Cc: linux-kernel, Davidlohr Bueso, Wolfram Sang, linux-i2c, 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_unlikely

Added a '_key' suffix to i2c_trace_msg, for better self
documentation.

Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 drivers/i2c/i2c-core-base.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 16a3b73375a6..bfcff2a6f0a3 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -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)
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/6] drivers/irqchip: Update supports_deactivate static key to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
  2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
@ 2018-03-26 21:09 ` Davidlohr Bueso
  2018-03-28 13:47   ` Marc Zyngier
  2018-03-26 21:09 ` [PATCH 3/6] sched/core: Update preempt_notifier_key " Davidlohr Bueso
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm
  Cc: linux-kernel, Davidlohr Bueso, Thomas Gleixner, Jason Cooper,
	Marc Zyngier, 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_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.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 drivers/irqchip/irq-gic-v3.c | 20 ++++++++++----------
 drivers/irqchip/irq-gic.c    | 22 +++++++++++-----------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 56c8de84a72b..e5d101418390 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -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 *regs
 		if (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 *pare
 
 	gic_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;
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index ac2e62d613d1..ced10c44b68a 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -121,7 +121,7 @@ static DEFINE_RAW_SPINLOCK(cpu_map_lock);
 #define NR_GIC_CPU_IF 8
 static 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;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/6] sched/core: Update preempt_notifier_key to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
  2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
  2018-03-26 21:09 ` [PATCH 2/6] drivers/irqchip: Update supports_deactivate " Davidlohr Bueso
@ 2018-03-26 21:09 ` Davidlohr Bueso
  2018-03-27  7:46   ` [tip:sched/core] sched/core: Update preempt_notifier_key to modern API tip-bot for Davidlohr Bueso
  2018-03-26 21:09 ` [PATCH 4/6] perf,x86: Update rdpmc_always_available static key to modern api Davidlohr Bueso
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm; +Cc: linux-kernel, Davidlohr Bueso, 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_unlikely

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 kernel/sched/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 757d5a251ca4..bf9e773007e8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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(&notifier->link, &current->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);
 }
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/6] perf,x86: Update rdpmc_always_available static key to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
                   ` (2 preceding siblings ...)
  2018-03-26 21:09 ` [PATCH 3/6] sched/core: Update preempt_notifier_key " Davidlohr Bueso
@ 2018-03-26 21:09 ` Davidlohr Bueso
  2018-03-27  7:47   ` [tip:perf/core] perf/x86: Update rdpmc_always_available static key to the modern API tip-bot for Davidlohr Bueso
  2018-03-26 21:09 ` [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api Davidlohr Bueso
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm; +Cc: linux-kernel, Davidlohr Bueso, 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_unlikely

Added a '_key' suffix to rdpmc_always_available, for better self
documentation.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 arch/x86/events/core.c             | 6 +++---
 arch/x86/include/asm/mmu_context.h | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index c5f3d83c04ad..7a987e6c7c35 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -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);
 	}
 
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 1de72ce514cd..57e3785d0d26 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -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
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
                   ` (3 preceding siblings ...)
  2018-03-26 21:09 ` [PATCH 4/6] perf,x86: Update rdpmc_always_available static key to modern api Davidlohr Bueso
@ 2018-03-26 21:09 ` Davidlohr Bueso
  2018-03-27 15:44   ` David Miller
  2018-03-26 21:09 ` [PATCH 6/6] net/sock: Update memalloc_socks " Davidlohr Bueso
  2018-03-27  7:36 ` [PATCH v2 -next 0/6] update static key users " Peter Zijlstra
  6 siblings, 1 reply; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm
  Cc: linux-kernel, Davidlohr Bueso, David S . Miller, netdev, 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_unlikely

Added a '_key' suffix to i2c_trace_msg, for better self
documentation.

Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 include/net/ip_tunnels.h  | 4 ++--
 net/ipv4/ip_tunnel_core.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 540a4b4417bf..fc494b48a64a 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -466,12 +466,12 @@ static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstat
 	return (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);
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 2f39479be92f..dde671e97829 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -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);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/6] net/sock: Update memalloc_socks static key to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
                   ` (4 preceding siblings ...)
  2018-03-26 21:09 ` [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api Davidlohr Bueso
@ 2018-03-26 21:09 ` Davidlohr Bueso
  2018-03-27  7:36 ` [PATCH v2 -next 0/6] update static key users " Peter Zijlstra
  6 siblings, 0 replies; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-26 21:09 UTC (permalink / raw)
  To: peterz, mingo, akpm
  Cc: linux-kernel, Davidlohr Bueso, David S . Miller, netdev, 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_unlikely

Added a '_key' suffix to memalloc_socks, for better self
documentation.

Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 include/net/sock.h | 4 ++--
 net/core/sock.c    | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 8c428c6847af..15d676365743 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -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
 
diff --git a/net/core/sock.c b/net/core/sock.c
index e689496dfd8a..670f35803411 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 -next 0/6] update static key users to modern api
  2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
                   ` (5 preceding siblings ...)
  2018-03-26 21:09 ` [PATCH 6/6] net/sock: Update memalloc_socks " Davidlohr Bueso
@ 2018-03-27  7:36 ` Peter Zijlstra
  6 siblings, 0 replies; 17+ messages in thread
From: Peter Zijlstra @ 2018-03-27  7:36 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: mingo, akpm, linux-kernel

On Mon, Mar 26, 2018 at 02:09:23PM -0700, Davidlohr Bueso wrote:
> 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!

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [tip:sched/core] sched/core: Update preempt_notifier_key to modern API
  2018-03-26 21:09 ` [PATCH 3/6] sched/core: Update preempt_notifier_key " Davidlohr Bueso
@ 2018-03-27  7:46   ` tip-bot for Davidlohr Bueso
  0 siblings, 0 replies; 17+ messages in thread
From: tip-bot for Davidlohr Bueso @ 2018-03-27  7:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, dave, peterz, dbueso, torvalds, tglx, linux-kernel, hpa

Commit-ID:  b720342849fe685310fca01748a32730a6eca5aa
Gitweb:     https://git.kernel.org/tip/b720342849fe685310fca01748a32730a6eca5aa
Author:     Davidlohr Bueso <dave@stgolabs.net>
AuthorDate: Mon, 26 Mar 2018 14:09:26 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
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()

Signed-off-by: Davidlohr 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-4-dave@stgolabs.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b249adbf2a48..de440456f15c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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(&notifier->link, &current->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);
 }
 

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [tip:perf/core] perf/x86: Update rdpmc_always_available static key to the modern API
  2018-03-26 21:09 ` [PATCH 4/6] perf,x86: Update rdpmc_always_available static key to modern api Davidlohr Bueso
@ 2018-03-27  7:47   ` tip-bot for Davidlohr Bueso
  0 siblings, 0 replies; 17+ messages in thread
From: tip-bot for Davidlohr Bueso @ 2018-03-27  7:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, dbueso, hpa, mingo, torvalds, linux-kernel, peterz, dave

Commit-ID:  631fe154edb0a37308d0116a0f9b7bba9dca6218
Gitweb:     https://git.kernel.org/tip/631fe154edb0a37308d0116a0f9b7bba9dca6218
Author:     Davidlohr Bueso <dave@stgolabs.net>
AuthorDate: Mon, 26 Mar 2018 14:09:27 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Davidlohr 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.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/core.c             | 6 +++---
 arch/x86/include/asm/mmu_context.h | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 4823695c459f..a6006e7bb729 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -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);
 	}
 
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 1de72ce514cd..57e3785d0d26 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
  2018-03-27 15:44   ` David Miller
@ 2018-03-27 15:37     ` Davidlohr Bueso
  0 siblings, 0 replies; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-27 15:37 UTC (permalink / raw)
  To: David Miller; +Cc: peterz, mingo, akpm, linux-kernel, netdev, dbueso

On Tue, 27 Mar 2018, David Miller wrote:

>From: Davidlohr Bueso <dave@stgolabs.net>
>Date: Mon, 26 Mar 2018 14:09:28 -0700
>
>> 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
>>
>> Added a '_key' suffix to i2c_trace_msg, for better self
>> documentation.
>
>I see no reference to i2c_trace_msg in 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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
  2018-03-26 21:09 ` [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api Davidlohr Bueso
@ 2018-03-27 15:44   ` David Miller
  2018-03-27 15:37     ` Davidlohr Bueso
  0 siblings, 1 reply; 17+ messages in thread
From: David Miller @ 2018-03-27 15:44 UTC (permalink / raw)
  To: dave; +Cc: peterz, mingo, akpm, linux-kernel, netdev, dbueso

From: Davidlohr Bueso <dave@stgolabs.net>
Date: Mon, 26 Mar 2018 14:09:28 -0700

> 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
> 
> Added a '_key' suffix to i2c_trace_msg, for better self
> documentation.

I see no reference to i2c_trace_msg in this patch.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/6] drivers/irqchip: Update supports_deactivate static key to modern api
  2018-03-28 13:47   ` Marc Zyngier
@ 2018-03-28 13:46     ` Davidlohr Bueso
  0 siblings, 0 replies; 17+ messages in thread
From: Davidlohr Bueso @ 2018-03-28 13:46 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: peterz, mingo, akpm, linux-kernel, Thomas Gleixner, Jason Cooper,
	Davidlohr Bueso

On Wed, 28 Mar 2018, Marc Zyngier wrote:

>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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/6] drivers/irqchip: Update supports_deactivate static key to modern api
  2018-03-26 21:09 ` [PATCH 2/6] drivers/irqchip: Update supports_deactivate " Davidlohr Bueso
@ 2018-03-28 13:47   ` Marc Zyngier
  2018-03-28 13:46     ` Davidlohr Bueso
  0 siblings, 1 reply; 17+ messages in thread
From: Marc Zyngier @ 2018-03-28 13:47 UTC (permalink / raw)
  To: Davidlohr Bueso, peterz, mingo, akpm
  Cc: linux-kernel, Thomas Gleixner, Jason Cooper, Davidlohr Bueso

On 26/03/18 22:09, Davidlohr Bueso wrote:
> No 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.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>

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.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
  2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
@ 2018-04-03 13:20   ` Wolfram Sang
  2018-04-03 14:00   ` David Howells
  2018-04-03 14:49   ` Wolfram Sang
  2 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2018-04-03 13:20 UTC (permalink / raw)
  To: Davidlohr Bueso, David Howells
  Cc: peterz, mingo, akpm, linux-kernel, linux-i2c, Davidlohr Bueso

[-- Attachment #1: Type: text/plain, Size: 2479 bytes --]

On Mon, Mar 26, 2018 at 02:09:24PM -0700, Davidlohr Bueso wrote:
> 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
> 
> Added a '_key' suffix to i2c_trace_msg, for better self
> documentation.
> 

CCing David who wrote the original code

> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-i2c@vger.kernel.org
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
> ---
>  drivers/i2c/i2c-core-base.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 16a3b73375a6..bfcff2a6f0a3 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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)
> -- 
> 2.13.6
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
  2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
  2018-04-03 13:20   ` Wolfram Sang
@ 2018-04-03 14:00   ` David Howells
  2018-04-03 14:49   ` Wolfram Sang
  2 siblings, 0 replies; 17+ messages in thread
From: David Howells @ 2018-04-03 14:00 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: dhowells, Davidlohr Bueso, peterz, mingo, akpm, linux-kernel,
	linux-i2c, Davidlohr Bueso

Wolfram Sang <wsa@the-dreams.de> wrote:

> > 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
> > 
> > Added a '_key' suffix to i2c_trace_msg, for better self
> > documentation.
> > 
> > Cc: Wolfram Sang <wsa@the-dreams.de>
> > Cc: linux-i2c@vger.kernel.org
> > Signed-off-by: Davidlohr Bueso <dbueso@suse.de>

Reviewed-by: David Howells <dhowells@redhat.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key to modern api
  2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
  2018-04-03 13:20   ` Wolfram Sang
  2018-04-03 14:00   ` David Howells
@ 2018-04-03 14:49   ` Wolfram Sang
  2 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2018-04-03 14:49 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: peterz, mingo, akpm, linux-kernel, linux-i2c, Davidlohr Bueso

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]

On Mon, Mar 26, 2018 at 02:09:24PM -0700, Davidlohr Bueso wrote:
> 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
> 
> Added a '_key' suffix to i2c_trace_msg, for better self
> documentation.
> 
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-i2c@vger.kernel.org
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-04-03 14:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 21:09 [PATCH v2 -next 0/6] update static key users to modern api Davidlohr Bueso
2018-03-26 21:09 ` [PATCH 1/6] drivers/i2c: Update i2c_trace_msg static key " Davidlohr Bueso
2018-04-03 13:20   ` Wolfram Sang
2018-04-03 14:00   ` David Howells
2018-04-03 14:49   ` Wolfram Sang
2018-03-26 21:09 ` [PATCH 2/6] drivers/irqchip: Update supports_deactivate " Davidlohr Bueso
2018-03-28 13:47   ` Marc Zyngier
2018-03-28 13:46     ` Davidlohr Bueso
2018-03-26 21:09 ` [PATCH 3/6] sched/core: Update preempt_notifier_key " Davidlohr Bueso
2018-03-27  7:46   ` [tip:sched/core] sched/core: Update preempt_notifier_key to modern API tip-bot for Davidlohr Bueso
2018-03-26 21:09 ` [PATCH 4/6] perf,x86: Update rdpmc_always_available static key to modern api Davidlohr Bueso
2018-03-27  7:47   ` [tip:perf/core] perf/x86: Update rdpmc_always_available static key to the modern API tip-bot for Davidlohr Bueso
2018-03-26 21:09 ` [PATCH 5/6] net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api Davidlohr Bueso
2018-03-27 15:44   ` David Miller
2018-03-27 15:37     ` Davidlohr Bueso
2018-03-26 21:09 ` [PATCH 6/6] net/sock: Update memalloc_socks " Davidlohr Bueso
2018-03-27  7:36 ` [PATCH v2 -next 0/6] update static key users " Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).