Skip to contentSkip to conversation

How to increase timer resolution?

DISCUSSION Robert Kaiser 2 participants 6 messages Sep 14, 2008

lore
Share & tools
lore
#0 lore raw

Hi everyone,

I'm using Xen 3.2.1 in my experimental setup, trying to find relationships between switch frequencies and overheads. For that, it would be good if I could increase the resolution of the timer (i.e. the one that you access with set_timer(), stop_timer() and friends). Currently, this seems to be fixed at 10 milliseconds, but I would like to change it to 1ms or maybe even down to a few hundred microseconds. I'm aware that this will affect performance -- that is part of what I'd like to measure.

Can you experts give me some hints how to do this, i.e. is it just a matter of giving the kernel the right commandline options (which?), can it be done by
changing a few compile time constants (which? where?), or is there more
involved?

Ideally, I would implement a new control function by which dom0 could change the frequency dynamically at run-time, but even having to re-compile Xen between experiments might be an acceptable approach. However, the code base is so dauntingly huge for a newbie like myself, I'm having difficulties in finding the right set-screws. Can anyone help me out?

Cheers

Rob

Signature · 4 lines
Robert Kaiser                    http://wwwvs.informatik.fh-wiesbaden.de
Labor für Verteilte Systeme            [email protected]
FH Wiesbaden - University of Applied Sciences     tel: (+49)611-9495-1294
Kurt-Schumacher-Ring 18, 65197 Wiesbaden, Germany fax: (+49)611-9495-1289
#1 lore raw

set_timer() and friends are already high-resolution, so long as your system has a local APIC. This is undoubtedly the case if running a multi-processor system. On a uni-processor system you might need to forcibly enable use of the APIC with 'lapic' as a Xen boot parameter.

Either way, early during boot you should find a message saying local APIC is found and enabled, or not found, or whatever.

-- Keir

Quoted 24 lines · Robert Kaiser

Hi everyone,

I'm using Xen 3.2.1 in my experimental setup, trying to find relationships between switch frequencies and overheads. For that, it would be good if I could increase the resolution of the timer (i.e. the one that you access with set_timer(), stop_timer() and friends). Currently, this seems to be fixed at 10 milliseconds, but I would like to change it to 1ms or maybe even down to a few hundred microseconds. I'm aware that this will affect performance -- that is part of what I'd like to measure.

Can you experts give me some hints how to do this, i.e. is it just a matter of giving the kernel the right commandline options (which?), can it be done by
changing a few compile time constants (which? where?), or is there more
involved?

Ideally, I would implement a new control function by which dom0 could change the frequency dynamically at run-time, but even having to re-compile Xen between experiments might be an acceptable approach. However, the code base is so dauntingly huge for a newbie like myself, I'm having difficulties in finding the right set-screws. Can anyone help me out?

Cheers

Rob

#2 lore raw

Hi Keir,

thanks for your quick response

Quoted 8 lines · Keir Fraser

set_timer() and friends are already high-resolution, so long as your system has a local APIC. This is undoubtedly the case if running a multi-processor system. On a uni-processor system you might need to forcibly enable use of the APIC with 'lapic' as a Xen boot parameter.

Either way, early during boot you should find a message saying local APIC is found and enabled, or not found, or whatever.

Quote:

(XEN) Local APIC disabled by BIOS -- reenabling.
(XEN) Could not enable APIC!

Seems like I have to switch to a different testing machine then, the old notebook I was using doesn't seem to have an APIC :-(

Do you know what resolution I can expect to get on an APIC-enabled machine?

Rob

Quoted 33 lines

-- Keir

Quoted 25 lines · Robert Kaiser

Hi everyone,

I'm using Xen 3.2.1 in my experimental setup, trying to find relationships between switch frequencies and overheads. For that, it would be good if I could increase the resolution of the timer (i.e. the one that you access with set_timer(), stop_timer() and friends). Currently, this seems to be fixed at 10 milliseconds, but I would like to change it to 1ms or maybe even down to a few hundred microseconds. I'm aware that this will affect performance -- that is part of what I'd like to measure.

Can you experts give me some hints how to do this, i.e. is it just a matter of giving the kernel the right commandline options (which?), can it be done by
changing a few compile time constants (which? where?), or is there more
involved?

Ideally, I would implement a new control function by which dom0 could change the frequency dynamically at run-time, but even having to re-compile Xen between experiments might be an acceptable approach. However, the code base is so dauntingly huge for a newbie like myself, I'm having difficulties in finding the right set-screws. Can anyone help me out?

Cheers

Rob

#3 lore raw
Quoted 12 lines · Robert Kaiser (FH)
Quoted 8 lines · Keir Fraser

set_timer() and friends are already high-resolution, so long as your system has a local APIC. This is undoubtedly the case if running a multi-processor system. On a uni-processor system you might need to forcibly enable use of the APIC with 'lapic' as a Xen boot parameter.

Either way, early during boot you should find a message saying local APIC is found and enabled, or not found, or whatever.

Quote:

Quoted 7 lines

(XEN) Local APIC disabled by BIOS -- reenabling.
(XEN) Could not enable APIC!

Seems like I have to switch to a different testing machine then, the old notebook I was using doesn't seem to have an APIC :-(

Do you know what resolution I can expect to get on an APIC-enabled machine?

The set_timer() infrastructure is not actually tick-based. With an APIC you'll get timer accuracy of around 100us (this figure because we service timer handlers up to 100us before the deadline specified to set_timer(), just to avoid multiple timer interrupts for close-together events). Without this extra fudge factor you'd get accuracy down to microsecond resolution.

-- Keir

#4 lore raw
Quoted 5 lines · On Sunday 14 September 2008 18:41:05 Keir Fraser wrote:

The set_timer() infrastructure is not actually tick-based. With an APIC you'll get timer accuracy of around 100us (this figure because we service timer handlers up to 100us before the deadline specified to set_timer(), just to avoid multiple timer interrupts for close-together events). Without this extra fudge factor you'd get accuracy down to microsecond resolution.

Aha, the TIME_SLOP constant, right? So is it safe to simply reduce this to -say- 10us in order to get a 20us resolution? Will check his out as soon as I have a suitable test machine.

Thanks again

Rob

Signature · 4 lines
Robert Kaiser                    http://wwwvs.informatik.fh-wiesbaden.de
Labor für Verteilte Systeme            [email protected]
FH Wiesbaden - University of Applied Sciences     tel: (+49)611-9495-294
Kurt-Schumacher-Ring 18, 65197 Wiesbaden, Germany fax: (+49)611-9495-289
#5 lore raw
Quoted 10 lines · Robert Kaiser
Quoted 5 lines · On Sunday 14 September 2008 18:41:05 Keir Fraser wrote:

The set_timer() infrastructure is not actually tick-based. With an APIC you'll get timer accuracy of around 100us (this figure because we service timer handlers up to 100us before the deadline specified to set_timer(), just to avoid multiple timer interrupts for close-together events). Without this extra fudge factor you'd get accuracy down to microsecond resolution.

Aha, the TIME_SLOP constant, right? So is it safe to simply reduce this to -say- 10us in order to get a 20us resolution? Will check his out as soon as I have a suitable test machine.

Yes, frankly you can set it to zero for your purposes.

-- Keir