diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-03-13 07:21:34 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-06 03:29:40 -0400 |
commit | ac17dc8e58f3069ea895cfff963adf98ff3cf6b2 (patch) | |
tree | fe07b13dd100fd1f650d8437296f5c6908e9adea | |
parent | 7dd1fcc258b65da718f01e4684a7b9244501a9fb (diff) |
perf_counter: provide major/minor page fault software events
Provide separate sw counters for major and minor page faults.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/powerpc/mm/fault.c | 5 | ||||
-rw-r--r-- | arch/x86/mm/fault.c | 7 | ||||
-rw-r--r-- | include/linux/perf_counter.h | 4 | ||||
-rw-r--r-- | kernel/perf_counter.c | 22 |
4 files changed, 21 insertions, 17 deletions
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index eda5b0ca4af2..17bbf6f91fbe 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c | |||
@@ -312,6 +312,7 @@ good_area: | |||
312 | } | 312 | } |
313 | if (ret & VM_FAULT_MAJOR) { | 313 | if (ret & VM_FAULT_MAJOR) { |
314 | current->maj_flt++; | 314 | current->maj_flt++; |
315 | perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MAJ, 1, 0, regs); | ||
315 | #ifdef CONFIG_PPC_SMLPAR | 316 | #ifdef CONFIG_PPC_SMLPAR |
316 | if (firmware_has_feature(FW_FEATURE_CMO)) { | 317 | if (firmware_has_feature(FW_FEATURE_CMO)) { |
317 | preempt_disable(); | 318 | preempt_disable(); |
@@ -319,8 +320,10 @@ good_area: | |||
319 | preempt_enable(); | 320 | preempt_enable(); |
320 | } | 321 | } |
321 | #endif | 322 | #endif |
322 | } else | 323 | } else { |
323 | current->min_flt++; | 324 | current->min_flt++; |
325 | perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MIN, 1, 0, regs); | ||
326 | } | ||
324 | up_read(&mm->mmap_sem); | 327 | up_read(&mm->mmap_sem); |
325 | return 0; | 328 | return 0; |
326 | 329 | ||
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index c8725752b6cd..f2d3324d9215 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -1140,10 +1140,13 @@ good_area: | |||
1140 | return; | 1140 | return; |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | if (fault & VM_FAULT_MAJOR) | 1143 | if (fault & VM_FAULT_MAJOR) { |
1144 | tsk->maj_flt++; | 1144 | tsk->maj_flt++; |
1145 | else | 1145 | perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MAJ, 1, 0, regs); |
1146 | } else { | ||
1146 | tsk->min_flt++; | 1147 | tsk->min_flt++; |
1148 | perf_swcounter_event(PERF_COUNT_PAGE_FAULTS_MIN, 1, 0, regs); | ||
1149 | } | ||
1147 | 1150 | ||
1148 | check_v8086_mode(regs, address, tsk); | 1151 | check_v8086_mode(regs, address, tsk); |
1149 | 1152 | ||
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index 3fefc3b8150d..4b14a8e9dbf5 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -49,8 +49,10 @@ enum hw_event_types { | |||
49 | PERF_COUNT_PAGE_FAULTS = -3, | 49 | PERF_COUNT_PAGE_FAULTS = -3, |
50 | PERF_COUNT_CONTEXT_SWITCHES = -4, | 50 | PERF_COUNT_CONTEXT_SWITCHES = -4, |
51 | PERF_COUNT_CPU_MIGRATIONS = -5, | 51 | PERF_COUNT_CPU_MIGRATIONS = -5, |
52 | PERF_COUNT_PAGE_FAULTS_MIN = -6, | ||
53 | PERF_COUNT_PAGE_FAULTS_MAJ = -7, | ||
52 | 54 | ||
53 | PERF_SW_EVENTS_MIN = -6, | 55 | PERF_SW_EVENTS_MIN = -8, |
54 | }; | 56 | }; |
55 | 57 | ||
56 | /* | 58 | /* |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 1773c5d7427d..68950a3a52bf 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -1503,6 +1503,12 @@ static void perf_swcounter_disable(struct perf_counter *counter) | |||
1503 | perf_swcounter_update(counter); | 1503 | perf_swcounter_update(counter); |
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | static const struct hw_perf_counter_ops perf_ops_generic = { | ||
1507 | .enable = perf_swcounter_enable, | ||
1508 | .disable = perf_swcounter_disable, | ||
1509 | .read = perf_swcounter_read, | ||
1510 | }; | ||
1511 | |||
1506 | /* | 1512 | /* |
1507 | * Software counter: cpu wall time clock | 1513 | * Software counter: cpu wall time clock |
1508 | */ | 1514 | */ |
@@ -1604,16 +1610,6 @@ static const struct hw_perf_counter_ops perf_ops_task_clock = { | |||
1604 | }; | 1610 | }; |
1605 | 1611 | ||
1606 | /* | 1612 | /* |
1607 | * Software counter: page faults | ||
1608 | */ | ||
1609 | |||
1610 | static const struct hw_perf_counter_ops perf_ops_page_faults = { | ||
1611 | .enable = perf_swcounter_enable, | ||
1612 | .disable = perf_swcounter_disable, | ||
1613 | .read = perf_swcounter_read, | ||
1614 | }; | ||
1615 | |||
1616 | /* | ||
1617 | * Software counter: context switches | 1613 | * Software counter: context switches |
1618 | */ | 1614 | */ |
1619 | 1615 | ||
@@ -1753,9 +1749,9 @@ sw_perf_counter_init(struct perf_counter *counter) | |||
1753 | hw_ops = &perf_ops_cpu_clock; | 1749 | hw_ops = &perf_ops_cpu_clock; |
1754 | break; | 1750 | break; |
1755 | case PERF_COUNT_PAGE_FAULTS: | 1751 | case PERF_COUNT_PAGE_FAULTS: |
1756 | if (!(counter->hw_event.exclude_user || | 1752 | case PERF_COUNT_PAGE_FAULTS_MIN: |
1757 | counter->hw_event.exclude_kernel)) | 1753 | case PERF_COUNT_PAGE_FAULTS_MAJ: |
1758 | hw_ops = &perf_ops_page_faults; | 1754 | hw_ops = &perf_ops_generic; |
1759 | break; | 1755 | break; |
1760 | case PERF_COUNT_CONTEXT_SWITCHES: | 1756 | case PERF_COUNT_CONTEXT_SWITCHES: |
1761 | if (!counter->hw_event.exclude_kernel) | 1757 | if (!counter->hw_event.exclude_kernel) |