ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

哪些性能事件可以使用PEBS?

2019-11-11 19:51:16  阅读:746  来源: 互联网

标签:performance intel performancecounter perf linux


我想了解哪些事件可以在我的事件上使用精确修饰符
CPU(桑迪桥).

英特尔软件开发人员手册(表18-32.PEBS性能
英特尔微体系结构代码名称Sandy Bridge的事件包含
仅以下事件:INST_RETIRED,UOPS_RETIRED,
BR_INST_RETIRED,BR_MISP_RETIRED,MEM_UOPS_RETIRED,
MEM_LOAD_UOPS_RETIRED,MEM_LOAD_UOPS_LLC_HIT_RETIRED.并且SandyBridge_core_V15.json用PEBS>列出了相同的事件. 0.

但是,有some examples个使用perf,它们将:p添加到cycles事件中.而且我可以在我的机器上成功运行perf record -e cycle:p.

同样,perf record -e cycles:p -vv-sleep 1打印精确的IP1.那么这是否意味着CPU_CLK_UNHALTED事件实际上使用了PEBS?

是否有可能获得支持:p的事件的完整列表?

解决方法:

在SandyBridge上有一些技巧可以支持cycles:p,而CPU_CLK_UNHALTED.*没有PEBS. hack是在intel_pebs_aliases_snb()中的perf内核部分中实现的.当用户使用非零精确修饰符请求-e周期,即PERF_COUNT_HW_CPU_CYCLES(转换为CPU_CLK_UNHALTED.CORE)时,此函数将使用PEBS将硬件事件更改为UOPS_RETIRED.ALL.

  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 }

intel_pebs_aliases_snb hack已在案例案例INTEL_FAM6_SANDYBRIDGE:/案例案例INTEL_FAM6_SANDYBRIDGE_X:中注册为3557 __init int intel_pmu_init(void)

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;

当precision_ip设置为非零时,从intel_pmu_hw_config()调用pebs_aliases:

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    }

该黑客攻击于2012年实施,lkml线程“ [PATCH] perf,x86:使周期:p在SNB上工作”,“ [tip:perf / core] perf / x86:为SNB / IVB实施周期:p”,cccb9ba9e4ee0d750265f53de9258df69655c40b, http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=cccb9ba9e4ee0d750265f53de9258df69655c40b

perf/x86: Implement cycles:p for SNB/IVB

Now that there’s finally a chip with working PEBS (IvyBridge), we can
enable the hardware and implement cycles:p for SNB/IVB.

而且我认为,除了arch/x86/events/intel/core.c中的Linux源代码,用于静态void intel_pebs_aliases的grep(通常实现了cycle:p / CPU_CLK_UNHALTED 0x003c的grep)之外,没有完整的此类“精确”转换hack列表,并检查intel_pmu_init的实际模型和确切的x86_pmu.选择的pebs_aliases变体:

> intel_pebs_aliases_core2,INST_RETIRED.ANY_P(0x00c0)CNTMASK = 16而不是周期:p
> intel_pebs_aliases_snb,UOPS_RETIRED.ALL(0x01c2)CNTMASK = 16而不是cycles:p
> intel_pebs_aliases_precdist可获取Precision_ip,INST_RETIRED.PREC_DIST(0x01c0)的最大值,而不是周期:SKL,IVB,HSW,BDW上的ppp

标签:performance,intel,performancecounter,perf,linux
来源: https://codeday.me/bug/20191111/2021926.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有