The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Arjan van de Ven <arjan@infradead.org>
Cc: Andi Kleen <andi@firstfloor.org>,
	Venkatesh Pallipadi <venki@google.com>,
	Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
	chris.mason@oracle.com, linux-kernel@vger.kernel.org
Subject: RE: [PATCH] x86: Export tsc related information in sysfs
Date: Sun, 16 May 2010 18:31:30 -0700 (PDT)	[thread overview]
Message-ID: <5adf3fee-0f7b-4039-b13f-619640cc4b88@default> (raw)
In-Reply-To: <alpine.LFD.2.00.1005161925480.3368@localhost.localdomain>

> > > From: Thomas Gleixner [mailto:tglx@linutronix.de]
> > > What we can talk about is a vget_tsc_raw() interface along with a
> 
> What I have in mind and what I'm working on for quite a while is going
> to work on both bare metal and VMs w/o hidden slowness.

Well, if this can be done today/soon and is fast enough
(say <2x the cycles of a rdtsc), I am very interested and
"won't let my friends use rdtsc" :-)  Anything I can do
to help?

> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> We try to use it for performance sake, but the kernel does at least
> it's very best to find out when it goes bad. We then switch back to a
> hpet or pm-timer which is horrible performance wise but does not screw
> up timekeeping and everything which relies on it completely.
>  :
> As I said, we try our very best to determine when things go awry, but
> there are small errors which occur either sporadic or after longer
> uptime which we cannot yet detect reliably. Multi-socket falls into
> that category, but we are working on that.

> From: Arjan van de Ven [mailto:arjan@infradead.org]
> Why do you think we do extensive and continuous validation of the tsc
> (and soon, continuous recalibration)

So the kernel has the ability to detect that the TSC
is "OK for now", but must use some kind of polling
(periodic warp test) to recognize that TSC has
gone "bad".  As long as TSC is good AND a sophisticated
enterprise app understands that TSC might go bad at
some point in the future AND if the kernel exposes
"goodness" information AND the app (like the kernel) is
resilient** to the possibility that there might be some
period of time that obtained timestamps might be
"bad" before the app polls the kernel to find out that
the kernel says they are indeed "bad"... why should it
be forbidden for an app to use TSC?

(** e.g. increments its own tsc_last to ensure time never goes
backwards)

It seems like the only advantages the kernel has here over
a reasonably intelligent app is that: 1) the kernel can run
a warp test and the app can't, and 2) the kernel can
estimate the frequency of the TSC and the app can't.
AND, in the case of a virtual machine, the kernel has
neither of these advantages anyway.

So though I now understand and agree that neither the kernel
nor an app can guarantee that TSC won't unexpectedly go from
"good" to "bad", I still don't understand why "TSC goodness"
information shouldn't be exposed to userland, where an
intelligent enterprise app can choose to use TSC when it is good
(for the same reason the kernel does: "for performance sake")
and choose to stop using it when it goes bad (for the same
reason the kernel does: to "not screw up timekeeping").

It sounds as if you are saying that "the kernel is allowed
to use a rope because if it accidentally gets the rope
around its neck, it has a knife to ensure it doesn't hang
itself" BUT "the app isn't allowed to use a rope because
it might hang itself and we'll be damned if we loan
our knife to an app because, well... because it doesn't
need a knife because we said it shouldn't use the rope".

I think you can understand why this isn't a very satisfying
explanation.

