Skip to contentSkip to conversation

million cycle interrupt

DISCUSSION Dan Magenheimer 4 participants 19 messages Apr 12, 2009 – Apr 14, 2009

lore
Share & tools
lore
#0 lore raw

(I realize my last similar topic turned out to be a false alarm, so I hope I am not "crying wolf" again.)

I'm still trying to understand some anomalous measurements in tmem, particularly instances where the maximum cycle count greatly exceeds the average. It seems that tmem's compression code is a magnet for interruptions. This inspired me to create a more controlled magnet, an "interrupt honeypot". To do this, at every tmem call, I run a loop which does nothing but repetitively read tsc and check the difference between successive reads. On both of my test machines, the measurement is normally well under 100 cycles. Infrequently, I get a "large" measurement which, since xen is non-preemptive, indicates a lengthy interrupt (or possibly that the tsc is getting moved forward). My code uses per_cpu to ensure that there aren't any measurement/recording races (which were the issue with my previous 10M "problem").

The result: On my quad-core-by-two-thread machine, I frequently get "large" measurements over 250000 cycles, with the max just over 1 million (and actually just over 2^20). Frequency averages about one every 1-2 seconds, but the measurement methodology makes it impossible to determine the true frequency or spacing. The vast majority of the "large" samples are reported on cpu#0 but a handful are reported on other cpus. This might also be methodology-related but the load is running on 4 vcpus.

On the same machine, when I run with nosmp, I see no large measurements. And when I run the load with 1 vcpu, I see a lower frequency (about one every ten seconds), but again this could be due to the measurement methodology.

On my dual-core (no SMT) test machine, I see only a couple of large measurements, 120438 cycles on cpu#0 and 120528 on cpu#1. The same load is being run, though limited to 2 vcpus.

Is a million cycles in an interrupt handler bad? Any idea what might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger machines. I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

Is there a way to cap the number of physical cpus seen by Xen (other than nosmp to cap at one)?

Dan

#1 lore raw
Quoted 8 lines · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any idea what might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger machines. I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the distribution of irq handling times for interruptions that Xen knows about. Otherwise who knows, it could even be system management mode on that particular box.

-- Keir

#2 lore raw
Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 30 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 8 lines · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any idea what might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger machines. I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management mode on that particular box.

-- Keir

#3 lore raw
Quoted 5 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Quoted 7 lines

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Since you already reach this step around calling actual action's handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print which handlers are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could be SMM. :-)

Thanks,
Kevin

Quoted 49 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 19 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 8 lines · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any idea what might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger machines. I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

Quoted 11 lines

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management mode on that particular box.

-- Keir

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Here's the relevant output. How do I map this to something meaningful?

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010 max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010 max_cycles=730972 in-flight=0 domain-list=0:255(----),

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000 max_cycles=1047500 mapped, unbound

(XEN) max_max_cycles = 1047500

Quoted 86 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 5 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Quoted 7 lines

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Since you already reach this step around calling actual action's handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print which handlers are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could be SMM. :-)

Thanks,
Kevin

Quoted 13 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Quoted 29 lines

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 24 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 8 lines · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any idea what might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger machines. I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
Quoted 17 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:34

Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Quoted 2 lines

Here's the relevant output. How do I map this to something meaningful?

One immediate trick is to print handler address for problematic vector, and then search its name in your dumpped Xen symbol file.

Thanks,
Kevin

Quoted 6 lines

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010
max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010
max_cycles=730972 in-flight=0 domain-list=0:255(----),

Above two look like owned by dom0.

Quoted 3 lines

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000
max_cycles=1047500 mapped, unbound

looks like PIT, but not quite sure.

Quoted 93 lines

(XEN) max_max_cycles = 1047500

Quoted 86 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 5 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Quoted 7 lines

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Since you already reach this step around calling actual action's handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print which handlers are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could be SMM. :-)

Thanks,
Kevin

Quoted 13 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Quoted 29 lines

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 24 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 8 lines · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any idea what might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger machines. I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw

Some more interesting data that echos my earlier
measurements:

Booting with maxcpus=4, the three "large" interrupts are all about 20000 cycles. Booting with maxcpus=6, the three are at 146896, 183260, and 240959 cycles.

