diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-27 13:53:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-27 13:53:30 -0400 |
commit | cdb8355add9b1d87ecfcb58b12879897dc1e3e36 (patch) | |
tree | 9af61da194aaa6c255cf17de9e324c21a35581b3 /arch/ia64/kernel/perfmon.c | |
parent | b98adfccdf5f8dd34ae56a2d5adbe2c030bd4674 (diff) | |
parent | df8f0ec1a413ae610899f009e25dc9777881e149 (diff) |
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6:
[IA64] minor reformatting to vmlinux.lds.S
[IA64] CMC/CPE: Reverse the order of fetching log and checking poll threshold
[IA64] PAL calls need physical mode, stacked
[IA64] ar.fpsr not set on MCA/INIT kernel entry
[IA64] printing support for MCA/INIT
[IA64] trim output of show_mem()
[IA64] show_mem() printk levels
[IA64] Make gp value point to Region 5 in mca handler
Revert "[IA64] Unwire set/get_robust_list"
[IA64] Implement futex primitives
[IA64-SGI] Do not request DMA memory for BTE
[IA64] Move perfmon tables from thread_struct to pfm_context
[IA64] Add interface so modules can discover whether multithreading is on.
[IA64] kprobes: fixup the pagefault exception caused by probehandlers
[IA64] kprobe opcode 16 bytes alignment on IA64
[IA64] esi-support
[IA64] Add "model name" to /proc/cpuinfo
Diffstat (limited to 'arch/ia64/kernel/perfmon.c')
-rw-r--r-- | arch/ia64/kernel/perfmon.c | 113 |
1 files changed, 49 insertions, 64 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 7bb7696e4ce2..281004ff7b00 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -63,6 +63,9 @@ | |||
63 | 63 | ||
64 | #define PFM_INVALID_ACTIVATION (~0UL) | 64 | #define PFM_INVALID_ACTIVATION (~0UL) |
65 | 65 | ||
66 | #define PFM_NUM_PMC_REGS 64 /* PMC save area for ctxsw */ | ||
67 | #define PFM_NUM_PMD_REGS 64 /* PMD save area for ctxsw */ | ||
68 | |||
66 | /* | 69 | /* |
67 | * depth of message queue | 70 | * depth of message queue |
68 | */ | 71 | */ |
@@ -297,14 +300,17 @@ typedef struct pfm_context { | |||
297 | unsigned long ctx_reload_pmcs[4]; /* bitmask of force reload PMC on ctxsw in */ | 300 | unsigned long ctx_reload_pmcs[4]; /* bitmask of force reload PMC on ctxsw in */ |
298 | unsigned long ctx_used_monitors[4]; /* bitmask of monitor PMC being used */ | 301 | unsigned long ctx_used_monitors[4]; /* bitmask of monitor PMC being used */ |
299 | 302 | ||
300 | unsigned long ctx_pmcs[IA64_NUM_PMC_REGS]; /* saved copies of PMC values */ | 303 | unsigned long ctx_pmcs[PFM_NUM_PMC_REGS]; /* saved copies of PMC values */ |
301 | 304 | ||
302 | unsigned int ctx_used_ibrs[1]; /* bitmask of used IBR (speedup ctxsw in) */ | 305 | unsigned int ctx_used_ibrs[1]; /* bitmask of used IBR (speedup ctxsw in) */ |
303 | unsigned int ctx_used_dbrs[1]; /* bitmask of used DBR (speedup ctxsw in) */ | 306 | unsigned int ctx_used_dbrs[1]; /* bitmask of used DBR (speedup ctxsw in) */ |
304 | unsigned long ctx_dbrs[IA64_NUM_DBG_REGS]; /* DBR values (cache) when not loaded */ | 307 | unsigned long ctx_dbrs[IA64_NUM_DBG_REGS]; /* DBR values (cache) when not loaded */ |
305 | unsigned long ctx_ibrs[IA64_NUM_DBG_REGS]; /* IBR values (cache) when not loaded */ | 308 | unsigned long ctx_ibrs[IA64_NUM_DBG_REGS]; /* IBR values (cache) when not loaded */ |
306 | 309 | ||
307 | pfm_counter_t ctx_pmds[IA64_NUM_PMD_REGS]; /* software state for PMDS */ | 310 | pfm_counter_t ctx_pmds[PFM_NUM_PMD_REGS]; /* software state for PMDS */ |
311 | |||
312 | unsigned long th_pmcs[PFM_NUM_PMC_REGS]; /* PMC thread save state */ | ||
313 | unsigned long th_pmds[PFM_NUM_PMD_REGS]; /* PMD thread save state */ | ||
308 | 314 | ||
309 | u64 ctx_saved_psr_up; /* only contains psr.up value */ | 315 | u64 ctx_saved_psr_up; /* only contains psr.up value */ |
310 | 316 | ||
@@ -868,7 +874,6 @@ static void | |||
868 | pfm_mask_monitoring(struct task_struct *task) | 874 | pfm_mask_monitoring(struct task_struct *task) |
869 | { | 875 | { |
870 | pfm_context_t *ctx = PFM_GET_CTX(task); | 876 | pfm_context_t *ctx = PFM_GET_CTX(task); |
871 | struct thread_struct *th = &task->thread; | ||
872 | unsigned long mask, val, ovfl_mask; | 877 | unsigned long mask, val, ovfl_mask; |
873 | int i; | 878 | int i; |
874 | 879 | ||
@@ -889,7 +894,7 @@ pfm_mask_monitoring(struct task_struct *task) | |||
889 | * So in both cases, the live register contains the owner's | 894 | * So in both cases, the live register contains the owner's |
890 | * state. We can ONLY touch the PMU registers and NOT the PSR. | 895 | * state. We can ONLY touch the PMU registers and NOT the PSR. |
891 | * | 896 | * |
892 | * As a consequence to this call, the thread->pmds[] array | 897 | * As a consequence to this call, the ctx->th_pmds[] array |
893 | * contains stale information which must be ignored | 898 | * contains stale information which must be ignored |
894 | * when context is reloaded AND monitoring is active (see | 899 | * when context is reloaded AND monitoring is active (see |
895 | * pfm_restart). | 900 | * pfm_restart). |
@@ -924,9 +929,9 @@ pfm_mask_monitoring(struct task_struct *task) | |||
924 | mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; | 929 | mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; |
925 | for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { | 930 | for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { |
926 | if ((mask & 0x1) == 0UL) continue; | 931 | if ((mask & 0x1) == 0UL) continue; |
927 | ia64_set_pmc(i, th->pmcs[i] & ~0xfUL); | 932 | ia64_set_pmc(i, ctx->th_pmcs[i] & ~0xfUL); |
928 | th->pmcs[i] &= ~0xfUL; | 933 | ctx->th_pmcs[i] &= ~0xfUL; |
929 | DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, th->pmcs[i])); | 934 | DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, ctx->th_pmcs[i])); |
930 | } | 935 | } |
931 | /* | 936 | /* |
932 | * make all of this visible | 937 | * make all of this visible |
@@ -943,7 +948,6 @@ static void | |||
943 | pfm_restore_monitoring(struct task_struct *task) | 948 | pfm_restore_monitoring(struct task_struct *task) |
944 | { | 949 | { |
945 | pfm_context_t *ctx = PFM_GET_CTX(task); | 950 | pfm_context_t *ctx = PFM_GET_CTX(task); |
946 | struct thread_struct *th = &task->thread; | ||
947 | unsigned long mask, ovfl_mask; | 951 | unsigned long mask, ovfl_mask; |
948 | unsigned long psr, val; | 952 | unsigned long psr, val; |
949 | int i, is_system; | 953 | int i, is_system; |
@@ -1009,9 +1013,9 @@ pfm_restore_monitoring(struct task_struct *task) | |||
1009 | mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; | 1013 | mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; |
1010 | for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { | 1014 | for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { |
1011 | if ((mask & 0x1) == 0UL) continue; | 1015 | if ((mask & 0x1) == 0UL) continue; |
1012 | th->pmcs[i] = ctx->ctx_pmcs[i]; | 1016 | ctx->th_pmcs[i] = ctx->ctx_pmcs[i]; |
1013 | ia64_set_pmc(i, th->pmcs[i]); | 1017 | ia64_set_pmc(i, ctx->th_pmcs[i]); |
1014 | DPRINT(("[%d] pmc[%d]=0x%lx\n", task->pid, i, th->pmcs[i])); | 1018 | DPRINT(("[%d] pmc[%d]=0x%lx\n", task->pid, i, ctx->th_pmcs[i])); |
1015 | } | 1019 | } |
1016 | ia64_srlz_d(); | 1020 | ia64_srlz_d(); |
1017 | 1021 | ||
@@ -1070,7 +1074,6 @@ pfm_restore_pmds(unsigned long *pmds, unsigned long mask) | |||
1070 | static inline void | 1074 | static inline void |
1071 | pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx) | 1075 | pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx) |
1072 | { | 1076 | { |
1073 | struct thread_struct *thread = &task->thread; | ||
1074 | unsigned long ovfl_val = pmu_conf->ovfl_val; | 1077 | unsigned long ovfl_val = pmu_conf->ovfl_val; |
1075 | unsigned long mask = ctx->ctx_all_pmds[0]; | 1078 | unsigned long mask = ctx->ctx_all_pmds[0]; |
1076 | unsigned long val; | 1079 | unsigned long val; |
@@ -1092,11 +1095,11 @@ pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx) | |||
1092 | ctx->ctx_pmds[i].val = val & ~ovfl_val; | 1095 | ctx->ctx_pmds[i].val = val & ~ovfl_val; |
1093 | val &= ovfl_val; | 1096 | val &= ovfl_val; |
1094 | } | 1097 | } |
1095 | thread->pmds[i] = val; | 1098 | ctx->th_pmds[i] = val; |
1096 | 1099 | ||
1097 | DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n", | 1100 | DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n", |
1098 | i, | 1101 | i, |
1099 | thread->pmds[i], | 1102 | ctx->th_pmds[i], |
1100 | ctx->ctx_pmds[i].val)); | 1103 | ctx->ctx_pmds[i].val)); |
1101 | } | 1104 | } |
1102 | } | 1105 | } |
@@ -1107,7 +1110,6 @@ pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx) | |||
1107 | static inline void | 1110 | static inline void |
1108 | pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx) | 1111 | pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx) |
1109 | { | 1112 | { |
1110 | struct thread_struct *thread = &task->thread; | ||
1111 | unsigned long mask = ctx->ctx_all_pmcs[0]; | 1113 | unsigned long mask = ctx->ctx_all_pmcs[0]; |
1112 | int i; | 1114 | int i; |
1113 | 1115 | ||
@@ -1115,8 +1117,8 @@ pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx) | |||
1115 | 1117 | ||
1116 | for (i=0; mask; i++, mask>>=1) { | 1118 | for (i=0; mask; i++, mask>>=1) { |
1117 | /* masking 0 with ovfl_val yields 0 */ | 1119 | /* masking 0 with ovfl_val yields 0 */ |
1118 | thread->pmcs[i] = ctx->ctx_pmcs[i]; | 1120 | ctx->th_pmcs[i] = ctx->ctx_pmcs[i]; |
1119 | DPRINT(("pmc[%d]=0x%lx\n", i, thread->pmcs[i])); | 1121 | DPRINT(("pmc[%d]=0x%lx\n", i, ctx->th_pmcs[i])); |
1120 | } | 1122 | } |
1121 | } | 1123 | } |
1122 | 1124 | ||
@@ -2860,7 +2862,6 @@ pfm_reset_regs(pfm_context_t *ctx, unsigned long *ovfl_regs, int is_long_reset) | |||
2860 | static int | 2862 | static int |
2861 | pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | 2863 | pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) |
2862 | { | 2864 | { |
2863 | struct thread_struct *thread = NULL; | ||
2864 | struct task_struct *task; | 2865 | struct task_struct *task; |
2865 | pfarg_reg_t *req = (pfarg_reg_t *)arg; | 2866 | pfarg_reg_t *req = (pfarg_reg_t *)arg; |
2866 | unsigned long value, pmc_pm; | 2867 | unsigned long value, pmc_pm; |
@@ -2881,7 +2882,6 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
2881 | if (state == PFM_CTX_ZOMBIE) return -EINVAL; | 2882 | if (state == PFM_CTX_ZOMBIE) return -EINVAL; |
2882 | 2883 | ||
2883 | if (is_loaded) { | 2884 | if (is_loaded) { |
2884 | thread = &task->thread; | ||
2885 | /* | 2885 | /* |
2886 | * In system wide and when the context is loaded, access can only happen | 2886 | * In system wide and when the context is loaded, access can only happen |
2887 | * when the caller is running on the CPU being monitored by the session. | 2887 | * when the caller is running on the CPU being monitored by the session. |
@@ -3036,7 +3036,7 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
3036 | * | 3036 | * |
3037 | * The value in ctx_pmcs[] can only be changed in pfm_write_pmcs(). | 3037 | * The value in ctx_pmcs[] can only be changed in pfm_write_pmcs(). |
3038 | * | 3038 | * |
3039 | * The value in thread->pmcs[] may be modified on overflow, i.e., when | 3039 | * The value in th_pmcs[] may be modified on overflow, i.e., when |
3040 | * monitoring needs to be stopped. | 3040 | * monitoring needs to be stopped. |
3041 | */ | 3041 | */ |
3042 | if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum); | 3042 | if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum); |
@@ -3050,7 +3050,7 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
3050 | /* | 3050 | /* |
3051 | * write thread state | 3051 | * write thread state |
3052 | */ | 3052 | */ |
3053 | if (is_system == 0) thread->pmcs[cnum] = value; | 3053 | if (is_system == 0) ctx->th_pmcs[cnum] = value; |
3054 | 3054 | ||
3055 | /* | 3055 | /* |
3056 | * write hardware register if we can | 3056 | * write hardware register if we can |
@@ -3102,7 +3102,6 @@ error: | |||
3102 | static int | 3102 | static int |
3103 | pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | 3103 | pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) |
3104 | { | 3104 | { |
3105 | struct thread_struct *thread = NULL; | ||
3106 | struct task_struct *task; | 3105 | struct task_struct *task; |
3107 | pfarg_reg_t *req = (pfarg_reg_t *)arg; | 3106 | pfarg_reg_t *req = (pfarg_reg_t *)arg; |
3108 | unsigned long value, hw_value, ovfl_mask; | 3107 | unsigned long value, hw_value, ovfl_mask; |
@@ -3126,7 +3125,6 @@ pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
3126 | * the owner of the local PMU. | 3125 | * the owner of the local PMU. |
3127 | */ | 3126 | */ |
3128 | if (likely(is_loaded)) { | 3127 | if (likely(is_loaded)) { |
3129 | thread = &task->thread; | ||
3130 | /* | 3128 | /* |
3131 | * In system wide and when the context is loaded, access can only happen | 3129 | * In system wide and when the context is loaded, access can only happen |
3132 | * when the caller is running on the CPU being monitored by the session. | 3130 | * when the caller is running on the CPU being monitored by the session. |
@@ -3234,7 +3232,7 @@ pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
3234 | /* | 3232 | /* |
3235 | * write thread state | 3233 | * write thread state |
3236 | */ | 3234 | */ |
3237 | if (is_system == 0) thread->pmds[cnum] = hw_value; | 3235 | if (is_system == 0) ctx->th_pmds[cnum] = hw_value; |
3238 | 3236 | ||
3239 | /* | 3237 | /* |
3240 | * write hardware register if we can | 3238 | * write hardware register if we can |
@@ -3300,7 +3298,6 @@ abort_mission: | |||
3300 | static int | 3298 | static int |
3301 | pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | 3299 | pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) |
3302 | { | 3300 | { |
3303 | struct thread_struct *thread = NULL; | ||
3304 | struct task_struct *task; | 3301 | struct task_struct *task; |
3305 | unsigned long val = 0UL, lval, ovfl_mask, sval; | 3302 | unsigned long val = 0UL, lval, ovfl_mask, sval; |
3306 | pfarg_reg_t *req = (pfarg_reg_t *)arg; | 3303 | pfarg_reg_t *req = (pfarg_reg_t *)arg; |
@@ -3324,7 +3321,6 @@ pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
3324 | if (state == PFM_CTX_ZOMBIE) return -EINVAL; | 3321 | if (state == PFM_CTX_ZOMBIE) return -EINVAL; |
3325 | 3322 | ||
3326 | if (likely(is_loaded)) { | 3323 | if (likely(is_loaded)) { |
3327 | thread = &task->thread; | ||
3328 | /* | 3324 | /* |
3329 | * In system wide and when the context is loaded, access can only happen | 3325 | * In system wide and when the context is loaded, access can only happen |
3330 | * when the caller is running on the CPU being monitored by the session. | 3326 | * when the caller is running on the CPU being monitored by the session. |
@@ -3386,7 +3382,7 @@ pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
3386 | * if context is zombie, then task does not exist anymore. | 3382 | * if context is zombie, then task does not exist anymore. |
3387 | * In this case, we use the full value saved in the context (pfm_flush_regs()). | 3383 | * In this case, we use the full value saved in the context (pfm_flush_regs()). |
3388 | */ | 3384 | */ |
3389 | val = is_loaded ? thread->pmds[cnum] : 0UL; | 3385 | val = is_loaded ? ctx->th_pmds[cnum] : 0UL; |
3390 | } | 3386 | } |
3391 | rd_func = pmu_conf->pmd_desc[cnum].read_check; | 3387 | rd_func = pmu_conf->pmd_desc[cnum].read_check; |
3392 | 3388 | ||
@@ -4355,8 +4351,8 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
4355 | pfm_copy_pmds(task, ctx); | 4351 | pfm_copy_pmds(task, ctx); |
4356 | pfm_copy_pmcs(task, ctx); | 4352 | pfm_copy_pmcs(task, ctx); |
4357 | 4353 | ||
4358 | pmcs_source = thread->pmcs; | 4354 | pmcs_source = ctx->th_pmcs; |
4359 | pmds_source = thread->pmds; | 4355 | pmds_source = ctx->th_pmds; |
4360 | 4356 | ||
4361 | /* | 4357 | /* |
4362 | * always the case for system-wide | 4358 | * always the case for system-wide |
@@ -5865,14 +5861,12 @@ void | |||
5865 | pfm_save_regs(struct task_struct *task) | 5861 | pfm_save_regs(struct task_struct *task) |
5866 | { | 5862 | { |
5867 | pfm_context_t *ctx; | 5863 | pfm_context_t *ctx; |
5868 | struct thread_struct *t; | ||
5869 | unsigned long flags; | 5864 | unsigned long flags; |
5870 | u64 psr; | 5865 | u64 psr; |
5871 | 5866 | ||
5872 | 5867 | ||
5873 | ctx = PFM_GET_CTX(task); | 5868 | ctx = PFM_GET_CTX(task); |
5874 | if (ctx == NULL) return; | 5869 | if (ctx == NULL) return; |
5875 | t = &task->thread; | ||
5876 | 5870 | ||
5877 | /* | 5871 | /* |
5878 | * we always come here with interrupts ALREADY disabled by | 5872 | * we always come here with interrupts ALREADY disabled by |
@@ -5930,19 +5924,19 @@ pfm_save_regs(struct task_struct *task) | |||
5930 | * guarantee we will be schedule at that same | 5924 | * guarantee we will be schedule at that same |
5931 | * CPU again. | 5925 | * CPU again. |
5932 | */ | 5926 | */ |
5933 | pfm_save_pmds(t->pmds, ctx->ctx_used_pmds[0]); | 5927 | pfm_save_pmds(ctx->th_pmds, ctx->ctx_used_pmds[0]); |
5934 | 5928 | ||
5935 | /* | 5929 | /* |
5936 | * save pmc0 ia64_srlz_d() done in pfm_save_pmds() | 5930 | * save pmc0 ia64_srlz_d() done in pfm_save_pmds() |
5937 | * we will need it on the restore path to check | 5931 | * we will need it on the restore path to check |
5938 | * for pending overflow. | 5932 | * for pending overflow. |
5939 | */ | 5933 | */ |
5940 | t->pmcs[0] = ia64_get_pmc(0); | 5934 | ctx->th_pmcs[0] = ia64_get_pmc(0); |
5941 | 5935 | ||
5942 | /* | 5936 | /* |
5943 | * unfreeze PMU if had pending overflows | 5937 | * unfreeze PMU if had pending overflows |
5944 | */ | 5938 | */ |
5945 | if (t->pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); | 5939 | if (ctx->th_pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); |
5946 | 5940 | ||
5947 | /* | 5941 | /* |
5948 | * finally, allow context access. | 5942 | * finally, allow context access. |
@@ -5987,7 +5981,6 @@ static void | |||
5987 | pfm_lazy_save_regs (struct task_struct *task) | 5981 | pfm_lazy_save_regs (struct task_struct *task) |
5988 | { | 5982 | { |
5989 | pfm_context_t *ctx; | 5983 | pfm_context_t *ctx; |
5990 | struct thread_struct *t; | ||
5991 | unsigned long flags; | 5984 | unsigned long flags; |
5992 | 5985 | ||
5993 | { u64 psr = pfm_get_psr(); | 5986 | { u64 psr = pfm_get_psr(); |
@@ -5995,7 +5988,6 @@ pfm_lazy_save_regs (struct task_struct *task) | |||
5995 | } | 5988 | } |
5996 | 5989 | ||
5997 | ctx = PFM_GET_CTX(task); | 5990 | ctx = PFM_GET_CTX(task); |
5998 | t = &task->thread; | ||
5999 | 5991 | ||
6000 | /* | 5992 | /* |
6001 | * we need to mask PMU overflow here to | 5993 | * we need to mask PMU overflow here to |
@@ -6020,19 +6012,19 @@ pfm_lazy_save_regs (struct task_struct *task) | |||
6020 | /* | 6012 | /* |
6021 | * save all the pmds we use | 6013 | * save all the pmds we use |
6022 | */ | 6014 | */ |
6023 | pfm_save_pmds(t->pmds, ctx->ctx_used_pmds[0]); | 6015 | pfm_save_pmds(ctx->th_pmds, ctx->ctx_used_pmds[0]); |
6024 | 6016 | ||
6025 | /* | 6017 | /* |
6026 | * save pmc0 ia64_srlz_d() done in pfm_save_pmds() | 6018 | * save pmc0 ia64_srlz_d() done in pfm_save_pmds() |
6027 | * it is needed to check for pended overflow | 6019 | * it is needed to check for pended overflow |
6028 | * on the restore path | 6020 | * on the restore path |
6029 | */ | 6021 | */ |
6030 | t->pmcs[0] = ia64_get_pmc(0); | 6022 | ctx->th_pmcs[0] = ia64_get_pmc(0); |
6031 | 6023 | ||
6032 | /* | 6024 | /* |
6033 | * unfreeze PMU if had pending overflows | 6025 | * unfreeze PMU if had pending overflows |
6034 | */ | 6026 | */ |
6035 | if (t->pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); | 6027 | if (ctx->th_pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); |
6036 | 6028 | ||
6037 | /* | 6029 | /* |
6038 | * now get can unmask PMU interrupts, they will | 6030 | * now get can unmask PMU interrupts, they will |
@@ -6051,7 +6043,6 @@ void | |||
6051 | pfm_load_regs (struct task_struct *task) | 6043 | pfm_load_regs (struct task_struct *task) |
6052 | { | 6044 | { |
6053 | pfm_context_t *ctx; | 6045 | pfm_context_t *ctx; |
6054 | struct thread_struct *t; | ||
6055 | unsigned long pmc_mask = 0UL, pmd_mask = 0UL; | 6046 | unsigned long pmc_mask = 0UL, pmd_mask = 0UL; |
6056 | unsigned long flags; | 6047 | unsigned long flags; |
6057 | u64 psr, psr_up; | 6048 | u64 psr, psr_up; |
@@ -6062,11 +6053,10 @@ pfm_load_regs (struct task_struct *task) | |||
6062 | 6053 | ||
6063 | BUG_ON(GET_PMU_OWNER()); | 6054 | BUG_ON(GET_PMU_OWNER()); |
6064 | 6055 | ||
6065 | t = &task->thread; | ||
6066 | /* | 6056 | /* |
6067 | * possible on unload | 6057 | * possible on unload |
6068 | */ | 6058 | */ |
6069 | if (unlikely((t->flags & IA64_THREAD_PM_VALID) == 0)) return; | 6059 | if (unlikely((task->thread.flags & IA64_THREAD_PM_VALID) == 0)) return; |
6070 | 6060 | ||
6071 | /* | 6061 | /* |
6072 | * we always come here with interrupts ALREADY disabled by | 6062 | * we always come here with interrupts ALREADY disabled by |
@@ -6148,21 +6138,21 @@ pfm_load_regs (struct task_struct *task) | |||
6148 | * | 6138 | * |
6149 | * XXX: optimize here | 6139 | * XXX: optimize here |
6150 | */ | 6140 | */ |
6151 | if (pmd_mask) pfm_restore_pmds(t->pmds, pmd_mask); | 6141 | if (pmd_mask) pfm_restore_pmds(ctx->th_pmds, pmd_mask); |
6152 | if (pmc_mask) pfm_restore_pmcs(t->pmcs, pmc_mask); | 6142 | if (pmc_mask) pfm_restore_pmcs(ctx->th_pmcs, pmc_mask); |
6153 | 6143 | ||
6154 | /* | 6144 | /* |
6155 | * check for pending overflow at the time the state | 6145 | * check for pending overflow at the time the state |
6156 | * was saved. | 6146 | * was saved. |
6157 | */ | 6147 | */ |
6158 | if (unlikely(PMC0_HAS_OVFL(t->pmcs[0]))) { | 6148 | if (unlikely(PMC0_HAS_OVFL(ctx->th_pmcs[0]))) { |
6159 | /* | 6149 | /* |
6160 | * reload pmc0 with the overflow information | 6150 | * reload pmc0 with the overflow information |
6161 | * On McKinley PMU, this will trigger a PMU interrupt | 6151 | * On McKinley PMU, this will trigger a PMU interrupt |
6162 | */ | 6152 | */ |
6163 | ia64_set_pmc(0, t->pmcs[0]); | 6153 | ia64_set_pmc(0, ctx->th_pmcs[0]); |
6164 | ia64_srlz_d(); | 6154 | ia64_srlz_d(); |
6165 | t->pmcs[0] = 0UL; | 6155 | ctx->th_pmcs[0] = 0UL; |
6166 | 6156 | ||
6167 | /* | 6157 | /* |
6168 | * will replay the PMU interrupt | 6158 | * will replay the PMU interrupt |
@@ -6215,7 +6205,6 @@ pfm_load_regs (struct task_struct *task) | |||
6215 | void | 6205 | void |
6216 | pfm_load_regs (struct task_struct *task) | 6206 | pfm_load_regs (struct task_struct *task) |
6217 | { | 6207 | { |
6218 | struct thread_struct *t; | ||
6219 | pfm_context_t *ctx; | 6208 | pfm_context_t *ctx; |
6220 | struct task_struct *owner; | 6209 | struct task_struct *owner; |
6221 | unsigned long pmd_mask, pmc_mask; | 6210 | unsigned long pmd_mask, pmc_mask; |
@@ -6224,7 +6213,6 @@ pfm_load_regs (struct task_struct *task) | |||
6224 | 6213 | ||
6225 | owner = GET_PMU_OWNER(); | 6214 | owner = GET_PMU_OWNER(); |
6226 | ctx = PFM_GET_CTX(task); | 6215 | ctx = PFM_GET_CTX(task); |
6227 | t = &task->thread; | ||
6228 | psr = pfm_get_psr(); | 6216 | psr = pfm_get_psr(); |
6229 | 6217 | ||
6230 | BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP)); | 6218 | BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP)); |
@@ -6287,22 +6275,22 @@ pfm_load_regs (struct task_struct *task) | |||
6287 | */ | 6275 | */ |
6288 | pmc_mask = ctx->ctx_all_pmcs[0]; | 6276 | pmc_mask = ctx->ctx_all_pmcs[0]; |
6289 | 6277 | ||
6290 | pfm_restore_pmds(t->pmds, pmd_mask); | 6278 | pfm_restore_pmds(ctx->th_pmds, pmd_mask); |
6291 | pfm_restore_pmcs(t->pmcs, pmc_mask); | 6279 | pfm_restore_pmcs(ctx->th_pmcs, pmc_mask); |
6292 | 6280 | ||
6293 | /* | 6281 | /* |
6294 | * check for pending overflow at the time the state | 6282 | * check for pending overflow at the time the state |
6295 | * was saved. | 6283 | * was saved. |
6296 | */ | 6284 | */ |
6297 | if (unlikely(PMC0_HAS_OVFL(t->pmcs[0]))) { | 6285 | if (unlikely(PMC0_HAS_OVFL(ctx->th_pmcs[0]))) { |
6298 | /* | 6286 | /* |
6299 | * reload pmc0 with the overflow information | 6287 | * reload pmc0 with the overflow information |
6300 | * On McKinley PMU, this will trigger a PMU interrupt | 6288 | * On McKinley PMU, this will trigger a PMU interrupt |
6301 | */ | 6289 | */ |
6302 | ia64_set_pmc(0, t->pmcs[0]); | 6290 | ia64_set_pmc(0, ctx->th_pmcs[0]); |
6303 | ia64_srlz_d(); | 6291 | ia64_srlz_d(); |
6304 | 6292 | ||
6305 | t->pmcs[0] = 0UL; | 6293 | ctx->th_pmcs[0] = 0UL; |
6306 | 6294 | ||
6307 | /* | 6295 | /* |
6308 | * will replay the PMU interrupt | 6296 | * will replay the PMU interrupt |
@@ -6377,11 +6365,11 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx) | |||
6377 | */ | 6365 | */ |
6378 | pfm_unfreeze_pmu(); | 6366 | pfm_unfreeze_pmu(); |
6379 | } else { | 6367 | } else { |
6380 | pmc0 = task->thread.pmcs[0]; | 6368 | pmc0 = ctx->th_pmcs[0]; |
6381 | /* | 6369 | /* |
6382 | * clear whatever overflow status bits there were | 6370 | * clear whatever overflow status bits there were |
6383 | */ | 6371 | */ |
6384 | task->thread.pmcs[0] = 0; | 6372 | ctx->th_pmcs[0] = 0; |
6385 | } | 6373 | } |
6386 | ovfl_val = pmu_conf->ovfl_val; | 6374 | ovfl_val = pmu_conf->ovfl_val; |
6387 | /* | 6375 | /* |
@@ -6402,7 +6390,7 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx) | |||
6402 | /* | 6390 | /* |
6403 | * can access PMU always true in system wide mode | 6391 | * can access PMU always true in system wide mode |
6404 | */ | 6392 | */ |
6405 | val = pmd_val = can_access_pmu ? ia64_get_pmd(i) : task->thread.pmds[i]; | 6393 | val = pmd_val = can_access_pmu ? ia64_get_pmd(i) : ctx->th_pmds[i]; |
6406 | 6394 | ||
6407 | if (PMD_IS_COUNTING(i)) { | 6395 | if (PMD_IS_COUNTING(i)) { |
6408 | DPRINT(("[%d] pmd[%d] ctx_pmd=0x%lx hw_pmd=0x%lx\n", | 6396 | DPRINT(("[%d] pmd[%d] ctx_pmd=0x%lx hw_pmd=0x%lx\n", |
@@ -6434,7 +6422,7 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx) | |||
6434 | 6422 | ||
6435 | DPRINT(("[%d] ctx_pmd[%d]=0x%lx pmd_val=0x%lx\n", task->pid, i, val, pmd_val)); | 6423 | DPRINT(("[%d] ctx_pmd[%d]=0x%lx pmd_val=0x%lx\n", task->pid, i, val, pmd_val)); |
6436 | 6424 | ||
6437 | if (is_self) task->thread.pmds[i] = pmd_val; | 6425 | if (is_self) ctx->th_pmds[i] = pmd_val; |
6438 | 6426 | ||
6439 | ctx->ctx_pmds[i].val = val; | 6427 | ctx->ctx_pmds[i].val = val; |
6440 | } | 6428 | } |
@@ -6678,7 +6666,7 @@ pfm_init(void) | |||
6678 | ffz(pmu_conf->ovfl_val)); | 6666 | ffz(pmu_conf->ovfl_val)); |
6679 | 6667 | ||
6680 | /* sanity check */ | 6668 | /* sanity check */ |
6681 | if (pmu_conf->num_pmds >= IA64_NUM_PMD_REGS || pmu_conf->num_pmcs >= IA64_NUM_PMC_REGS) { | 6669 | if (pmu_conf->num_pmds >= PFM_NUM_PMD_REGS || pmu_conf->num_pmcs >= PFM_NUM_PMC_REGS) { |
6682 | printk(KERN_ERR "perfmon: not enough pmc/pmd, perfmon disabled\n"); | 6670 | printk(KERN_ERR "perfmon: not enough pmc/pmd, perfmon disabled\n"); |
6683 | pmu_conf = NULL; | 6671 | pmu_conf = NULL; |
6684 | return -1; | 6672 | return -1; |
@@ -6753,7 +6741,6 @@ void | |||
6753 | dump_pmu_state(const char *from) | 6741 | dump_pmu_state(const char *from) |
6754 | { | 6742 | { |
6755 | struct task_struct *task; | 6743 | struct task_struct *task; |
6756 | struct thread_struct *t; | ||
6757 | struct pt_regs *regs; | 6744 | struct pt_regs *regs; |
6758 | pfm_context_t *ctx; | 6745 | pfm_context_t *ctx; |
6759 | unsigned long psr, dcr, info, flags; | 6746 | unsigned long psr, dcr, info, flags; |
@@ -6798,16 +6785,14 @@ dump_pmu_state(const char *from) | |||
6798 | ia64_psr(regs)->up = 0; | 6785 | ia64_psr(regs)->up = 0; |
6799 | ia64_psr(regs)->pp = 0; | 6786 | ia64_psr(regs)->pp = 0; |
6800 | 6787 | ||
6801 | t = ¤t->thread; | ||
6802 | |||
6803 | for (i=1; PMC_IS_LAST(i) == 0; i++) { | 6788 | for (i=1; PMC_IS_LAST(i) == 0; i++) { |
6804 | if (PMC_IS_IMPL(i) == 0) continue; | 6789 | if (PMC_IS_IMPL(i) == 0) continue; |
6805 | printk("->CPU%d pmc[%d]=0x%lx thread_pmc[%d]=0x%lx\n", this_cpu, i, ia64_get_pmc(i), i, t->pmcs[i]); | 6790 | printk("->CPU%d pmc[%d]=0x%lx thread_pmc[%d]=0x%lx\n", this_cpu, i, ia64_get_pmc(i), i, ctx->th_pmcs[i]); |
6806 | } | 6791 | } |
6807 | 6792 | ||
6808 | for (i=1; PMD_IS_LAST(i) == 0; i++) { | 6793 | for (i=1; PMD_IS_LAST(i) == 0; i++) { |
6809 | if (PMD_IS_IMPL(i) == 0) continue; | 6794 | if (PMD_IS_IMPL(i) == 0) continue; |
6810 | printk("->CPU%d pmd[%d]=0x%lx thread_pmd[%d]=0x%lx\n", this_cpu, i, ia64_get_pmd(i), i, t->pmds[i]); | 6795 | printk("->CPU%d pmd[%d]=0x%lx thread_pmd[%d]=0x%lx\n", this_cpu, i, ia64_get_pmd(i), i, ctx->th_pmds[i]); |
6811 | } | 6796 | } |
6812 | 6797 | ||
6813 | if (ctx) { | 6798 | if (ctx) { |