Messages in this thread | | | Date | Sun, 4 May 2014 14:31:23 -0700 | Subject | Re: [RFC/HACK] x86: Fast return to kernel | From | Linus Torvalds <> |
| |
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
| |