Still looking at bug #195 which shows up occasionally upon boot, and
now, I can recreate by generating a lot of traffic over the serial line
into Xen (holding down 'r' to print the run queues).
I started comparing how Xen sets up and calibrates the timers with
Linux and have a few questions where they differ.
In Linux, the i386 and x86_64 set up the pit timer using
binary, mode 2, LSB/MSB, ch 0, and then periodically read PIT_CH0 to
obtain a count. Linux also uses PIT CH2 to do some calibration.
Xen, in xen/arch/x86/i8259.c sets up the PIT in the same manner (binary,
mode 2, LSB/MSB, ch 0) but as far as I can see, PIT_CH0 is never used
again, specifically, PIT_CH0 is not used when handling a timer
interrupt.
Instead, in xen/arch/x86/time.c, when Xen uses PIT as the platform timer,
it runs pit_read_counter() which gets a count from PIT_CH2, which was
used during calibrate_boot_tsc() but in mode 0.
I don't fully understand the different modes of the PIT, but looking at
the some intel [1]documentation I see:
MODE 0: INTERRUPT ON TERMINAL COUNT
Mode 0 is typically used for event counting After the Control Word
is written OUT is initially low and will remain low until the
Counter reaches zero OUT then goes high and remains high until a new
count or a new Mode 0 Control Word is written into the Counter
MODE 2 RATE GENERATOR
This Mode functions like a divide-by-N counter It is typicially used
to generate a Real Time Clock interrupt OUT will initially be high
When the initial count has decremented to 1 OUT goes low for one CLK
pulse OUT then goes high again the Counter reloads the initial count
and the process is repeated Mode 2 is periodic the same sequence is
repeated indefinitely For an initial count of N the sequence repeats
every N CLK cycles
Why does Xen chose to use mode 0, on PIT CH2 for calculating how much
time has passed rather than how Linux using PIT_CH0 in mode 2? Are
there some trade offs?
1. http://www.cs.utexas.edu/users/dahlin/Classes/UGOS/reading/82C54.pdf
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253 T/L: 678-9253
ryanh@xxxxxxxxxx
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|