aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2014-08-11 15:27:13 -0400
committerIngo Molnar <mingo@kernel.org>2014-08-13 01:51:16 -0400
commitc8aab2e04ac9f442a07abeaf49ddd1703c608f47 (patch)
tree06c3673adc39b10d9c5651439d5c1387a706a824 /arch
parent770eee1fd38c70a009b321f5dbe64358f42511fd (diff)
perf/x86: Clean up __intel_pmu_pebs_event() code
This patch makes the code more readable. It also renames precise_store_data_hsw() to precise_datala_hsw() because the function is called for both loads and stores on HSW. The patch also gets rid of the hardcoded store events codes in that same function. Signed-off-by: Stephane Eranian <eranian@google.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1407785233-32193-5-git-send-email-eranian@google.com Cc: ak@linux.intel.com Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 67919ce0f76a..9dc419991772 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -108,10 +108,9 @@ static u64 precise_store_data(u64 status)
108 return val; 108 return val;
109} 109}
110 110
111static u64 precise_store_data_hsw(struct perf_event *event, u64 status) 111static u64 precise_datala_hsw(struct perf_event *event, u64 status)
112{ 112{
113 union perf_mem_data_src dse; 113 union perf_mem_data_src dse;
114 u64 cfg = event->hw.config & INTEL_ARCH_EVENT_MASK;
115 114
116 dse.val = PERF_MEM_NA; 115 dse.val = PERF_MEM_NA;
117 116
@@ -128,15 +127,12 @@ static u64 precise_store_data_hsw(struct perf_event *event, u64 status)
128 * MEM_UOPS_RETIRED.SPLIT_STORES 127 * MEM_UOPS_RETIRED.SPLIT_STORES
129 * MEM_UOPS_RETIRED.ALL_STORES 128 * MEM_UOPS_RETIRED.ALL_STORES
130 */ 129 */
131 if (cfg != 0x12d0 && cfg != 0x22d0 && cfg != 0x42d0 && cfg != 0x82d0) 130 if (event->hw.flags & PERF_X86_EVENT_PEBS_ST_HSW) {
132 return dse.val; 131 if (status & 1)
133 132 dse.mem_lvl = PERF_MEM_LVL_L1 | PERF_MEM_LVL_HIT;
134 if (status & 1) 133 else
135 dse.mem_lvl = PERF_MEM_LVL_L1 | PERF_MEM_LVL_HIT; 134 dse.mem_lvl = PERF_MEM_LVL_L1 | PERF_MEM_LVL_MISS;
136 else 135 }
137 dse.mem_lvl = PERF_MEM_LVL_L1 | PERF_MEM_LVL_MISS;
138
139 /* Nothing else supported. Sorry. */
140 return dse.val; 136 return dse.val;
141} 137}
142 138
@@ -825,6 +821,10 @@ static inline u64 intel_hsw_transaction(struct pebs_record_hsw *pebs)
825static void __intel_pmu_pebs_event(struct perf_event *event, 821static void __intel_pmu_pebs_event(struct perf_event *event,
826 struct pt_regs *iregs, void *__pebs) 822 struct pt_regs *iregs, void *__pebs)
827{ 823{
824#define PERF_X86_EVENT_PEBS_HSW_PREC \
825 (PERF_X86_EVENT_PEBS_ST_HSW | \
826 PERF_X86_EVENT_PEBS_LD_HSW | \
827 PERF_X86_EVENT_PEBS_NA_HSW)
828 /* 828 /*
829 * We cast to the biggest pebs_record but are careful not to 829 * We cast to the biggest pebs_record but are careful not to
830 * unconditionally access the 'extra' entries. 830 * unconditionally access the 'extra' entries.
@@ -834,47 +834,40 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
834 struct perf_sample_data data; 834 struct perf_sample_data data;
835 struct pt_regs regs; 835 struct pt_regs regs;
836 u64 sample_type; 836 u64 sample_type;
837 int fll, fst; 837 int fll, fst, dsrc;
838 int fl = event->hw.flags;
838 839
839 if (!intel_pmu_save_and_restart(event)) 840 if (!intel_pmu_save_and_restart(event))
840 return; 841 return;
841 842
842 fll = event->hw.flags & PERF_X86_EVENT_PEBS_LDLAT; 843 sample_type = event->attr.sample_type;
843 fst = event->hw.flags & (PERF_X86_EVENT_PEBS_ST | 844 dsrc = sample_type & PERF_SAMPLE_DATA_SRC;
844 PERF_X86_EVENT_PEBS_ST_HSW | 845
845 PERF_X86_EVENT_PEBS_LD_HSW | 846 fll = fl & PERF_X86_EVENT_PEBS_LDLAT;
846 PERF_X86_EVENT_PEBS_NA_HSW); 847 fst = fl & (PERF_X86_EVENT_PEBS_ST | PERF_X86_EVENT_PEBS_HSW_PREC);
847 848
848 perf_sample_data_init(&data, 0, event->hw.last_period); 849 perf_sample_data_init(&data, 0, event->hw.last_period);
849 850
850 data.period = event->hw.last_period; 851 data.period = event->hw.last_period;
851 sample_type = event->attr.sample_type;
852 852
853 /* 853 /*
854 * if PEBS-LL or PreciseStore 854 * Use latency for weight (only avail with PEBS-LL)
855 */ 855 */
856 if (fll || fst) { 856 if (fll && (sample_type & PERF_SAMPLE_WEIGHT))
857 /* 857 data.weight = pebs->lat;
858 * Use latency for weight (only avail with PEBS-LL) 858
859 */ 859 /*
860 if (fll && (sample_type & PERF_SAMPLE_WEIGHT)) 860 * data.data_src encodes the data source
861 data.weight = pebs->lat; 861 */
862 862 if (dsrc) {
863 /* 863 u64 val = PERF_MEM_NA;
864 * data.data_src encodes the data source 864 if (fll)
865 */ 865 val = load_latency_data(pebs->dse);
866 if (sample_type & PERF_SAMPLE_DATA_SRC) { 866 else if (fst && (fl & PERF_X86_EVENT_PEBS_HSW_PREC))
867 if (fll) 867 val = precise_datala_hsw(event, pebs->dse);
868 data.data_src.val = load_latency_data(pebs->dse); 868 else if (fst)
869 else if (event->hw.flags & 869 val = precise_store_data(pebs->dse);
870 (PERF_X86_EVENT_PEBS_ST_HSW| 870 data.data_src.val = val;
871 PERF_X86_EVENT_PEBS_LD_HSW|
872 PERF_X86_EVENT_PEBS_NA_HSW))
873 data.data_src.val =
874 precise_store_data_hsw(event, pebs->dse);
875 else
876 data.data_src.val = precise_store_data(pebs->dse);
877 }
878 } 871 }
879 872
880 /* 873 /*
@@ -901,16 +894,16 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
901 else 894 else
902 regs.flags &= ~PERF_EFLAGS_EXACT; 895 regs.flags &= ~PERF_EFLAGS_EXACT;
903 896
904 if ((event->attr.sample_type & PERF_SAMPLE_ADDR) && 897 if ((sample_type & PERF_SAMPLE_ADDR) &&
905 x86_pmu.intel_cap.pebs_format >= 1) 898 x86_pmu.intel_cap.pebs_format >= 1)
906 data.addr = pebs->dla; 899 data.addr = pebs->dla;
907 900
908 if (x86_pmu.intel_cap.pebs_format >= 2) { 901 if (x86_pmu.intel_cap.pebs_format >= 2) {
909 /* Only set the TSX weight when no memory weight. */ 902 /* Only set the TSX weight when no memory weight. */
910 if ((event->attr.sample_type & PERF_SAMPLE_WEIGHT) && !fll) 903 if ((sample_type & PERF_SAMPLE_WEIGHT) && !fll)
911 data.weight = intel_hsw_weight(pebs); 904 data.weight = intel_hsw_weight(pebs);
912 905
913 if (event->attr.sample_type & PERF_SAMPLE_TRANSACTION) 906 if (sample_type & PERF_SAMPLE_TRANSACTION)
914 data.txn = intel_hsw_transaction(pebs); 907 data.txn = intel_hsw_transaction(pebs);
915 } 908 }
916 909