linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Cc: "H. Peter Anvin" <hpa@zytor.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] setup.c notsc Re: Microsecond accuracy
Date: Thu, 7 Dec 2000 19:28:05 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.21.0012071856280.1138-100000@localhost.localdomain> (raw)
In-Reply-To: <Pine.GSO.3.96.1001207165626.21086F-100000@delta.ds2.pg.gda.pl>

On Thu, 7 Dec 2000, Maciej W. Rozycki wrote:

> On 7 Dec 2000, H. Peter Anvin wrote:
> 
> > Unfortunately the most important instance of the in-kernel flag -- the
> > global one in the somewhat misnamed boot_cpu_data.x86_features --
> > isn't actually readable in the /proc/cpuinfo file.  It is perfectly
> > possible (e.g. the "notsc" option) for ALL the CPUs to report this
> > capability, but the global capability to still be off.
> 
>  Hmm, I recall I implemented and explicitly verified switching the
> /proc/cpuinfo "tsc" flag (as well as the userland access to the TSC) off
> when I wrote the code to handle the "notsc" option.  Has it changed since
> then?  I recall you modified the code a bit -- I looked at the changes
> then but I was pretty confident the semantics was preserved.

The present situation is inconsistent: "notsc" removes cpuinfo's
"tsc" flag in the UP case (when cpu_data[0] is boot_cpu_data), but
not in the SMP case.  I don't believe HPA's recent mods affected that
behaviour, but it is made consistent (cleared in SMP case too) by the
patch I sent him a couple of days ago, below updated for test12-pre7...

I didn't test userland access to the TSC, but my reading of the code
was that prior to this patch, it would be disallowed on the boot cpu,
but still allowed on auxiliaries - because disable_tsc set X86_CR4_TSD
if cpu_has_tsc, but initing boot cpu forces cpu_has_tsc to !cpu_has_tsc.

My patch description was:
identify_cpu() re-evaluates x86_capability, which left cpu_has_tsc true
(and cpu MHz shown as 0.000) in non-SMP "notsc" case: #ifdef CONFIG_TSC
was bogus.  And set X86_CR4_TSD here when testing this cpu's capability,
not where cpu_init() tests cpu_has_tsc (boot_cpu's adjusted capability).

I have removed the "FIX-HPA" comment line: of course, that's none of my
business, but if you approve the patch I imagine you'd want that to go too
(I agree it's a bit ugly there, but safest to disable cpu_has_tsc soonest).

Hugh

--- test12-pre7/arch/i386/kernel/setup.c	Thu Dec  7 17:25:55 2000
+++ linux/arch/i386/kernel/setup.c	Thu Dec  7 17:56:35 2000
@@ -1999,10 +1999,14 @@
 	 * we do "generic changes."
 	 */
 
+#ifndef CONFIG_X86_TSC
 	/* TSC disabled? */
-#ifdef CONFIG_TSC
-	if ( tsc_disable )
-		clear_bit(X86_FEATURE_TSC, &c->x86_capability);
+	if ( test_bit(X86_FEATURE_TSC, &c->x86_capability) ) {
+		if (tsc_disable || !cpu_has_tsc) {
+			clear_bit(X86_FEATURE_TSC, &c->x86_capability);
+			set_in_cr4(X86_CR4_TSD);
+		}
+	}
 #endif
 
 	/* Disable the PN if appropriate */
@@ -2218,9 +2222,7 @@
 #ifndef CONFIG_X86_TSC
 	if (tsc_disable && cpu_has_tsc) {
 		printk("Disabling TSC...\n");
-		/**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
 		clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
-		set_in_cr4(X86_CR4_TSD);
 	}
 #endif
 

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

  reply	other threads:[~2000-12-07 19:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-07 11:42 Microsecond accuracy Kotsovinos Vangelis
2000-12-07 12:36 ` Tigran Aivazian
2000-12-07 14:13   ` Tigran Aivazian
2000-12-07 15:33     ` H. Peter Anvin
2000-12-07 16:07       ` Maciej W. Rozycki
2000-12-07 19:28         ` Hugh Dickins [this message]
2000-12-07 20:48           ` [PATCH] setup.c notsc " Maciej W. Rozycki
2000-12-13 14:10           ` H. Peter Anvin
2000-12-07 16:54 ` Christopher Friesen
2000-12-08  0:17   ` Kotsovinos Vangelis
2000-12-07 21:14 ` Karim Yaghmour
2000-12-08  0:18   ` Kotsovinos Vangelis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0012071856280.1138-100000@localhost.localdomain \
    --to=hugh@veritas.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@ds2.pg.gda.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).