So it definitely appears to get worse as maxcpus
gets larger.

I also wonder if it might be related to SMT?

Quoted 1 line

One immediate trick is to print handler address for problematic

I'll give that a try, but probably not until tomorrow.

Quoted 145 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 8:42 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 17 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:34

Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Quoted 2 lines

Here's the relevant output. How do I map this to something meaningful?

One immediate trick is to print handler address for problematic vector, and then search its name in your dumpped Xen symbol file.

Thanks,
Kevin

Quoted 6 lines

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010
max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010
max_cycles=730972 in-flight=0 domain-list=0:255(----),

Above two look like owned by dom0.

Quoted 3 lines

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000
max_cycles=1047500 mapped, unbound

looks like PIT, but not quite sure.

Quoted 66 lines

(XEN) max_max_cycles = 1047500

Quoted 60 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 5 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Quoted 7 lines

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Since you already reach this step around calling actual action's handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print which handlers are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could be SMM. :-)

Thanks,
Kevin

Quoted 29 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 11 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 1 line · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any

idea what

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger

machines.

Quoted 25 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw
Quoted 6 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:59

Some more interesting data that echos my earlier
measurements:

Quoted 6 lines

Booting with maxcpus=4, the three "large" interrupts are all about 20000 cycles. Booting with maxcpus=6, the three are at 146896, 183260, and 240959 cycles.

So it definitely appears to get worse as maxcpus
gets larger.

lock contention?

Quoted 2 lines

I also wonder if it might be related to SMT?

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors. At hardware level although cache is shared, ISRs in Xen are normally short and I don't think such high factor could come from there...

Thanks,
Kevin

Quoted 81 lines
Quoted 2 lines

One immediate trick is to print handler address for problematic

I'll give that a try, but probably not until tomorrow.

Quoted 76 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 8:42 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 17 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:34

Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Quoted 2 lines

Here's the relevant output. How do I map this to something meaningful?

One immediate trick is to print handler address for problematic vector, and then search its name in your dumpped Xen symbol file.

Thanks,
Kevin

Quoted 6 lines

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010
max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010
max_cycles=730972 in-flight=0 domain-list=0:255(----),

Above two look like owned by dom0.

Quoted 3 lines

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000
max_cycles=1047500 mapped, unbound

looks like PIT, but not quite sure.

Quoted 26 lines

(XEN) max_max_cycles = 1047500

Quoted 20 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 12 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Quoted 71 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Since you already reach this step around calling actual action's handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print

which handlers

Quoted 66 lines
Quoted 33 lines
Quoted 33 lines

are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could be SMM. :-)

Thanks,
Kevin

Quoted 25 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 7 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any

idea what

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

might be consuming this? The evidence might imply more cpus means longer interrupt, which bodes poorly for larger

machines.

Quoted 25 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#8 lore raw

The IO-APIC-edge interrupt action is timer_interrupt.

The MSI interrupt action is showing up strange (2010001)... I'll need to look into this more.

Quoted 1 line

lock contention?

Possible, though the consistent max numbers make it seem unlikely.

Quoted 2 lines

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors.

You mentioned PIT earlier... I wonder if PIT can be read in parallel if read from different cores, but if read from different threads, it must be serialized? A million cycles is probably about right for a platform timer read, true?

Quoted 188 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 9:05 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 6 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:59

Some more interesting data that echos my earlier
measurements:

Quoted 6 lines

Booting with maxcpus=4, the three "large" interrupts are all about 20000 cycles. Booting with maxcpus=6, the three are at 146896, 183260, and 240959 cycles.

So it definitely appears to get worse as maxcpus
gets larger.

lock contention?

Quoted 2 lines

I also wonder if it might be related to SMT?

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors. At hardware level although cache is shared, ISRs in Xen are normally short and I don't think such high factor could come from there...

Thanks,
Kevin

Quoted 81 lines
Quoted 2 lines

One immediate trick is to print handler address for problematic

I'll give that a try, but probably not until tomorrow.

Quoted 76 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 8:42 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 17 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:34

Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Quoted 2 lines

Here's the relevant output. How do I map this to something meaningful?

