aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/kernel/perfmon.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ia64/kernel/perfmon.c')
-rw-r--r--arch/ia64/kernel/perfmon.c114
1 files changed, 50 insertions, 64 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 84a7e52f56f6..281004ff7b00 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -34,6 +34,7 @@
34#include <linux/file.h> 34#include <linux/file.h>
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/vfs.h> 36#include <linux/vfs.h>
37#include <linux/smp.h>
37#include <linux/pagemap.h> 38#include <linux/pagemap.h>
38#include <linux/mount.h> 39#include <linux/mount.h>
39#include <linux/bitops.h> 40#include <linux/bitops.h>
@@ -62,6 +63,9 @@
62 63
63#define PFM_INVALID_ACTIVATION (~0UL) 64#define PFM_INVALID_ACTIVATION (~0UL)
64 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
65/* 69/*
66 * depth of message queue 70 * depth of message queue
67 */ 71 */
@@ -296,14 +300,17 @@ typedef struct pfm_context {
296 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 */
297 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 */
298 302
299 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 */
300 304
301 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) */
302 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) */
303 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 */
304 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 */
305 309
306 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 */
307 314
308 u64 ctx_saved_psr_up; /* only contains psr.up value */ 315 u64 ctx_saved_psr_up; /* only contains psr.up value */
309 316
@@ -867,7 +874,6 @@ static void
867pfm_mask_monitoring(struct task_struct *task) 874pfm_mask_monitoring(struct task_struct *task)
868{ 875{
869 pfm_context_t *ctx = PFM_GET_CTX(task); 876 pfm_context_t *ctx = PFM_GET_CTX(task);
870 struct thread_struct *th = &task->thread;
871 unsigned long mask, val, ovfl_mask; 877 unsigned long mask, val, ovfl_mask;
872 int i; 878 int i;
873 879
@@ -888,7 +894,7 @@ pfm_mask_monitoring(struct task_struct *task)
888 * So in both cases, the live register contains the owner's 894 * So in both cases, the live register contains the owner's
889 * 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.
890 * 896 *
891 * As a consequence to this call, the thread->pmds[] array 897 * As a consequence to this call, the ctx->th_pmds[] array
892 * contains stale information which must be ignored 898 * contains stale information which must be ignored
893 * when context is reloaded AND monitoring is active (see 899 * when context is reloaded AND monitoring is active (see
894 * pfm_restart). 900 * pfm_restart).
@@ -923,9 +929,9 @@ pfm_mask_monitoring(struct task_struct *task)
923 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; 929 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER;
924 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { 930 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) {
925 if ((mask & 0x1) == 0UL) continue; 931 if ((mask & 0x1) == 0UL) continue;
926 ia64_set_pmc(i, th->pmcs[i] & ~0xfUL); 932 ia64_set_pmc(i, ctx->th_pmcs[i] & ~0xfUL);
927 th->pmcs[i] &= ~0xfUL; 933 ctx->th_pmcs[i] &= ~0xfUL;
928 DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, th->pmcs[i])); 934 DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, ctx->th_pmcs[i]));
929 } 935 }
930 /* 936 /*
931 * make all of this visible 937 * make all of this visible
@@ -942,7 +948,6 @@ static void
942pfm_restore_monitoring(struct task_struct *task) 948pfm_restore_monitoring(struct task_struct *task)
943{ 949{
944 pfm_context_t *ctx = PFM_GET_CTX(task); 950 pfm_context_t *ctx = PFM_GET_CTX(task);
945 struct thread_struct *th = &task->thread;
946 unsigned long mask, ovfl_mask; 951 unsigned long mask, ovfl_mask;
947 unsigned long psr, val; 952 unsigned long psr, val;
948 int i, is_system; 953 int i, is_system;
@@ -1008,9 +1013,9 @@ pfm_restore_monitoring(struct task_struct *task)
1008 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; 1013 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER;
1009 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { 1014 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) {
1010 if ((mask & 0x1) == 0UL) continue; 1015 if ((mask & 0x1) == 0UL) continue;
1011 th->pmcs[i] = ctx->ctx_pmcs[i]; 1016 ctx->th_pmcs[i] = ctx->ctx_pmcs[i];
1012 ia64_set_pmc(i, th->pmcs[i]); 1017 ia64_set_pmc(i, ctx->th_pmcs[i]);
1013 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]));
1014 } 1019 }
1015 ia64_srlz_d(); 1020 ia64_srlz_d();
1016 1021
@@ -1069,7 +1074,6 @@ pfm_restore_pmds(unsigned long *pmds, unsigned long mask)
1069static inline void 1074static inline void
1070pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx) 1075pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
1071{ 1076{
1072 struct thread_struct *thread = &task->thread;
1073 unsigned long ovfl_val = pmu_conf->ovfl_val; 1077 unsigned long ovfl_val = pmu_conf->ovfl_val;
1074 unsigned long mask = ctx->ctx_all_pmds[0]; 1078 unsigned long mask = ctx->ctx_all_pmds[0];
1075 unsigned long val; 1079 unsigned long val;
@@ -1091,11 +1095,11 @@ pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
1091 ctx->ctx_pmds[i].val = val & ~ovfl_val; 1095 ctx->ctx_pmds[i].val = val & ~ovfl_val;
1092 val &= ovfl_val; 1096 val &= ovfl_val;
1093 } 1097 }
1094 thread->pmds[i] = val; 1098 ctx->th_pmds[i] = val;
1095 1099
1096 DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n", 1100 DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n",
1097 i, 1101 i,
1098 thread->pmds[i], 1102 ctx->th_pmds[i],
1099 ctx->ctx_pmds[i].val)); 1103 ctx->ctx_pmds[i].val));
1100 } 1104 }
1101} 1105}
@@ -1106,7 +1110,6 @@ pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
1106static inline void 1110static inline void
1107pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx) 1111pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx)
1108{ 1112{
1109 struct thread_struct *thread = &task->thread;
1110 unsigned long mask = ctx->ctx_all_pmcs[0]; 1113 unsigned long mask = ctx->ctx_all_pmcs[0];
1111 int i; 1114 int i;
1112 1115
@@ -1114,8 +1117,8 @@ pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx)
1114 1117
1115 for (i=0; mask; i++, mask>>=1) { 1118 for (i=0; mask; i++, mask>>=1) {
1116 /* masking 0 with ovfl_val yields 0 */ 1119 /* masking 0 with ovfl_val yields 0 */
1117 thread->pmcs[i] = ctx->ctx_pmcs[i]; 1120 ctx->th_pmcs[i] = ctx->ctx_pmcs[i];
1118 DPRINT(("pmc[%d]=0x%lx\n", i, thread->pmcs[i])); 1121 DPRINT(("pmc[%d]=0x%lx\n", i, ctx->th_pmcs[i]));
1119 } 1122 }
1120} 1123}
1121 1124
@@ -2859,7 +2862,6 @@ pfm_reset_regs(pfm_context_t *ctx, unsigned long *ovfl_regs, int is_long_reset)
2859static int 2862static int
2860pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) 2863pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
2861{ 2864{
2862 struct thread_struct *thread = NULL;
2863 struct task_struct *task; 2865 struct task_struct *task;
2864 pfarg_reg_t *req = (pfarg_reg_t *)arg; 2866 pfarg_reg_t *req = (pfarg_reg_t *)arg;
2865 unsigned long value, pmc_pm; 2867 unsigned long value, pmc_pm;
@@ -2880,7 +2882,6 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
2880 if (state == PFM_CTX_ZOMBIE) return -EINVAL; 2882 if (state == PFM_CTX_ZOMBIE) return -EINVAL;
2881 2883
2882 if (is_loaded) { 2884 if (is_loaded) {
2883 thread = &task->thread;
2884 /* 2885 /*
2885 * 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
2886 * 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.
@@ -3035,7 +3036,7 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3035 * 3036 *
3036 * 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().
3037 * 3038 *
3038 * 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
3039 * monitoring needs to be stopped. 3040 * monitoring needs to be stopped.
3040 */ 3041 */
3041 if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum); 3042 if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum);
@@ -3049,7 +3050,7 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3049 /* 3050 /*
3050 * write thread state 3051 * write thread state
3051 */ 3052 */
3052 if (is_system == 0) thread->pmcs[cnum] = value; 3053 if (is_system == 0) ctx->th_pmcs[cnum] = value;
3053 3054
3054 /* 3055 /*
3055 * write hardware register if we can 3056 * write hardware register if we can
@@ -3101,7 +3102,6 @@ error:
3101static int 3102static int
3102pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) 3103pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3103{ 3104{
3104 struct thread_struct *thread = NULL;
3105 struct task_struct *task; 3105 struct task_struct *task;
3106 pfarg_reg_t *req = (pfarg_reg_t *)arg; 3106 pfarg_reg_t *req = (pfarg_reg_t *)arg;
3107 unsigned long value, hw_value, ovfl_mask; 3107 unsigned long value, hw_value, ovfl_mask;
@@ -3125,7 +3125,6 @@ pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3125 * the owner of the local PMU. 3125 * the owner of the local PMU.
3126 */ 3126 */
3127 if (likely(is_loaded)) { 3127 if (likely(is_loaded)) {
3128 thread = &task->thread;
3129 /* 3128 /*
3130 * 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
3131 * 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.
@@ -3233,7 +3232,7 @@ pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3233 /* 3232 /*
3234 * write thread state 3233 * write thread state
3235 */ 3234 */
3236 if (is_system == 0) thread->pmds[cnum] = hw_value; 3235 if (is_system == 0) ctx->th_pmds[cnum] = hw_value;
3237 3236
3238 /* 3237 /*
3239 * write hardware register if we can 3238 * write hardware register if we can
@@ -3299,7 +3298,6 @@ abort_mission:
3299static int 3298static int
3300pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) 3299pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3301{ 3300{
3302 struct thread_struct *thread = NULL;
3303 struct task_struct *task; 3301 struct task_struct *task;
3304 unsigned long val = 0UL, lval, ovfl_mask, sval; 3302 unsigned long val = 0UL, lval, ovfl_mask, sval;
3305 pfarg_reg_t *req = (pfarg_reg_t *)arg; 3303 pfarg_reg_t *req = (pfarg_reg_t *)arg;
@@ -3323,7 +3321,6 @@ pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3323 if (state == PFM_CTX_ZOMBIE) return -EINVAL; 3321 if (state == PFM_CTX_ZOMBIE) return -EINVAL;
3324 3322
3325 if (likely(is_loaded)) { 3323 if (likely(is_loaded)) {
3326 thread = &task->thread;
3327 /* 3324 /*
3328 * 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
3329 * 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.
@@ -3385,7 +3382,7 @@ pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3385 * if context is zombie, then task does not exist anymore. 3382 * if context is zombie, then task does not exist anymore.
3386 * 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()).
3387 */ 3384 */
3388 val = is_loaded ? thread->pmds[cnum] : 0UL; 3385 val = is_loaded ? ctx->th_pmds[cnum] : 0UL;
3389 } 3386 }
3390 rd_func = pmu_conf->pmd_desc[cnum].read_check; 3387 rd_func = pmu_conf->pmd_desc[cnum].read_check;
3391 3388
@@ -4354,8 +4351,8 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
4354 pfm_copy_pmds(task, ctx); 4351 pfm_copy_pmds(task, ctx);
4355 pfm_copy_pmcs(task, ctx); 4352 pfm_copy_pmcs(task, ctx);
4356 4353
4357 pmcs_source = thread->pmcs; 4354 pmcs_source = ctx->th_pmcs;
4358 pmds_source = thread->pmds; 4355 pmds_source = ctx->th_pmds;
4359 4356
4360 /* 4357 /*
4361 * always the case for system-wide 4358 * always the case for system-wide
@@ -5864,14 +5861,12 @@ void
5864pfm_save_regs(struct task_struct *task) 5861pfm_save_regs(struct task_struct *task)
5865{ 5862{
5866 pfm_context_t *ctx; 5863 pfm_context_t *ctx;
5867 struct thread_struct *t;
5868 unsigned long flags; 5864 unsigned long flags;
5869 u64 psr; 5865 u64 psr;
5870 5866
5871 5867
5872 ctx = PFM_GET_CTX(task); 5868 ctx = PFM_GET_CTX(task);
5873 if (ctx == NULL) return; 5869 if (ctx == NULL) return;
5874 t = &task->thread;
5875 5870
5876 /* 5871 /*
5877 * we always come here with interrupts ALREADY disabled by 5872 * we always come here with interrupts ALREADY disabled by
@@ -5929,19 +5924,19 @@ pfm_save_regs(struct task_struct *task)
5929 * guarantee we will be schedule at that same 5924 * guarantee we will be schedule at that same
5930 * CPU again. 5925 * CPU again.
5931 */ 5926 */
5932 pfm_save_pmds(t->pmds, ctx->ctx_used_pmds[0]); 5927 pfm_save_pmds(ctx->th_pmds, ctx->ctx_used_pmds[0]);
5933 5928
5934 /* 5929 /*
5935 * save pmc0 ia64_srlz_d() done in pfm_save_pmds() 5930 * save pmc0 ia64_srlz_d() done in pfm_save_pmds()
5936 * we will need it on the restore path to check 5931 * we will need it on the restore path to check
5937 * for pending overflow. 5932 * for pending overflow.
5938 */ 5933 */
5939 t->pmcs[0] = ia64_get_pmc(0); 5934 ctx->th_pmcs[0] = ia64_get_pmc(0);
5940 5935
5941 /* 5936 /*
5942 * unfreeze PMU if had pending overflows 5937 * unfreeze PMU if had pending overflows
5943 */ 5938 */
5944 if (t->pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); 5939 if (ctx->th_pmcs[0] & ~0x1UL) pfm_unfreeze_pmu();
5945 5940
5946 /* 5941 /*
5947 * finally, allow context access. 5942 * finally, allow context access.
@@ -5986,7 +5981,6 @@ static void
5986pfm_lazy_save_regs (struct task_struct *task) 5981pfm_lazy_save_regs (struct task_struct *task)
5987{ 5982{
5988 pfm_context_t *ctx; 5983 pfm_context_t *ctx;
5989 struct thread_struct *t;
5990 unsigned long flags; 5984 unsigned long flags;
5991 5985
5992 { u64 psr = pfm_get_psr(); 5986 { u64 psr = pfm_get_psr();
@@ -5994,7 +5988,6 @@ pfm_lazy_save_regs (struct task_struct *task)
5994 } 5988 }
5995 5989
5996 ctx = PFM_GET_CTX(task); 5990 ctx = PFM_GET_CTX(task);
5997 t = &task->thread;
5998 5991
5999 /* 5992 /*
6000 * we need to mask PMU overflow here to 5993 * we need to mask PMU overflow here to
@@ -6019,19 +6012,19 @@ pfm_lazy_save_regs (struct task_struct *task)
6019 /* 6012 /*
6020 * save all the pmds we use 6013 * save all the pmds we use
6021 */ 6014 */
6022 pfm_save_pmds(t->pmds, ctx->ctx_used_pmds[0]); 6015 pfm_save_pmds(ctx->th_pmds, ctx->ctx_used_pmds[0]);
6023 6016
6024 /* 6017 /*
6025 * save pmc0 ia64_srlz_d() done in pfm_save_pmds() 6018 * save pmc0 ia64_srlz_d() done in pfm_save_pmds()
6026 * it is needed to check for pended overflow 6019 * it is needed to check for pended overflow
6027 * on the restore path 6020 * on the restore path
6028 */ 6021 */
6029 t->pmcs[0] = ia64_get_pmc(0); 6022 ctx->th_pmcs[0] = ia64_get_pmc(0);
6030 6023
6031 /* 6024 /*
6032 * unfreeze PMU if had pending overflows 6025 * unfreeze PMU if had pending overflows
6033 */ 6026 */
6034 if (t->pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); 6027 if (ctx->th_pmcs[0] & ~0x1UL) pfm_unfreeze_pmu();
6035 6028
6036 /* 6029 /*
6037 * now get can unmask PMU interrupts, they will 6030 * now get can unmask PMU interrupts, they will
@@ -6050,7 +6043,6 @@ void
6050pfm_load_regs (struct task_struct *task) 6043pfm_load_regs (struct task_struct *task)
6051{ 6044{
6052 pfm_context_t *ctx; 6045 pfm_context_t *ctx;
6053 struct thread_struct *t;
6054 unsigned long pmc_mask = 0UL, pmd_mask = 0UL; 6046 unsigned long pmc_mask = 0UL, pmd_mask = 0UL;
6055 unsigned long flags; 6047 unsigned long flags;
6056 u64 psr, psr_up; 6048 u64 psr, psr_up;
@@ -6061,11 +6053,10 @@ pfm_load_regs (struct task_struct *task)
6061 6053
6062 BUG_ON(GET_PMU_OWNER()); 6054 BUG_ON(GET_PMU_OWNER());
6063 6055
6064 t = &task->thread;
6065 /* 6056 /*
6066 * possible on unload 6057 * possible on unload
6067 */ 6058 */
6068 if (unlikely((t->flags & IA64_THREAD_PM_VALID) == 0)) return; 6059 if (unlikely((task->thread.flags & IA64_THREAD_PM_VALID) == 0)) return;
6069 6060
6070 /* 6061 /*
6071 * we always come here with interrupts ALREADY disabled by 6062 * we always come here with interrupts ALREADY disabled by
@@ -6147,21 +6138,21 @@ pfm_load_regs (struct task_struct *task)
6147 * 6138 *
6148 * XXX: optimize here 6139 * XXX: optimize here
6149 */ 6140 */
6150 if (pmd_mask) pfm_restore_pmds(t->pmds, pmd_mask); 6141 if (pmd_mask) pfm_restore_pmds(ctx->th_pmds, pmd_mask);
6151 if (pmc_mask) pfm_restore_pmcs(t->pmcs, pmc_mask); 6142 if (pmc_mask) pfm_restore_pmcs(ctx->th_pmcs, pmc_mask);
6152 6143
6153 /* 6144 /*
6154 * check for pending overflow at the time the state 6145 * check for pending overflow at the time the state
6155 * was saved. 6146 * was saved.
6156 */ 6147 */
6157 if (unlikely(PMC0_HAS_OVFL(t->pmcs[0]))) { 6148 if (unlikely(PMC0_HAS_OVFL(ctx->th_pmcs[0]))) {
6158 /* 6149 /*
6159 * reload pmc0 with the overflow information 6150 * reload pmc0 with the overflow information
6160 * On McKinley PMU, this will trigger a PMU interrupt 6151 * On McKinley PMU, this will trigger a PMU interrupt
6161 */ 6152 */
6162 ia64_set_pmc(0, t->pmcs[0]); 6153 ia64_set_pmc(0, ctx->th_pmcs[0]);
6163 ia64_srlz_d(); 6154 ia64_srlz_d();
6164 t->pmcs[0] = 0UL; 6155 ctx->th_pmcs[0] = 0UL;
6165 6156
6166 /* 6157 /*
6167 * will replay the PMU interrupt 6158 * will replay the PMU interrupt
@@ -6214,7 +6205,6 @@ pfm_load_regs (struct task_struct *task)
6214void 6205void
6215pfm_load_regs (struct task_struct *task) 6206pfm_load_regs (struct task_struct *task)
6216{ 6207{
6217 struct thread_struct *t;
6218 pfm_context_t *ctx; 6208 pfm_context_t *ctx;
6219 struct task_struct *owner; 6209 struct task_struct *owner;
6220 unsigned long pmd_mask, pmc_mask; 6210 unsigned long pmd_mask, pmc_mask;
@@ -6223,7 +6213,6 @@ pfm_load_regs (struct task_struct *task)
6223 6213
6224 owner = GET_PMU_OWNER(); 6214 owner = GET_PMU_OWNER();
6225 ctx = PFM_GET_CTX(task); 6215 ctx = PFM_GET_CTX(task);
6226 t = &task->thread;
6227 psr = pfm_get_psr(); 6216 psr = pfm_get_psr();
6228 6217
6229 BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP)); 6218 BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP));
@@ -6286,22 +6275,22 @@ pfm_load_regs (struct task_struct *task)
6286 */ 6275 */
6287 pmc_mask = ctx->ctx_all_pmcs[0]; 6276 pmc_mask = ctx->ctx_all_pmcs[0];
6288 6277
6289 pfm_restore_pmds(t->pmds, pmd_mask); 6278 pfm_restore_pmds(ctx->th_pmds, pmd_mask);
6290 pfm_restore_pmcs(t->pmcs, pmc_mask); 6279 pfm_restore_pmcs(ctx->th_pmcs, pmc_mask);
6291 6280
6292 /* 6281 /*
6293 * check for pending overflow at the time the state 6282 * check for pending overflow at the time the state
6294 * was saved. 6283 * was saved.
6295 */ 6284 */
6296 if (unlikely(PMC0_HAS_OVFL(t->pmcs[0]))) { 6285 if (unlikely(PMC0_HAS_OVFL(ctx->th_pmcs[0]))) {
6297 /* 6286 /*
6298 * reload pmc0 with the overflow information 6287 * reload pmc0 with the overflow information
6299 * On McKinley PMU, this will trigger a PMU interrupt 6288 * On McKinley PMU, this will trigger a PMU interrupt
6300 */ 6289 */
6301 ia64_set_pmc(0, t->pmcs[0]); 6290 ia64_set_pmc(0, ctx->th_pmcs[0]);
6302 ia64_srlz_d(); 6291 ia64_srlz_d();
6303 6292
6304 t->pmcs[0] = 0UL; 6293 ctx->th_pmcs[0] = 0UL;
6305 6294
6306 /* 6295 /*
6307 * will replay the PMU interrupt 6296 * will replay the PMU interrupt
@@ -6376,11 +6365,11 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx)
6376 */ 6365 */
6377 pfm_unfreeze_pmu(); 6366 pfm_unfreeze_pmu();
6378 } else { 6367 } else {
6379 pmc0 = task->thread.pmcs[0]; 6368 pmc0 = ctx->th_pmcs[0];
6380 /* 6369 /*
6381 * clear whatever overflow status bits there were 6370 * clear whatever overflow status bits there were
6382 */ 6371 */
6383 task->thread.pmcs[0] = 0; 6372 ctx->th_pmcs[0] = 0;
6384 } 6373 }
6385 ovfl_val = pmu_conf->ovfl_val; 6374 ovfl_val = pmu_conf->ovfl_val;
6386 /* 6375 /*
@@ -6401,7 +6390,7 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx)
6401 /* 6390 /*
6402 * can access PMU always true in system wide mode 6391 * can access PMU always true in system wide mode
6403 */ 6392 */
6404 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];
6405 6394
6406 if (PMD_IS_COUNTING(i)) { 6395 if (PMD_IS_COUNTING(i)) {
6407 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",
@@ -6433,7 +6422,7 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx)
6433 6422
6434 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));
6435 6424
6436 if (is_self) task->thread.pmds[i] = pmd_val; 6425 if (is_self) ctx->th_pmds[i] = pmd_val;
6437 6426
6438 ctx->ctx_pmds[i].val = val; 6427 ctx->ctx_pmds[i].val = val;
6439 } 6428 }
@@ -6677,7 +6666,7 @@ pfm_init(void)
6677 ffz(pmu_conf->ovfl_val)); 6666 ffz(pmu_conf->ovfl_val));
6678 6667
6679 /* sanity check */ 6668 /* sanity check */
6680 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) {
6681 printk(KERN_ERR "perfmon: not enough pmc/pmd, perfmon disabled\n"); 6670 printk(KERN_ERR "perfmon: not enough pmc/pmd, perfmon disabled\n");
6682 pmu_conf = NULL; 6671 pmu_conf = NULL;
6683 return -1; 6672 return -1;
@@ -6752,7 +6741,6 @@ void
6752dump_pmu_state(const char *from) 6741dump_pmu_state(const char *from)
6753{ 6742{
6754 struct task_struct *task; 6743 struct task_struct *task;
6755 struct thread_struct *t;
6756 struct pt_regs *regs; 6744 struct pt_regs *regs;
6757 pfm_context_t *ctx; 6745 pfm_context_t *ctx;
6758 unsigned long psr, dcr, info, flags; 6746 unsigned long psr, dcr, info, flags;
@@ -6797,16 +6785,14 @@ dump_pmu_state(const char *from)
6797 ia64_psr(regs)->up = 0; 6785 ia64_psr(regs)->up = 0;
6798 ia64_psr(regs)->pp = 0; 6786 ia64_psr(regs)->pp = 0;
6799 6787
6800 t = &current->thread;
6801
6802 for (i=1; PMC_IS_LAST(i) == 0; i++) { 6788 for (i=1; PMC_IS_LAST(i) == 0; i++) {
6803 if (PMC_IS_IMPL(i) == 0) continue; 6789 if (PMC_IS_IMPL(i) == 0) continue;
6804 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]);
6805 } 6791 }
6806 6792
6807 for (i=1; PMD_IS_LAST(i) == 0; i++) { 6793 for (i=1; PMD_IS_LAST(i) == 0; i++) {
6808 if (PMD_IS_IMPL(i) == 0) continue; 6794 if (PMD_IS_IMPL(i) == 0) continue;
6809 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]);
6810 } 6796 }
6811 6797
6812 if (ctx) { 6798 if (ctx) {