Re: [PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Ingo Molnar

* Guillaume Chazarain <[EMAIL PROTECTED]> wrote:

> >+static int tsc_enabled;
> 
> So, now we have tsc_disable, tsc_enabled and tsc_unstable. I can 
> understand the latter, but this lacks orthogonality IMHO.

tsc_disable should be renamed to tsc_disable_override or so, to signal 
that it's only the mirror of the 'notsc' flag the user passed in over 
the boot line.

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Guillaume Chazarain

+static int tsc_enabled;


So, now we have tsc_disable, tsc_enabled and tsc_unstable.
I can understand the latter, but this lacks orthogonality IMHO.

--
Guillaume
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Ingo Molnar

* Thomas Gleixner <[EMAIL PROTECTED]> wrote:

> commit f9690982b8c2f9a2c65acdc113e758ec356676a3 removed the check for 
> cpu_khz from sched_clock(), which prevented early access to the TSC by 
> non obvious magic.
> 
> This is harmless as long as the CPU has a TSC. On TSCless systems this 
> results in an illegal instruction trap.
> 
> Replace tsc_disabled and tsc_unstable by tsc_enabled, which is only 
> set when the tsc is available and not unstable.
> 
> Signed-off-by: Thomas Gleixner <[EMAIL PROTECTED]>

oops, indeed! I think this should also resolve one of the bugs (TSC-less 
Cyrix?) that were reported against -mm some time ago.

Acked-by: Ingo Molnar <[EMAIL PROTECTED]>

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Thomas Gleixner
commit f9690982b8c2f9a2c65acdc113e758ec356676a3 removed the check for
cpu_khz from sched_clock(), which prevented early access to the TSC by
non obvious magic.

This is harmless as long as the CPU has a TSC. On TSCless systems this
results in an illegal instruction trap.

Replace tsc_disabled and tsc_unstable by tsc_enabled, which is only set
when the tsc is available and not unstable.

Signed-off-by: Thomas Gleixner <[EMAIL PROTECTED]>

diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index 0e65f7a..6cb8f53 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -18,6 +18,8 @@
 
 #include "mach_timer.h"
 
+static int tsc_enabled;
+
 /*
  * On some systems the TSC frequency does not
  * change with the cpu frequency. So we need
@@ -105,7 +107,7 @@ unsigned long long sched_clock(void)
/*
 * Fall back to jiffies if there's no TSC available:
 */
-   if (tsc_unstable || unlikely(tsc_disable))
+   if (unlikely(!tsc_enabled))
/* No locking but a rare wrong value is not a big deal: */
return (jiffies_64 - INITIAL_JIFFIES) * (10 / HZ);
 
@@ -283,6 +285,7 @@ void mark_tsc_unstable(void)
 {
if (!tsc_unstable) {
tsc_unstable = 1;
+   tsc_enabled = 0;
/* Can be called before registration */
if (clocksource_tsc.mult)
clocksource_change_rating(_tsc, 0);
@@ -383,7 +386,9 @@ void __init tsc_init(void)
if (check_tsc_unstable()) {
clocksource_tsc.rating = 0;
clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
-   }
+   } else
+   tsc_enabled = 1;
+
clocksource_register(_tsc);
 
return;




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Thomas Gleixner
commit f9690982b8c2f9a2c65acdc113e758ec356676a3 removed the check for
cpu_khz from sched_clock(), which prevented early access to the TSC by
non obvious magic.

This is harmless as long as the CPU has a TSC. On TSCless systems this
results in an illegal instruction trap.

Replace tsc_disabled and tsc_unstable by tsc_enabled, which is only set
when the tsc is available and not unstable.

Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]

diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index 0e65f7a..6cb8f53 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -18,6 +18,8 @@
 
 #include mach_timer.h
 
+static int tsc_enabled;
+
 /*
  * On some systems the TSC frequency does not
  * change with the cpu frequency. So we need
@@ -105,7 +107,7 @@ unsigned long long sched_clock(void)
/*
 * Fall back to jiffies if there's no TSC available:
 */
-   if (tsc_unstable || unlikely(tsc_disable))
+   if (unlikely(!tsc_enabled))
/* No locking but a rare wrong value is not a big deal: */
return (jiffies_64 - INITIAL_JIFFIES) * (10 / HZ);
 
@@ -283,6 +285,7 @@ void mark_tsc_unstable(void)
 {
if (!tsc_unstable) {
tsc_unstable = 1;
+   tsc_enabled = 0;
/* Can be called before registration */
if (clocksource_tsc.mult)
clocksource_change_rating(clocksource_tsc, 0);
@@ -383,7 +386,9 @@ void __init tsc_init(void)
if (check_tsc_unstable()) {
clocksource_tsc.rating = 0;
clocksource_tsc.flags = ~CLOCK_SOURCE_IS_CONTINUOUS;
-   }
+   } else
+   tsc_enabled = 1;
+
clocksource_register(clocksource_tsc);
 
return;




-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Ingo Molnar

* Thomas Gleixner [EMAIL PROTECTED] wrote:

 commit f9690982b8c2f9a2c65acdc113e758ec356676a3 removed the check for 
 cpu_khz from sched_clock(), which prevented early access to the TSC by 
 non obvious magic.
 
 This is harmless as long as the CPU has a TSC. On TSCless systems this 
 results in an illegal instruction trap.
 
 Replace tsc_disabled and tsc_unstable by tsc_enabled, which is only 
 set when the tsc is available and not unstable.
 
 Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]

oops, indeed! I think this should also resolve one of the bugs (TSC-less 
Cyrix?) that were reported against -mm some time ago.

Acked-by: Ingo Molnar [EMAIL PROTECTED]

Ingo
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Guillaume Chazarain

+static int tsc_enabled;


So, now we have tsc_disable, tsc_enabled and tsc_unstable.
I can understand the latter, but this lacks orthogonality IMHO.

--
Guillaume
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

2007-03-24 Thread Ingo Molnar

* Guillaume Chazarain [EMAIL PROTECTED] wrote:

 +static int tsc_enabled;
 
 So, now we have tsc_disable, tsc_enabled and tsc_unstable. I can 
 understand the latter, but this lacks orthogonality IMHO.

tsc_disable should be renamed to tsc_disable_override or so, to signal 
that it's only the mirror of the 'notsc' flag the user passed in over 
the boot line.

Ingo
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/