One immediate trick is to print handler address for problematic vector, and then search its name in your dumpped Xen symbol file.

Thanks,
Kevin

Quoted 6 lines

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010
max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010
max_cycles=730972 in-flight=0 domain-list=0:255(----),

Above two look like owned by dom0.

Quoted 3 lines

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000
max_cycles=1047500 mapped, unbound

looks like PIT, but not quite sure.

Quoted 26 lines

(XEN) max_max_cycles = 1047500

Quoted 20 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 12 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Rather than do this generically and ensure I get all the macros correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with smp_call_function showing the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Since you already reach this step around calling actual action's handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print

which handlers

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could

be SMM. :-)

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

Thanks,
Kevin

Quoted 25 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 7 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any

idea what

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

might be consuming this? The evidence might imply

more cpus

Quoted 28 lines
Quoted 27 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

means longer interrupt, which bodes poorly for larger

machines.

Quoted 25 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

I tried disabling the timer rendezvous code (not positive I was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to read TSC and find out the
distribution of irq handling times for interruptions that Xen knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw
Quoted 4 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 12:24

The IO-APIC-edge interrupt action is timer_interrupt.

this could be either driven by PIT or HPET (in legacy replacement mode), and activated when PIT is using as a platform timer or when PIT/HPET is used to broadcast wakeup event to cpus in deep C-states. The logic in timer_interrupt is very simple, and maybe you could again go one more step tracing into that function, e.g. the block protected by pit_lock. :-)

Quoted 3 lines

The MSI interrupt action is showing up strange (2010001)... I'll need to look into this more.

It's reasonable as action is allocated by xmalloc for those devices owned by guest. I guess you find two MSI instances in __do_IRQ_guest path? If yes, the logic to handle pending eoi may be suspected. Then you may use "ioapic_ack=old" to verify.

From information by far, it looks like the weird high cost could be from individual handler implementation, or else you should be able to observe in every handler (such as serial).

Quoted 6 lines
Quoted 2 lines

lock contention?

Possible, though the consistent max numbers make it seem unlikely.

Quoted 8 lines
Quoted 2 lines

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors.

You mentioned PIT earlier... I wonder if PIT can be read in parallel if read from different cores, but if read from different threads, it must be serialized? A million cycles is probably about right for a platform timer read, true?

It looks too large to me.

Thanks,
Kevin

Quoted 173 lines
Quoted 26 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 9:05 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 6 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:59

Some more interesting data that echos my earlier
measurements:

Quoted 6 lines

Booting with maxcpus=4, the three "large" interrupts are all about 20000 cycles. Booting with maxcpus=6, the three are at 146896, 183260, and 240959 cycles.

So it definitely appears to get worse as maxcpus
gets larger.

lock contention?

Quoted 2 lines

I also wonder if it might be related to SMT?

Quoted 83 lines

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors. At hardware level although cache is shared, ISRs in Xen are normally short and I don't think such high factor could come from there...

Thanks,
Kevin

Quoted 74 lines
Quoted 2 lines

One immediate trick is to print handler address for problematic

I'll give that a try, but probably not until tomorrow.

Quoted 69 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 8:42 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 17 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:34

Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Quoted 2 lines

Here's the relevant output. How do I map this to something meaningful?

One immediate trick is to print handler address for problematic vector, and then search its name in your dumpped Xen symbol file.

Thanks,
Kevin

Quoted 6 lines

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010
max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010
max_cycles=730972 in-flight=0 domain-list=0:255(----),

Above two look like owned by dom0.

Quoted 3 lines

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000
max_cycles=1047500 mapped, unbound

looks like PIT, but not quite sure.

Quoted 19 lines

(XEN) max_max_cycles = 1047500

Quoted 13 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 6 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Rather than do this generically and ensure I get all

the macros

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

correct (e.g. per_cpu, nesting) I manually instrumented three likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with

smp_call_function showing

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Since you already reach this step around calling

actual action's

Quoted 37 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print

which handlers

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

are registered or invoked on your platform. If only one handler is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could

be SMM. :-)

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

Thanks,
Kevin

Quoted 25 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system management mode

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 7 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · Dan Magenheimer

Is a million cycles in an interrupt handler bad? Any

