【问题标题】:What [Vectors] means in perf top report?perf top report中的[Vectors]是什么意思?
【发布时间】:2018-07-13 07:00:26
【问题描述】:

我使用 perf top 来分析一个在 arm-linux 上运行的进程,结果如下所示:

 4.27%  [vectors]             [.] 0x00000fc4                      
 3.84%  [kernel]              [k] _raw_spin_unlock_irqrestore     
 2.30%  [kernel]              [k] _raw_spin_unlock_irq            
 1.94%  libc-2.20.so          [.] 0x0007c35c                      
 1.91%  [vectors]             [.] 0x00000fd8                      
 1.56%  libGLESv2.so.1.9.6.0  [.] 0x0003a5e0                      
 1.34%  libGLESv2.so.1.9.6.0  [.] 0x0003a5cc                      
 0.91%  [omapdrm_pvr]         [k] _SegmentListInsert              
 0.87%  libpthread-2.20.so    [.] 0x0000aee4                      
 0.82%  libc-2.20.so          [.] 0x00075464                      
 0.76%  libc-2.20.so          [.] 0x0007767c                      
 0.48%  libpthread-2.20.so    [.] 0x000094dc                      
 0.46%  libv8.so.4            [.] 0x0017a058                      
 0.46%  libGLESv2.so.1.9.6.0  [.] 0x0003a420                      
 0.43%  [kernel]              [k] do_nanosleep                    
 0.41%  [kernel]              [k] __copy_from_user                
 0.40%  libc-2.20.so          [.] 0x0007d8a4                      
 0.40%  libpthread-2.20.so    [.] 0x00009480                      
 0.39%  [kernel]              [k] do_vfp                          
 0.39%  librender_engine.so   [.] 0x004d3ff8 

我想知道 [vectros] 可能代表什么?据我所知,它不是内核模块,但是,0x00000fc4 是一个永远不应该使用的低端地址,除此之外,0x00000fc4 似乎是arm异常向量的地址。

欢迎任何评论。

【问题讨论】:

  • 中断处理程序似乎是合理的,甚至可能。尤其是如果您的工作量中断繁重,我认为这是基于_raw_spin_unlock_irq 有大量时间的情况。

标签: vector kernel perf


【解决方案1】:

这个[vectors]是用于arm memory range ofvectors page的,名称在arch/arm64/kernel/vdso.caarch32_setup_vectors_page函数中定义

#define AARCH32_VECTORS_BASE    0xffff0000
....

int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp)
{
...
    unsigned long addr = AARCH32_VECTORS_BASE;
    static const struct vm_special_mapping spec = {
        .name   = "[vectors]",
        .pages  = vectors_page,
    };
    ...
    current->mm->context.vdso = (void *)addr;

    /* Map vectors page at the high address. */
    ret = _install_special_mapping(mm, addr, PAGE_SIZE,
                       VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC,
                       &spec);
    ...
}

arch_vma_namearch/arm/kernel/process.c

/*
 * The vectors page is always readable from user space for the
 * atomic helpers. Insert it into the gate_vma so that it is visible
 * through ptrace and /proc/<pid>/mem.
 */
static struct vm_area_struct gate_vma = {
    .vm_start   = 0xffff0000,
    .vm_end     = 0xffff0000 + PAGE_SIZE,
    .vm_flags   = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC,
};
...

const char *arch_vma_name(struct vm_area_struct *vma)
{
    return is_gate_vma(vma) ? "[vectors]" : NULL;
}

我不确定 perf 是否会在该区域中显示用于分析样本的正确地址,它可能会在该部分内偏移...

另一个关于arm的矢量页面的问题:Vectors page mapping in linux for ARM

arm32上的“异常向量表”映射到0xffff0000,根据https://doar-e.github.io/blog/2014/04/30/corrupting-arm-evt/ 您可以在平台上检查cat /proc/self/maps 的输出,并使用gdb x/1024wx 0xffff0000 从0xffff0000 偏移量转储页面。

关于 arm64 https://blog.linuxplumbersconf.org/2016/ocw/system/presentations/3711/original/LPC_vDSO.pdf 上的新 vdso 的演示文稿

【讨论】:

  • 我把内存转储出来了,原来 0xffff0fc4 是一个循环的入口。 --- (gdb) x/1024ih 0xffff0fc0 0xffff0fc0: dmb ish 0xffff0fc4: ldrex r3, [r2] 0xffff0fc8: subs r3, r3, r0 0xffff0fcc: strexeq r3, r1, [r2] 0xffff0fd0: teqeq r3, # 0xffff0fc4 --- 00000fc4 更有可能是节内的偏移量。
  • @LeonardoPhysh,谢谢!是的,perf 可以将这种映射视为一些文件映射,并将显示偏移量。评论说“原子助手”,而ldrex 是原子的,所以这段代码可能是LL/SC style 的一些原子同步原语的实现。检查程序的多线程同步,以及 CPU 的硬件特性。
猜你喜欢
  • 2013-11-20
  • 1970-01-01
  • 2012-09-18
  • 2022-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-22
  • 2011-09-13
相关资源
最近更新 更多