All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <h.peter.anvin@intel.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [RFC/HACK] x86: Fast return to kernel
Date: Sun, 04 May 2014 15:01:44 -0700	[thread overview]
Message-ID: <5366B8C8.3080700@intel.com> (raw)
In-Reply-To: <CA+55aFxA522TJ8ROr0AJMusvYitm2RntBfBNXAK1eych3TP=dw@mail.gmail.com>

On 05/04/2014 02:31 PM, Linus Torvalds wrote:
> On Sun, May 4, 2014 at 12:59 PM, H. Peter Anvin <h.peter.anvin@intel.com> wrote:
>>
>> Maybe let userspace sit in a tight loop doing RDTSC, and look for data
>> points too far apart to have been uninterrupted?
> 
> That won't work, since Andy's patch improves on the "interrupt
> happened in kernel space", not on the user-space interrupt case.
> 

I was thinking about your proposal, not Andy's.

> But some variation on that with a kernel module that does something like
> 
>  - take over one CPU and force tons of timer interrupts on that CPU
> using the local APIC
> 
>  - for (say) ten billion cycles, do something like this in that kernel module:
> 
>    #define TEN_BILLION (10000000000)
> 
>         unsigned long prev = 0, sum = 0, end = rdtsc() + TEN_BILLION;
>         for (;;) {
>                 unsigned long tsc = rdtsc();
>                 if (tsc > end)
>                         break;
>                 if (tsc < prev + 500) {
>                         sum += tsc - prev;
>                 }
>                 prev = tsc;
>         }
> 
> and see how big a fraction of the 10 billion cycles you capture in
> 'sum'.  The bigger the fraction, the less time the timer interrupts
> stole from your CPU.
> 
> That "500" is just a random cut-off. Any interrupt will take more than
> that many TSC cycles. So the above basically counts how much
> uninterrupted time that thread gets.

Yes, same idea, but in a kernel module.

	-hpa



  reply	other threads:[~2014-05-04 22:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-02 19:04 [RFC/HACK] x86: Fast return to kernel Andy Lutomirski
2014-05-02 19:31 ` Linus Torvalds
2014-05-02 19:50   ` Andy Lutomirski
2014-05-04 18:40     ` Ingo Molnar
2014-05-04 19:59       ` H. Peter Anvin
2014-05-04 21:31         ` Linus Torvalds
2014-05-04 22:01           ` H. Peter Anvin [this message]
2014-05-02 19:51   ` Linus Torvalds
2014-05-02 20:07     ` H. Peter Anvin
2014-05-02 20:30     ` Thomas Gleixner
2014-05-02 21:01       ` Linus Torvalds
2014-05-02 21:04         ` Andy Lutomirski
2014-05-02 21:07           ` Linus Torvalds
2014-05-02 21:37             ` H. Peter Anvin
2014-05-02 21:42               ` Andy Lutomirski
2014-05-02 21:44                 ` H. Peter Anvin
2014-05-02 21:28         ` Thomas Gleixner
2014-05-04 23:46     ` Paolo Bonzini
2014-05-04 23:49       ` H. Peter Anvin
2014-05-02 20:19   ` Steven Rostedt

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=5366B8C8.3080700@intel.com \
    --to=h.peter.anvin@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.