lkml.org 
[lkml]   [2014]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC/HACK] x86: Fast return to kernel
From
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.

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.

Hmm?

Linus


\
 
 \ /
  Last update: 2014-05-05 00:01    [W:0.194 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site