【问题标题】:PMU x86-64 performance counters not showing in perf under AWSPMU x86-64 性能计数器未显示在 AWS 下的 perf 中
【发布时间】:2021-11-22 12:19:19
【问题描述】:

我正在为特定应用程序运行 C++ 基准测试。在这个测试中,我在临界区之前打开性能计数器文件(__NR_perf_event_open syscall),继续该部分,然后在读取指定的指标(指令、周期、分支、缓存未命中等)之后。

我验证这需要在 sudo 下运行,因为该进程需要 CAP_PERFCOUNT 功能。我还必须验证 /proc/sys/kernel/perf_event_paranoid 是否设置为大于 2 的数字,对于带有内核 5.11.0 的 Ubuntu 20.04.3 似乎总是如此,这是我在测试中标准化的操作系统。

此设置适用于我的所有本地计算机。但是,在云上,它仅适用于 m5zn.6xlarge(英特尔至强铂金 8252C)的某些实例。它不适用于其他 t3.medium、c3.4xlarge、c5a.8xlarge。

它们的 AMI 都是相同的 ami-09e67e426f25ce0d7。

验证此行为的一种简单方法是运行以下命令:

sudo perf stat /bin/sleep 1

在 m5zn 盒子上我会看到:

 Performance counter stats for '/bin/sleep 1':

          0.54 msec task-clock                #    0.001 CPUs utiliz
             1      context-switches          #    0.002 M/sec
             1      cpu-migrations            #    0.002 M/sec
            75      page-faults               #    0.139 M/sec
       2191485      cycles                    #    4.070 GHz
       1292564      instructions              #    0.59  insn per cyc
        258373      branches                  #  479.860 M/sec
         11090      branch-misses             #    4.29% of all branc

   1.000902741 seconds time elapsed

   0.000889000 seconds user
   0.000000000 seconds sys

Perf with valid output

在其他盒子上我会看到:

 Performance counter stats for '/bin/sleep 1':

          0.62 msec task-clock                #    0.001 CPUs utilized
             2      context-switches          #    0.003 M/sec
             0      cpu-migrations            #    0.000 K/sec
            76      page-faults               #    0.124 M/sec
<not supported>      cycles
<not supported>      instructions
<not supported>      branches
<not supported>      branch-misses

   1.002488031 seconds time elapsed

   0.000930000 seconds user
   0.000000000 seconds sys

Perf with not supported values

我怀疑 m5zn.6xlarge 由真实实例支持,而其他实例是共享实例。我的怀疑正确吗?

我可以启动哪些实例来为我提供性能计数器 PMU 支持?

谢谢!

【问题讨论】:

    标签: amazon-web-services amazon-ec2 linux-kernel performancecounter intel-pmu


    【解决方案1】:

    经过一番研究,我发现由于所有 Amazon AWS 实例都是虚拟实例,因此没有一个客户操作系统可以直接访问硬件性能计数器(PMC 或 PMU)。

    来宾操作系统只能通过称为虚拟 PMU (vPMU) 的内核驱动程序读取性能计数器,该驱动程序仅适用于某些 Intel Xeon CPU。

    因此,在我尝试的实例列表中,只有配备 Intel Platinum 8252 的 m5zn 具有受支持的 CPU。

    很容易通过运行检查来宾操作系统是否支持vPMU

    cat /proc/cpuinfo | grep arch_perfmon
    

    也可以在 smpboot 之后检查 dmesg 输出:

    [    0.916264] smpboot: CPU0: Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz (family: 0x6, model: 0x55, stepping: 0x4)
    [    0.916410] Performance Events: unsupported p6 CPU model 85 no PMU driver, software events only.
    

    在 AWS 上,经验法则是您只能在最大的实例或占用整个套接字的实例上获得 vPMU。

    https://oavdeev.github.io/posts/vpmu_support_z1d/

    目前这些实例支持 vPMU:

    i3.metal
    c5.9xlarge
    c5.18xlarge
    m4.16xlarge
    m5.12xlarge
    m5.24xlarge
    r5.12xlarge
    r5.24xlarge
    f1.16xlarge
    h1.16xlarge
    i3.16xlarge
    p2.16xlarge
    p3.16xlarge
    r4.16xlarge
    x1.32xlarge
    c5d.9xlarge
    c5d.18xlarge
    m5d.12xlarge
    m5d.24xlarge
    r5d.12xlarge
    r5d.24xlarge
    x1e.32xlarge
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-26
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 2014-03-06
      • 2020-04-15
      • 2018-08-02
      相关资源
      最近更新 更多