idea what

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

might be consuming this? The evidence might imply

more cpus

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

means longer interrupt, which bodes poorly for larger

machines.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

I tried disabling the timer rendezvous code (not

positive I

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

was successful), but still got large measurements, and eventually the machine froze up (but not before I observed the stime skew climbing quickly to the millisecond-plus range).

Quoted 23 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

You can instrument irq_enter() and irq_exit() to

read TSC and

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

find out the
distribution of irq handling times for

interruptions that Xen

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines

knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#10 lore raw
Quoted 1 line

be suspected. Then you may use "ioapic_ack=old" to verify.

FYI ioapic_ack=old doesn't seem to help

Quoted 252 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 10:45 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 4 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 12:24

The IO-APIC-edge interrupt action is timer_interrupt.

this could be either driven by PIT or HPET (in legacy replacement mode), and activated when PIT is using as a platform timer or when PIT/HPET is used to broadcast wakeup event to cpus in deep C-states. The logic in timer_interrupt is very simple, and maybe you could again go one more step tracing into that function, e.g. the block protected by pit_lock. :-)

Quoted 3 lines

The MSI interrupt action is showing up strange (2010001)... I'll need to look into this more.

It's reasonable as action is allocated by xmalloc for those devices owned by guest. I guess you find two MSI instances in __do_IRQ_guest path? If yes, the logic to handle pending eoi may be suspected. Then you may use "ioapic_ack=old" to verify.

From information by far, it looks like the weird high cost could be from individual handler implementation, or else you should be able to observe in every handler (such as serial).

Quoted 6 lines
Quoted 2 lines

lock contention?

Possible, though the consistent max numbers make it seem unlikely.

Quoted 8 lines
Quoted 2 lines

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors.

You mentioned PIT earlier... I wonder if PIT can be read in parallel if read from different cores, but if read from different threads, it must be serialized? A million cycles is probably about right for a platform timer read, true?

It looks too large to me.

Thanks,
Kevin

Quoted 103 lines
Quoted 103 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 9:05 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 6 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:59

Some more interesting data that echos my earlier
measurements:

Quoted 6 lines

Booting with maxcpus=4, the three "large" interrupts are all about 20000 cycles. Booting with maxcpus=6, the three are at 146896, 183260, and 240959 cycles.

So it definitely appears to get worse as maxcpus
gets larger.

lock contention?

Quoted 2 lines

I also wonder if it might be related to SMT?

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors. At hardware level although cache is shared, ISRs in Xen are normally short and I don't think such high factor could come from there...

Thanks,
Kevin

Quoted 68 lines
Quoted 2 lines

One immediate trick is to print handler address for problematic

I'll give that a try, but probably not until tomorrow.

Quoted 63 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 8:42 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 17 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月14日 10:34

Quoted 1 line

handler, why not take one more step to measure every handler

Great idea! I added a max_cycles field to irq_desc_t and check/update it at every interrupt in do_IRQ, then print max_cycles in "xm debug-key i", including a "max max".

I'm not entirely sure how to interpret the output from dump_irqs() but the only two IRQ's with type==PCI-MSI have a "large"
max (450044 cycles and 730972 cycles). The third is Vec240, an IO-APIC-edge interrupt that maxes at 1047500
cycles. No other interrupt has a max exceeding 10000.

Quoted 2 lines

Here's the relevant output. How do I map this to something meaningful?

One immediate trick is to print handler address for problematic vector, and then search its name in your dumpped Xen symbol file.

Thanks,
Kevin

Quoted 6 lines

(XEN) Vec 49 IRQ -1: type=PCI-MSI status=00000010
max_cycles=450044 in-flight=0 domain-list=0:254(----),

(XEN) Vec208 IRQ -1: type=PCI-MSI status=00000010
max_cycles=730972 in-flight=0 domain-list=0:255(----),

Above two look like owned by dom0.

Quoted 3 lines

(XEN) Vec240 IRQ 0: type=IO-APIC-edge status=00000000
max_cycles=1047500 mapped, unbound

looks like PIT, but not quite sure.

Quoted 13 lines

(XEN) max_max_cycles = 1047500

Quoted 7 lines

