Skip to contentSkip to conversation

2.6.17.1 perfmon2 patch for review: PMU context switch

PATCH Chuck Ebbert 3 participants 4 messages Jun 30, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <[email protected]>

Quoted 7 lines · Andi Kleen
Quoted 4 lines

So why do we need care about context switch in cpu-wide mode? It is because we support a mode where the idle thread is excluded from cpu-wide monitoring. This is very useful to distinguish 'useful kernel work' from 'idle'.

I don't quite see the point because on x86 the PMU doesn't run during C states anyways. So you get idle excluded automatically.

Looks like it does run:

$ pfmon -ecpu_clk_unhalted,interrupts_masked_cycles -k --system-wide -t 10
<session to end in 10 seconds>
CPU0     60351837 CPU_CLK_UNHALTED
CPU0    346548229 INTERRUPTS_MASKED_CYCLES

The CPU spent ~60 million clocks unhalted and ~350 million with interrupts disabled. (This is an idle 1.6GHz Turion64 machine.)

Now let's see what happens when we exclude the idle thread:

$ pfmon -ecpu_clk_unhalted,interrupts_masked_cycles -k --system-wide -t 10 --excl-idle
<session to end in 10 seconds>
CPU0    449250 CPU_CLK_UNHALTED
CPU0    161577 INTERRUPTS_MASKED_CYCLES

Looks like excluding the idle thread means interrupts that happen while idle don't get counted either. We took 5000 clock interrupts and I know they take longer than that to process.

Signature · 2 lines
Chuck
 "You can't read a newspaper if you can't read."  --George W. Bush
#1 lore raw
Quoted 9 lines · Chuck Ebbert

In-Reply-To: <[email protected]>

Quoted 5 lines · Andi Kleen
Quoted 4 lines

So why do we need care about context switch in cpu-wide mode? It is because we support a mode where the idle thread is excluded from cpu-wide monitoring. This is very useful to distinguish 'useful kernel work' from 'idle'.

Quoted 4 lines
Quoted 2 lines

I don't quite see the point because on x86 the PMU doesn't run during C states anyways. So you get idle excluded automatically.

Looks like it does run:

I'm pretty sure it doesn't. You can see it by watching the frequency of the perfctr mode NMI watchdog in /proc/interrupts under different loads.

When the system is idle the frequency goes down and increases when the system is busy. I also got confirmation of this behaviour from both Intel and AMD. C states > 0 are not supposed to run the performance counters.

Are you sure you didn't boot with poll=idle? Otherwise something must be wrong with your measurements.

-Andi

#2 lore raw
In reply to Chuck Ebbert

Chuck,

Quoted 14 lines · Chuck Ebbert

In-Reply-To: <[email protected]>

Quoted 7 lines · Andi Kleen
Quoted 4 lines

So why do we need care about context switch in cpu-wide mode? It is because we support a mode where the idle thread is excluded from cpu-wide monitoring. This is very useful to distinguish 'useful kernel work' from 'idle'.

I don't quite see the point because on x86 the PMU doesn't run during C states anyways. So you get idle excluded automatically.

Looks like it does run:

Quoted 8 lines
$ pfmon -ecpu_clk_unhalted,interrupts_masked_cycles -k --system-wide -t 10
<session to end in 10 seconds>
CPU0     60351837 CPU_CLK_UNHALTED
CPU0    346548229 INTERRUPTS_MASKED_CYCLES

The CPU spent ~60 million clocks unhalted and ~350 million with interrupts disabled. (This is an idle 1.6GHz Turion64 machine.)

I think it stops counting only CERTAIN events. That's where it becomes difficult to interpret. There was a defect like this on Itanium 2.

Quoted 11 lines

Now let's see what happens when we exclude the idle thread:

$ pfmon -ecpu_clk_unhalted,interrupts_masked_cycles -k --system-wide -t 10 --excl-idle
<session to end in 10 seconds>
CPU0    449250 CPU_CLK_UNHALTED
CPU0    161577 INTERRUPTS_MASKED_CYCLES

Looks like excluding the idle thread means interrupts that happen while idle don't get counted either. We took 5000 clock interrupts and I know they take longer than that to process.

Yes, the way it is implemented today means that nothing happening while the idle threads runs/sleeps is counted. Monitoring is disabled at context switch boundaries for task->pid==0.

I would rather have something that would stop counting *EVERYTHING* ONLY when going low-power OR when busy looping. That's why the idle notififers that Andi mentioned are interesting. But this would not cover interrupts received while in idle and yet we want to measure those as they represent useful kernel work. This is unless interrupts while idle qualifies for an exit_idle() notification.

Signature · 1 line
-Stephane
#3 lore raw
In reply to Chuck Ebbert

Chuck,

Quoted 14 lines · Chuck Ebbert

In-Reply-To: <[email protected]>

Quoted 7 lines · Andi Kleen
Quoted 4 lines

So why do we need care about context switch in cpu-wide mode? It is because we support a mode where the idle thread is excluded from cpu-wide monitoring. This is very useful to distinguish 'useful kernel work' from 'idle'.

I don't quite see the point because on x86 the PMU doesn't run during C states anyways. So you get idle excluded automatically.

Looks like it does run:

Quoted 8 lines
$ pfmon -ecpu_clk_unhalted,interrupts_masked_cycles -k --system-wide -t 10
<session to end in 10 seconds>
CPU0     60351837 CPU_CLK_UNHALTED
CPU0    346548229 INTERRUPTS_MASKED_CYCLES

The CPU spent ~60 million clocks unhalted and ~350 million with interrupts disabled. (This is an idle 1.6GHz Turion64 machine.)

As Andi is suggesting, I think this may depends on how the BIOS implements the low-power state. I have tried the same command on my dual Opteron 250 2.4GHz and I get:

$ pfmon --us-c -ecpu_clk_unhalted,interrupts_masked_cycles -k --system-wide -t 10
<session to end in 10 seconds>
CPU0                     9,520,303 CPU_CLK_UNHALTED
CPU0                     3,726,315 INTERRUPTS_MASKED_CYCLES
CPU1                    21,268,151 CPU_CLK_UNHALTED
CPU1                    14,515,389 INTERRUPTS_MASKED_CYCLES

That's without idle=poll.

Signature · 1 line
-Stephane