CPU_CLK_UNHALTED.*
에 대한 PEBS가없는 SandyBridge에서 cycles:p
을 지원하는 해킹이 있습니다. 해킹은 perf
의 커널 부분에서 intel_pebs_aliases_snb()
에 구현됩니다. 사용자 PERF_COUNT_HW_CPU_CYCLES
이다 -e cycles
를 요청하면,이 함수는 PEBS으로 UOPS_RETIRED.ALL
하드웨어 이벤트를 변경할 것이다 제로 precise
개질제 (CPU_CLK_UNHALTED.CORE
로 변환)
intel_pebs_aliases_snb
해킹은
로
case INTEL_FAM6_SANDYBRIDGE:
/
case INTEL_FAM6_SANDYBRIDGE_X:
위한
3557 __init int intel_pmu_init(void)
에 등록
29 [PERF_COUNT_HW_CPU_CYCLES] = 0x003c,
2739 static void intel_pebs_aliases_snb(struct perf_event *event)
2740 {
2741 if ((event->hw.config & X86_RAW_EVENT_MASK) == 0x003c) {
2742 /*
2743 * Use an alternative encoding for CPU_CLK_UNHALTED.THREAD_P
2744 * (0x003c) so that we can use it with PEBS.
2745 *
2746 * The regular CPU_CLK_UNHALTED.THREAD_P event (0x003c) isn't
2747 * PEBS capable. However we can use UOPS_RETIRED.ALL
2748 * (0x01c2), which is a PEBS capable event, to get the same
2749 * count.
2750 *
2751 * UOPS_RETIRED.ALL counts the number of cycles that retires
2752 * CNTMASK micro-ops. By setting CNTMASK to a value (16)
2753 * larger than the maximum number of micro-ops that can be
2754 * retired per cycle (4) and then inverting the condition, we
2755 * count all cycles that retire 16 or less micro-ops, which
2756 * is every cycle.
2757 *
2758 * Thereby we gain a PEBS capable cycle counter.
2759 */
2760 u64 alt_config = X86_CONFIG(.event=0xc2, .umask=0x01, .inv=1, .cmask=16);
2761
2762 alt_config |= (event->hw.config & ~X86_RAW_EVENT_MASK);
2763 event->hw.config = alt_config;
2764 }
2765 }
3772 x86_pmu.event_constraints = intel_snb_event_constraints;
3773 x86_pmu.pebs_constraints = intel_snb_pebs_event_constraints;
3774 x86_pmu.pebs_aliases = intel_pebs_aliases_snb;
pebs_aliases
은 precise_ip
이 0이 아닌 값으로 설정된 경우 intel_pmu_hw_config()
에서 호출됩니다.
해킹은 2012 년에 구현 된
2814 static int intel_pmu_hw_config(struct perf_event *event)
2815 {
2821 if (event->attr.precise_ip) {
2828 if (x86_pmu.pebs_aliases)
2829 x86_pmu.pebs_aliases(event);
2830 }
, LKML 스레드 "[PATCH] 반환 한, 86은 : 사이클을 확인 : p는 SNB 작업", "[팁 : 반환 한/코어] 반환 한/86 : 사이클을 구현 : P를위한 SNB/IVB ", cccb9ba9e4ee0d750265f53de9258df69655c40b, http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=cccb9ba9e4ee0d750265f53de9258df69655c40b :
반환 한/86 : 구현 사이클 : 작업 PEBS (IvyBridge)와 칩이 마침내이 있다고
이제 SNB/IVB를위한 P, 우리는 하드웨어를 사용할 수 있습니다 SNB/IVB에 대해 사이클을 구현합니다.
그리고 내 생각에 대한 전체 arch/x86/events/intel/core.c
에서 리눅스 소스 코드 외에 예 : "정확한"변환 해킹의 목록, GREP이 없습니다 static void intel_pebs_aliases
(보통 cycles:p
/CPU_CLK_UNHALTED 0x003c
구현됩니다) 실제 모델과 정확한 x86_pmu.pebs_aliases
에 대한 intel_pmu_init
을 확인 변형 선택 :
- intel_pebs_aliases_core2,
INST_RETIRED.ANY_P (0x00c0) CNTMASK=16
대신 intel_pebs_aliases_snb
cycles:p
의, UOPS_RETIRED.ALL (0x01c2) CNTMASK=16
대신을의 precise_ip
의 가장 높은 값을는
- intel_pebs_aliases_precdist 대신 SKL, IVB, HSW에
cycles:ppp
의 INST_RETIRED.PREC_DIST (0x01c0)
, BDW 이
일리아가 시도 [인텔의 PMU-도구에서 ocperf] (https://github.com/andikleen/ pmu-tools). 인텔 CPU의 전체 이벤트 목록 ('ocperf list'?)이 있으며 바닐라 perf는 사용자 공간에 전체 목록이 없습니다. 헤더 인쇄가있는 perf 보고서가 0이 아닌 exact_ip 보고서를 포함합니까? (레코드에 의해 필요하지만 커널에 의해 비활성화 될 수 있음)? 커널 버전은 무엇입니까? [ '정확한 _ 칩의 1'은 "SAMPLE_IP에 일정한 스키드가 있어야합니다."] (http://lxr.free-electrons.com/source/include/uapi/linux/perf_event.h?v=4.8#L323) – osgx