LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] x86: remove unused code in set_cyc2ns_scale()
@ 2008-01-29 21:15 Guillaume Chazarain
  2008-01-31 15:21 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Guillaume Chazarain @ 2008-01-29 21:15 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Linux Kernel Mailing List, Thomas Gleixner, H. Peter Anvin,
	Guillaume Chazarain

This should be fold into:
4f95bd6e2b21a8c724357463f8341502d47aba13
x86: scale cyc_2_nsec according to CPU frequency

Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
---
 arch/x86/kernel/tsc_32.c |   14 +++++---------
 arch/x86/kernel/tsc_64.c |   14 +++++---------
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c
index 43517e3..e05e221 100644
--- a/arch/x86/kernel/tsc_32.c
+++ b/arch/x86/kernel/tsc_32.c
@@ -83,20 +83,16 @@ DEFINE_PER_CPU(unsigned long, cyc2ns);
 
 static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
 {
-	unsigned long flags, prev_scale, *scale;
-	unsigned long long tsc_now, ns_now;
+	unsigned long flags, *scale;
+
+	if (!cpu_khz)
+		return;
 
 	local_irq_save(flags);
 	sched_clock_idle_sleep_event();
 
 	scale = &per_cpu(cyc2ns, cpu);
-
-	rdtscll(tsc_now);
-	ns_now = __cycles_2_ns(tsc_now);
-
-	prev_scale = *scale;
-	if (cpu_khz)
-		*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
+	*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
 
 	/*
 	 * Start smoothly with the new frequency:
diff --git a/arch/x86/kernel/tsc_64.c b/arch/x86/kernel/tsc_64.c
index 947554d..e0e9d4f 100644
--- a/arch/x86/kernel/tsc_64.c
+++ b/arch/x86/kernel/tsc_64.c
@@ -44,20 +44,16 @@ DEFINE_PER_CPU(unsigned long, cyc2ns);
 
 static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
 {
-	unsigned long flags, prev_scale, *scale;
-	unsigned long long tsc_now, ns_now;
+	unsigned long flags, *scale;
+
+	if (!cpu_khz)
+		return;
 
 	local_irq_save(flags);
 	sched_clock_idle_sleep_event();
 
 	scale = &per_cpu(cyc2ns, cpu);
-
-	rdtscll(tsc_now);
-	ns_now = __cycles_2_ns(tsc_now);
-
-	prev_scale = *scale;
-	if (cpu_khz)
-		*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
+	*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
 
 	sched_clock_idle_wakeup_event(0);
 	local_irq_restore(flags);
-- 
1.5.3.7


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

* Re: [PATCH] x86: remove unused code in set_cyc2ns_scale()
  2008-01-29 21:15 [PATCH] x86: remove unused code in set_cyc2ns_scale() Guillaume Chazarain
@ 2008-01-31 15:21 ` Ingo Molnar
  2008-01-31 19:18   ` Guillaume Chazarain
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2008-01-31 15:21 UTC (permalink / raw)
  To: Guillaume Chazarain
  Cc: Linux Kernel Mailing List, Thomas Gleixner, H. Peter Anvin


* Guillaume Chazarain <guichaz@yahoo.fr> wrote:

>  arch/x86/kernel/tsc_32.c |   14 +++++---------
>  arch/x86/kernel/tsc_64.c |   14 +++++---------
>  2 files changed, 10 insertions(+), 18 deletions(-)

>  static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
>  {
> -	unsigned long flags, prev_scale, *scale;
> -	unsigned long long tsc_now, ns_now;
> +	unsigned long flags, *scale;
> +
> +	if (!cpu_khz)
> +		return;
>  
>  	local_irq_save(flags);
>  	sched_clock_idle_sleep_event();
>  
>  	scale = &per_cpu(cyc2ns, cpu);
> -
> -	rdtscll(tsc_now);
> -	ns_now = __cycles_2_ns(tsc_now);
> -
> -	prev_scale = *scale;
> -	if (cpu_khz)
> -		*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
> +	*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;

hm, this is not a pure elimination of dead code, this will change 
behavior. For example we wont call sched_clock_idle_sleep_event() on 
!cpu_khz now. Hm?

	Ingo

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

* Re: [PATCH] x86: remove unused code in set_cyc2ns_scale()
  2008-01-31 15:21 ` Ingo Molnar
@ 2008-01-31 19:18   ` Guillaume Chazarain
  0 siblings, 0 replies; 3+ messages in thread
From: Guillaume Chazarain @ 2008-01-31 19:18 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel Mailing List, Thomas Gleixner, H. Peter Anvin

On 1/31/08, Ingo Molnar <mingo@elte.hu> wrote:
> hm, this is not a pure elimination of dead code, this will change
> behavior. For example we wont call sched_clock_idle_sleep_event() on
> !cpu_khz now. Hm?

Oops, indeed I overlooked that. OTOH, I can't see how it can happen
(in 32 bit at least), and even if it happens it should not have any
effect. But I'll keep this check to avoid making this case illegal.

Thanks for the review.

-- 
Guillaume

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

end of thread, other threads:[~2008-01-31 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-29 21:15 [PATCH] x86: remove unused code in set_cyc2ns_scale() Guillaume Chazarain
2008-01-31 15:21 ` Ingo Molnar
2008-01-31 19:18   ` Guillaume Chazarain

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