-----Original Message-----
From: Tian, Kevin [mailto:[email protected]]
Sent: Monday, April 13, 2009 5:19 PM
To: Dan Magenheimer; Keir Fraser; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

From: Dan Magenheimer
Sent: 2009年4月14日 5:15

Quoted 1 line

You can instrument irq_enter() and irq_exit() to read TSC

Rather than do this generically and ensure I get all

the macros

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

correct (e.g. per_cpu, nesting) I manually

instrumented three

Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

likely suspect irq_enter/exit pairs, two in do_IRQ() and one in smp_call_function(). ALL of them show an issue with max readings in the 300K-1M range... with

smp_call_function showing

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

the lowest max and the second in do_IRQ (the non-guest one) showing readings over 1M (and the guest one at about 800K).

Since you already reach this step around calling

actual action's

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

handler, why not take one more step to measure every handler (serial, apic, vtd, ...)? You can first simply print

which handlers

Quoted 1 line
Quoted 1 line
Quoted 1 line

are registered or invoked on your platform. If only

one handler

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

is experienced with abnormal high latency, it's possibly one specific point. Or else you can suspect on some common code shared by all handlers, or ... as Keir said, it could

be SMM. :-)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks,
Kevin

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Interestingly, I get no readings at all over 60K when I recompile with max_phys_cpus=4 (and with nosmp) on my quad-core-by-two-thread machine. This is versus several readings over 60K nearly every second when max_phys_cpus=8.

Quoted 1 line

Otherwise who knows, it could even be system

management mode

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

I suppose measuring irq_enter/exist pairs still don't rule this out. But the "large" interrupts don't seem to happen (at least not nearly as frequently) with fewer physical processors enabled, so sys mgmt mode seems unlikely.

Anyway, still a probable problem, still mostly a mystery as to what is actually happening. And, repeat, this has nothing to do with tmem... I'm just observing it using tmem as a convenient measurement tool.

Quoted 10 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Monday, April 13, 2009 2:24 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] million cycle interrupt

On 12/04/2009 21:16, "Dan Magenheimer"
<[email protected]> wrote:

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Is a million cycles in an interrupt handler bad? Any

idea what

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

might be consuming this? The evidence might imply

more cpus

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

means longer interrupt, which bodes poorly for larger

machines.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

I tried disabling the timer rendezvous code (not

positive I

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

was successful), but still got large measurements, and eventually the machine froze up (but not before

I observed

Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

the stime skew climbing quickly to the millisecond-plus range).

You can instrument irq_enter() and irq_exit() to

read TSC and

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

find out the
distribution of irq handling times for

interruptions that Xen

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines

knows about.
Otherwise who knows, it could even be system management

mode on that

Quoted 12 lines
Quoted 6 lines

particular box.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#11 lore raw
In reply to Dan Magenheimer
Quoted 8 lines · Dan Magenheimer
Quoted 2 lines

If it's really caused by SMT, it's more likely to be software caused resource contention due to doubled logical processors.

You mentioned PIT earlier... I wonder if PIT can be read in parallel if read from different cores, but if read from different threads, it must be serialized? A million cycles is probably about right for a platform timer read, true?

You could validate that quite easily by adding your own timer read wrapped in TSC reads. Actually a PIT read, even though it requires multiple accesses over the ISA bus, should take less than 10us.

-- Keir

#12 lore raw
Quoted 5 lines

You could validate that quite easily by adding your own timer read wrapped
in TSC reads. Actually a PIT read, even though it requires multiple accesses
over the ISA bus, should take less than 10us.

I'll take a look at that next. Taking average as well as max, the timer_interrupt interrupt is AVERAGING over 300K cycles (with 8 processors). This interrupt is 100Hz, correct? If so, that means a full 1% of one processor's cycles are spent processing timer_interrupts!

The MSI interrupts have large max, but the average is relatively small (under 5000 cycles). It still would be nice to know what is causing the max value, especially since it only occurs for me with more than 4 processors.

But first, Keir, would you take this patch so that this kind of issue can be more easily diagnosed in the future? If you're worried about the extra two global variable reads, you could wrap an "#ifndef NDEBUG" around it (with #else #define opt_measure_irqs 0), but it might be nice to have this diagnostic capability in released code.

