mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Peter Zijlstra <peterz@infradead.org>, Andi Kleen <andi@firstfloor.org>
Cc: Arjan van de Ven <arjan@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	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: Tue, 18 May 2010 08:13:34 -0700 (PDT)	[thread overview]
Message-ID: <d8d6ecc0-144a-4d7f-a1a0-5c6f290a12ca@default> (raw)
In-Reply-To: <1274183935.5605.7726.camel@twins>

> From: Peter Zijlstra [mailto:peterz@infradead.org]
> Subject: Re: [PATCH] x86: Export tsc related information in sysfs
> 
> On Tue, 2010-05-18 at 13:25 +0200, Andi Kleen wrote:
> > On Tue, May 18, 2010 at 11:58:18AM +0200, Peter Zijlstra wrote:
> > > On Sun, 2010-05-16 at 22:06 -0700, Arjan van de Ven wrote:
> > > > look we're not disabling ring 3 tsc. We could, but we don't.
> > >
> > > Maybe we should.
> >
> > That would kill the vsyscall too. Remember it's running in ring 3.
> >
> > That is in theory you could disable it on systems where the vsyscall
> > doesn't use it, but then you would likely break huge amounts of
> software,
> > unless you emulate it.
> 
> Well, software shouldn't use it, so breaking it sounds like a fine
> idea ;-)

Last fall, I discovered that EVERY program on RHEL5 (U2?) uses rdtsc
because RHEL5 ld.so uses rdtsc.  The uses are few and harmless but
are there nonetheless.  Clearly that can be fixed, but you might
be surprised how big "huge amounts of software" is.

> Also, a slow emulation is an incentive to actually do the right thing.

Emulation is not particularly slow, especially compared to accessing
the HPET.  If the kernel deems TSC is unsafe, the ring 3 vsyscall
shouldn't be using rdtsc either so the additional trap overhead
might be in the noise.

As long as there is a sysfs file that can override the setting
and there is a counter (accessible via sysfs) that can count
the number of emulated rdtsc/rdtscp instructions (possibly
optionally by pid so the "offending" userland threads can
be tracked down), setting CR4.TSD whenever the kernel deems
TSC is unsafe and emulating rdtsc might be a reasonable solution.
Infrequent rdtsc users won't know or care, and frequent users
will at least be able to learn the frequency of their "sin".

And to help Thomas/Arjan/Ingo/Andi educate users, every read
or write to any of these sysfs files could also result in a
printk of "Use of rdtsc is deprecated... use vsyscalls instead.
See Documentation/friends_dont_let_friends_use_rdtsc."
(Half ;-)

And the sysfs file could have a "strict" setting which kills any
thread that uses rdtsc, so Thomas can tell future problem
reporters: "Set the rdtsc setting to strict and if you still
have problems, call me back."  (Other half of ;-)

  reply	other threads:[~2010-05-18 15:16 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-15  1:40 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
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 [this message]
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
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=d8d6ecc0-144a-4d7f-a1a0-5c6f290a12ca@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=peterz@infradead.org \
    --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

all inboxes | Powered by JetHome®