P.S. Thanks for taking the time to discuss this!


  reply	other threads:[~2010-05-17  1:33 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-15  1:40 [PATCH] x86: Export tsc related information in sysfs Venkatesh Pallipadi
2010-05-15  9:57 ` Andi Kleen
2010-05-15 13:29   ` Dan Magenheimer
2010-05-15 16:48     ` Venkatesh Pallipadi
2010-05-15 19:14     ` Arjan van de Ven
2010-05-15 22:32       ` Dan Magenheimer
2010-05-16  5:43         ` Arjan van de Ven
2010-05-16  9:20           ` Thomas Gleixner
2010-05-16 16:42             ` Dan Magenheimer
2010-05-16 19:14               ` Thomas Gleixner
2010-05-17  1:31                 ` Dan Magenheimer [this message]
2010-05-17  5:06                   ` Arjan van de Ven
2010-05-18  9:58                     ` Peter Zijlstra
2010-05-18 10:03                       ` Peter Zijlstra
2010-05-18 11:25                       ` Andi Kleen
2010-05-18 11:58                         ` Peter Zijlstra
2010-05-18 15:13                           ` Dan Magenheimer
2010-05-18 16:40                           ` H. Peter Anvin
2010-05-18 16:52                             ` Peter Zijlstra
2010-05-18 17:04                               ` H. Peter Anvin
2010-05-18 17:49                                 ` Dan Magenheimer
2010-05-18 18:46                                   ` H. Peter Anvin
2010-05-18 19:00                                     ` Dan Magenheimer
2010-05-18 19:16                                       ` Dan Magenheimer
2010-05-18 19:26                                         ` H. Peter Anvin
2010-05-18 20:29                                           ` Dan Magenheimer
2010-05-18 20:34                                             ` H. Peter Anvin
2010-05-18 21:02                                               ` Dan Magenheimer
2010-05-18 21:13                                               ` Andi Kleen
2010-05-19  6:26                                                 ` Peter Zijlstra
2010-05-17 10:20                   ` Thomas Gleixner
2010-05-16 20:29               ` Arjan van de Ven
2010-05-17 10:26         ` Andi Kleen
2010-06-04 14:24           ` Pavel Machek
2010-05-15 22:45     ` Thomas Gleixner
2010-05-17 10:22     ` Andi Kleen
2010-05-17 15:23       ` Dan Magenheimer
2010-05-17 16:56         ` Andi Kleen
2010-05-17 22:36         ` Thomas Gleixner
2010-05-17 23:33           ` Dan Magenheimer
2010-05-18  0:00             ` Ingo Molnar
2010-05-18  0:02             ` Ingo Molnar
2010-05-15 12:35 ` Jaswinder Singh Rajput
2010-05-15 14:37   ` Venkatesh Pallipadi
  -- strict thread matches above, loose matches on Subject: below --
2010-05-20 19:19 Brian Bloniarz
2010-05-22  2:03 ` john stultz
2010-05-22  3:33   ` H. Peter Anvin
2010-05-24 18:13   ` Dan Magenheimer
2010-05-24 18:19     ` H. Peter Anvin
2010-05-24 18:51     ` john stultz
2010-05-24 20:20       ` H. Peter Anvin
2010-05-24 20:39         ` john stultz
2010-05-24 21:26           ` H. Peter Anvin
2010-05-24 22:04           ` Dan Magenheimer
2010-05-24 22:30             ` H. Peter Anvin
2010-05-24 22:49               ` john stultz
2010-05-24 23:16                 ` Dan Magenheimer
2010-05-24 23:19                   ` H. Peter Anvin
2010-05-24 23:30                   ` john stultz
2010-05-24 23:42                     ` Andi Kleen
2010-05-25  0:01                     ` Dan Magenheimer
2010-05-25  0:07                       ` H. Peter Anvin
2010-05-25  1:33               ` Brian Bloniarz
2010-05-26  0:16                 ` Brian Bloniarz
2010-05-26  0:48                   ` john stultz
2010-05-26  2:50                     ` Brian Bloniarz
2010-05-26 12:35                       ` Thomas Gleixner
2010-05-26 14:26                         ` Dan Magenheimer
2010-05-26 14:41                           ` Thomas Gleixner
2010-05-26 15:04                       ` john stultz
2010-05-26 16:02                         ` Brian Bloniarz
2010-05-26 16:25                           ` john stultz
2010-05-26 18:24                             ` H. Peter Anvin
2010-05-26 18:44                             ` Brian Bloniarz
2010-05-26 18:51                               ` H. Peter Anvin
2010-05-26 20:19                                 ` john stultz
2010-05-26 21:06                                   ` H. Peter Anvin
2010-05-26 19:49                               ` john stultz
2010-05-26 20:22                                 ` Brian Bloniarz
2010-05-26 12:30                   ` Thomas Gleixner

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=5adf3fee-0f7b-4039-b13f-619640cc4b88@default \
    --to=dan.magenheimer@oracle.com \
    --cc=andi@firstfloor.org \
    --cc=arjan@infradead.org \
    --cc=chris.mason@oracle.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=venki@google.com \
    /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