xen/arch/x86/irq.c +50 -3
diff -r d9de5cc2b0bc xen/arch/x86/irq.c
@@ -25,7 +25,11 @@ int opt_noirqbalance = 0;
 int opt_noirqbalance = 0;
 boolean_param("noirqbalance", opt_noirqbalance);
 
+int opt_measure_irqs = 0;
+boolean_param("measure_irqs", opt_measure_irqs);
+
 irq_desc_t irq_desc[NR_VECTORS];
+irq_desc_measure_t irq_desc_measure[NR_VECTORS];
 
 static DEFINE_SPINLOCK(vector_lock);
 int vector_irq[NR_VECTORS] __read_mostly = {
@@ -114,6 +118,8 @@ asmlinkage void do_IRQ(struct cpu_user_r
     unsigned int      vector = regs->entry_vector;
     irq_desc_t       *desc = &irq_desc[vector];
     struct irqaction *action;
+    irq_desc_measure_t    *mdesc;
+    unsigned long tsc_in = 0, diff;
 
     perfc_incr(irqs);
 
@@ -123,7 +129,18 @@ asmlinkage void do_IRQ(struct cpu_user_r
     if ( likely(desc->status & IRQ_GUEST) )
     {
         irq_enter();
+        if ( opt_measure_irqs )
+            tsc_in = (unsigned long)get_cycles();
         __do_IRQ_guest(vector);
+        if ( opt_measure_irqs )
+        {
+            diff = (unsigned long)get_cycles() - tsc_in;
+            mdesc = &irq_desc_measure[vector];
+            mdesc->count++;
+            mdesc->tot_cycles += diff;
+            if ( diff > mdesc->max_cycles )
+                mdesc->max_cycles = diff;
+        }
         irq_exit();
         spin_unlock(&desc->lock);
         return;
@@ -147,7 +164,18 @@ asmlinkage void do_IRQ(struct cpu_user_r
         desc->status &= ~IRQ_PENDING;
         irq_enter();
         spin_unlock_irq(&desc->lock);
+        if ( opt_measure_irqs )
+            tsc_in = (unsigned long)get_cycles();
         action->handler(vector_to_irq(vector), action->dev_id, regs);
+        if ( opt_measure_irqs )
+        {
+            diff = (unsigned long)get_cycles() - tsc_in;
+            mdesc = &irq_desc_measure[vector];
+            mdesc->count++;
+            mdesc->tot_cycles += diff;
+            if ( diff > mdesc->max_cycles )
+                mdesc->max_cycles = diff;
+        }
         spin_lock_irq(&desc->lock);
         irq_exit();
     }
@@ -1071,9 +1099,11 @@ static void dump_irqs(unsigned char key)
 {
     int i, glob_irq, irq, vector;
     irq_desc_t *desc;
+    irq_desc_measure_t *mdesc = NULL;
     irq_guest_action_t *action;
     struct domain *d;
     unsigned long flags;
+    unsigned long max_max_cycles = 0;
 
     printk("Guest interrupt information:\n");
 
@@ -1088,12 +1118,23 @@ static void dump_irqs(unsigned char key)
 
         spin_lock_irqsave(&desc->lock, flags);
 
+        if ( opt_measure_irqs )
+        {
+            mdesc = &irq_desc_measure[vector];
+            if ( mdesc->max_cycles > max_max_cycles )
+                max_max_cycles = mdesc->max_cycles;
+        }
         if ( !(desc->status & IRQ_GUEST) )
+        {
             printk("   Vec%3d IRQ%3d: type=%-15s status=%08x "
-                   "mapped, unbound\n",
+                   "mapped, unbound",
                    vector, glob_irq, desc->handler->typename, desc->status);
-        else
-        {
+            if ( opt_measure_irqs )
+                printk(" cycles(n/avg/max)=%lu/%lu/%lu", mdesc->count,
+                       mdesc->count ? (mdesc->tot_cycles / mdesc->count) : 0,
+                       mdesc->max_cycles);
+            printk("\n");
+        } else {
             action = (irq_guest_action_t *)desc->action;
 
             printk("   Vec%3d IRQ%3d: type=%-15s status=%08x "
@@ -1123,11 +1164,17 @@ static void dump_irqs(unsigned char key)
                     printk(",");
             }
 
+            if ( opt_measure_irqs )
+                printk(" cycles(n/avg/max)=%lu/%lu/%lu", mdesc->count,
+                       mdesc->count ? (mdesc->tot_cycles / mdesc->count) : 0,
+                       mdesc->max_cycles);
             printk("\n");
         }
 
         spin_unlock_irqrestore(&desc->lock, flags);
     }
+    if ( max_max_cycles )
+        printk("max_max_cycles = %lu\n",max_max_cycles);
 
     dump_ioapic_irq_info();
 }
xen/include/xen/irq.h +6 -0
diff -r d9de5cc2b0bc xen/include/xen/irq.h
@@ -67,6 +67,12 @@ typedef struct {
     cpumask_t affinity;
 } __cacheline_aligned irq_desc_t;
 
+typedef struct {
+    unsigned long max_cycles;
+    unsigned long tot_cycles;
+    unsigned long count;
+} irq_desc_measure_t;
+
 extern irq_desc_t irq_desc[NR_VECTORS];
 
 extern int setup_irq_vector(unsigned int, struct irqaction *);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#13 lore raw
Quoted 1 line

I'll take a look at that next.

It appears that the call to smp_timer_broadcast_ipi() in timer_interrupt() is the cycle hog. And it definitely appears to be a scaleability problem!

maxcpus=4: avg=1600, max=15000 (cycles, rounded) maxcpus=5: avg=2000, max=24000
maxcpus=6: avg=83000, max=244000
maxcpus=7: avg=198000, max=780000
maxcpus=8: avg=310000, max=1027000

The load is a 4vcpu PV EL5u2 32-bit domain continually compiling linux-2.6.28 with -j80. I killed the load after only a few minutes, so the max might get worse. On the other hand, just booting dom0 seems to put max in about the same range.

Dan

Quoted 34 lines

-----Original Message-----
From: Dan Magenheimer
Sent: Tuesday, April 14, 2009 9:39 AM
To: Keir Fraser; Tian, Kevin; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 5 lines

You could validate that quite easily by adding your own timer read wrapped
in TSC reads. Actually a PIT read, even though it requires multiple accesses
over the ISA bus, should take less than 10us.

I'll take a look at that next. Taking average as well as max, the timer_interrupt interrupt is AVERAGING over 300K cycles (with 8 processors). This interrupt is 100Hz, correct? If so, that means a full 1% of one processor's cycles are spent processing timer_interrupts!

The MSI interrupts have large max, but the average is relatively small (under 5000 cycles). It still would be nice to know what is causing the max value, especially since it only occurs for me with more than 4 processors.

But first, Keir, would you take this patch so that this kind of issue can be more easily diagnosed in the future? If you're worried about the extra two global variable reads, you could wrap an "#ifndef NDEBUG" around it (with #else #define opt_measure_irqs 0), but it might be nice to have this diagnostic capability in released code.

#14 lore raw
Quoted 8 lines

From: Dan Magenheimer [mailto:[email protected]]
Sent: 2009年4月15日 1:11

Quoted 1 line

I'll take a look at that next.

It appears that the call to smp_timer_broadcast_ipi() in timer_interrupt() is the cycle hog. And it definitely appears to be a scaleability problem!

So I guess processors on your platform at least support some deep C-states (>=C3), or else that broadcast path should be a nop, is it right? If you disable deep C-states in BIOS, I guess it then scales well.

Quoted 6 lines

maxcpus=4: avg=1600, max=15000 (cycles, rounded) maxcpus=5: avg=2000, max=24000
maxcpus=6: avg=83000, max=244000
maxcpus=7: avg=198000, max=780000
maxcpus=8: avg=310000, max=1027000

This looks sth related to IPI overhead. When more processors are available, more IPIs are required to contend the bus. But I'm not sure whether the attitude of change fully comes from that part. Which type of platform are you using? We'll also take a try here to first reproduce and then find exact reason.

Quoted 6 lines

The load is a 4vcpu PV EL5u2 32-bit domain continually compiling linux-2.6.28 with -j80. I killed the load after only a few minutes, so the max might get worse. On the other hand, just booting dom0 seems to put max in about the same range.

And average is then very low w/o dom0 only?

Thanks
Kevin

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#15 lore raw
In reply to Dan Magenheimer
Quoted 2 lines
Quoted 2 lines

Is there a way to cap the number of physical cpus seen by Xen (other than nosmp to cap at one)?

There is a compile time option (max_phys_cpus) where you can specify the number of LCPUs.

Aravindh Puthiyaparambil
Virtualization Engineer
Virtual Systems Development
Unisys, Tredyffrin PA

#16 lore raw

Thanks Aravindh!

Hmmm... I'm suspicious of this. When compiled with max_phys_cpus=4, xm info shows nr_cpus=4, nr_nodes=1, cores_per_socket=1 and threads_per_core=1. Without this compile option, cores_per_socket=4 and threads_per_core=2... so I would expect only one of these to change. Hopefully the compile option is simply changing the data reported by xm info. It appears the guest still is using 4 physical processors.

Quoted 19 lines

-----Original Message-----
From: Puthiyaparambil, Aravindh
[mailto:[email protected]]
Sent: Monday, April 13, 2009 9:31 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 2 lines
Quoted 2 lines

Is there a way to cap the number of physical cpus seen by Xen (other than nosmp to cap at one)?

There is a compile time option (max_phys_cpus) where you can specify the number of LCPUs.

Aravindh Puthiyaparambil
Virtualization Engineer
Virtual Systems Development
Unisys, Tredyffrin PA

#17 lore raw

I have only tried increasing the max_phys_cpus from 32 to 64, 96 etc. I would think that decreasing it to 4 means that only the first 4 LCPUS were booted. The rest should have been ignored.

-----Original Message-----
From: Dan Magenheimer [mailto:[email protected]]
Sent: Monday, April 13, 2009 4:24 PM
To: Puthiyaparambil, Aravindh; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Thanks Aravindh!

Hmmm... I'm suspicious of this. When compiled with max_phys_cpus=4, xm info shows nr_cpus=4, nr_nodes=1, cores_per_socket=1 and threads_per_core=1. Without this compile option, cores_per_socket=4 and threads_per_core=2... so I would expect only one of these to change. Hopefully the compile option is simply changing the data reported by xm info. It appears the guest still is using 4 physical processors.

Quoted 19 lines

-----Original Message-----
From: Puthiyaparambil, Aravindh
[mailto:[email protected]]
Sent: Monday, April 13, 2009 9:31 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 2 lines
Quoted 2 lines

Is there a way to cap the number of physical cpus seen by Xen (other than nosmp to cap at one)?

There is a compile time option (max_phys_cpus) where you can specify the number of LCPUs.

Aravindh Puthiyaparambil
Virtualization Engineer
Virtual Systems Development
Unisys, Tredyffrin PA

#18 lore raw
In reply to Dan Magenheimer

use "maxcpus=" in your grub.conf.

Thanks
Kevin

Quoted 34 lines

From: Dan Magenheimer
Sent: 2009年4月14日 4:24

Thanks Aravindh!

Hmmm... I'm suspicious of this. When compiled with max_phys_cpus=4, xm info shows nr_cpus=4, nr_nodes=1, cores_per_socket=1 and threads_per_core=1. Without this compile option, cores_per_socket=4 and threads_per_core=2... so I would expect only one of these to change. Hopefully the compile option is simply changing the data reported by xm info. It appears the guest still is using 4 physical processors.

Quoted 11 lines

-----Original Message-----
From: Puthiyaparambil, Aravindh
[mailto:[email protected]]
Sent: Monday, April 13, 2009 9:31 AM
To: Dan Magenheimer; Xen-Devel (E-mail)
Subject: RE: [Xen-devel] million cycle interrupt

Quoted 2 lines
Quoted 2 lines

Is there a way to cap the number of physical cpus seen by Xen (other than nosmp to cap at one)?

Quoted 8 lines

There is a compile time option (max_phys_cpus) where you can specify the number of LCPUs.

Aravindh Puthiyaparambil
Virtualization Engineer
Virtual Systems Development
Unisys, Tredyffrin PA

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel