Re: Improving the kernel/i386 timecounter performance (GSoC proposal)

From: Maxim Sobolev <sobomax_at_FreeBSD.org>
Date: Mon, 30 Mar 2009 18:31:06 -0700
Peter Jeremy wrote:
> On 2009-Mar-29 08:35:45 +0800, David Xu <davidxu_at_freebsd.org> wrote:
>> Julian Elischer wrote:
>>> interestingly it is even feasible to have a per-thread page..
>>> it requires that the scheduler change a page table entry tough.
>> I will knock his door at midnight if he added such a heavy weight
>> task in the scheduler, TLB shutdown is horrible, and big code size
>> squeezing out data from CPU cache is not idea model.
>> scheduler should be as simple as just a context switching routine.
> 
> If the TSC is not consistent between all cores (which is probably
> the most common situation at present), then using the TSC implies
> knowing which core you are executing on.  From a userland perspective,
> the easiest way to do this is to have a page of data that varies
> depending on which core you are executing on.

It's not that easy, unless you can pin thread to a specific core before 
reading that page. I.e. imagine the case when your thread reads per-cpu 
page, get preempted and scheduled to a different core, then executes 
RDTSC there, still thinking it got TSC reading from the first core. Even 
if it does re-read from that page again after reading TSC to determine 
if he has read the correct TSC, still it's possible (though not very 
likely) that it has been preempted again and scheduled to the first core 
after reading the TSC.

-Maxim
Received on Mon Mar 30 2009 - 23:31:13 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:45 UTC