kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/7] static_key: use static_key_slow_inc_deferred()
       [not found] <1382004631-25895-1-git-send-email-rkrcmar@redhat.com>
@ 2013-10-17 10:10 ` Radim Krčmář
  2013-10-17 10:39   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Radim Krčmář @ 2013-10-17 10:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Radim Krčmář, Gleb Natapov, Paolo Bonzini,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Peter Zijlstra,
	Paul Mackerras, Arnaldo Carvalho de Melo, kvm

Simple replacement where possible.
Saves us problematic access to the structure and allows optimalizations
and bug fixes to take place.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/lapic.c | 7 ++++---
 kernel/events/core.c | 6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 5439117..eff85f6 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -121,7 +121,7 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val)
 		if (val & APIC_SPIV_APIC_ENABLED)
 			static_key_slow_dec_deferred(&apic_sw_disabled);
 		else
-			static_key_slow_inc(&apic_sw_disabled.key);
+			static_key_slow_inc_deferred(&apic_sw_disabled);
 	}
 	apic_set_reg(apic, APIC_SPIV, val);
 }
@@ -1351,7 +1351,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
 		if (value & MSR_IA32_APICBASE_ENABLE)
 			static_key_slow_dec_deferred(&apic_hw_disabled);
 		else
-			static_key_slow_inc(&apic_hw_disabled.key);
+			static_key_slow_inc_deferred(&apic_hw_disabled);
 		recalculate_apic_map(vcpu->kvm);
 	}
 
@@ -1546,7 +1546,8 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
 	kvm_lapic_set_base(vcpu,
 			APIC_DEFAULT_PHYS_BASE | MSR_IA32_APICBASE_ENABLE);
 
-	static_key_slow_inc(&apic_sw_disabled.key); /* sw disabled at reset */
+	/* sw disabled at reset */
+	static_key_slow_inc_deferred(&apic_sw_disabled);
 	kvm_lapic_reset(vcpu);
 	kvm_iodevice_init(&apic->dev, &apic_mmio_ops);
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d49a9d2..ade89a1 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6565,7 +6565,7 @@ static void account_event(struct perf_event *event)
 		return;
 
 	if (event->attach_state & PERF_ATTACH_TASK)
-		static_key_slow_inc(&perf_sched_events.key);
+		static_key_slow_inc_deferred(&perf_sched_events);
 	if (event->attr.mmap || event->attr.mmap_data)
 		atomic_inc(&nr_mmap_events);
 	if (event->attr.comm)
@@ -6577,9 +6577,9 @@ static void account_event(struct perf_event *event)
 			tick_nohz_full_kick_all();
 	}
 	if (has_branch_stack(event))
-		static_key_slow_inc(&perf_sched_events.key);
+		static_key_slow_inc_deferred(&perf_sched_events);
 	if (is_cgroup_event(event))
-		static_key_slow_inc(&perf_sched_events.key);
+		static_key_slow_inc_deferred(&perf_sched_events);
 
 	account_event_cpu(event, event->cpu);
 }
-- 
1.8.3.1

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

* Re: [PATCH 4/7] static_key: use static_key_slow_inc_deferred()
  2013-10-17 10:10 ` [PATCH 4/7] static_key: use static_key_slow_inc_deferred() Radim Krčmář
@ 2013-10-17 10:39   ` Paolo Bonzini
  2013-10-18  7:29     ` Radim Krčmář
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2013-10-17 10:39 UTC (permalink / raw)
  To: Radim Krčmář
  Cc: linux-kernel, Gleb Natapov, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, kvm

Il 17/10/2013 12:10, Radim Krčmář ha scritto:
> Simple replacement where possible.
> Saves us problematic access to the structure and allows optimalizations
> and bug fixes to take place.

I think you should introduce this first as a simple wrapper around
static_key_slow_inc, and then add the bells and whistles you have in
patches 2 and 3.

Paolo

> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/lapic.c | 7 ++++---
>  kernel/events/core.c | 6 +++---
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 5439117..eff85f6 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -121,7 +121,7 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val)
>  		if (val & APIC_SPIV_APIC_ENABLED)
>  			static_key_slow_dec_deferred(&apic_sw_disabled);
>  		else
> -			static_key_slow_inc(&apic_sw_disabled.key);
> +			static_key_slow_inc_deferred(&apic_sw_disabled);
>  	}
>  	apic_set_reg(apic, APIC_SPIV, val);
>  }
> @@ -1351,7 +1351,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
>  		if (value & MSR_IA32_APICBASE_ENABLE)
>  			static_key_slow_dec_deferred(&apic_hw_disabled);
>  		else
> -			static_key_slow_inc(&apic_hw_disabled.key);
> +			static_key_slow_inc_deferred(&apic_hw_disabled);
>  		recalculate_apic_map(vcpu->kvm);
>  	}
>  
> @@ -1546,7 +1546,8 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
>  	kvm_lapic_set_base(vcpu,
>  			APIC_DEFAULT_PHYS_BASE | MSR_IA32_APICBASE_ENABLE);
>  
> -	static_key_slow_inc(&apic_sw_disabled.key); /* sw disabled at reset */
> +	/* sw disabled at reset */
> +	static_key_slow_inc_deferred(&apic_sw_disabled);
>  	kvm_lapic_reset(vcpu);
>  	kvm_iodevice_init(&apic->dev, &apic_mmio_ops);
>  
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index d49a9d2..ade89a1 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6565,7 +6565,7 @@ static void account_event(struct perf_event *event)
>  		return;
>  
>  	if (event->attach_state & PERF_ATTACH_TASK)
> -		static_key_slow_inc(&perf_sched_events.key);
> +		static_key_slow_inc_deferred(&perf_sched_events);
>  	if (event->attr.mmap || event->attr.mmap_data)
>  		atomic_inc(&nr_mmap_events);
>  	if (event->attr.comm)
> @@ -6577,9 +6577,9 @@ static void account_event(struct perf_event *event)
>  			tick_nohz_full_kick_all();
>  	}
>  	if (has_branch_stack(event))
> -		static_key_slow_inc(&perf_sched_events.key);
> +		static_key_slow_inc_deferred(&perf_sched_events);
>  	if (is_cgroup_event(event))
> -		static_key_slow_inc(&perf_sched_events.key);
> +		static_key_slow_inc_deferred(&perf_sched_events);
>  
>  	account_event_cpu(event, event->cpu);
>  }
> 

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

* Re: [PATCH 4/7] static_key: use static_key_slow_inc_deferred()
  2013-10-17 10:39   ` Paolo Bonzini
@ 2013-10-18  7:29     ` Radim Krčmář
  0 siblings, 0 replies; 3+ messages in thread
From: Radim Krčmář @ 2013-10-18  7:29 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: linux-kernel, Gleb Natapov, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, kvm

2013-10-17 12:39+0200, Paolo Bonzini:
> Il 17/10/2013 12:10, Radim Krčmář ha scritto:
> > Simple replacement where possible.
> > Saves us problematic access to the structure and allows optimalizations
> > and bug fixes to take place.
> 
> I think you should introduce this first as a simple wrapper around
> static_key_slow_inc, and then add the bells and whistles you have in
> patches 2 and 3.

Ok, thanks.

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

end of thread, other threads:[~2013-10-18  7:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1382004631-25895-1-git-send-email-rkrcmar@redhat.com>
2013-10-17 10:10 ` [PATCH 4/7] static_key: use static_key_slow_inc_deferred() Radim Krčmář
2013-10-17 10:39   ` Paolo Bonzini
2013-10-18  7:29     ` Radim Krčmář

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