简体   繁体   English

Linux用户空间中PEBS的x86-64“线性地址”?

[英]x86-64 “linear address” for PEBS from Linux userspace?

Is it possible to use the Haswell CPU feature PEBS (Precise Event Based Sampling) directly from a Linux userspace process instead of using a kernel interface? 是否可以直接从Linux用户空间进程使用Haswell CPU功能PEBS(基于精确事件的采样),而不使用内核接口?

I have succeeded in accessing performance counters from userspace using the RDPMC instruction and only using the kernel for WRMSR. 我已经成功使用RDPMC指令从用户空间访问性能计数器,并且仅将内核用于WRMSR。 This makes me very happy. 这让我很高兴。

Now I want to also access PEBS. 现在我也要访问PEBS。 To do this I need to use the MSR IA32_DS_AREA to supply a "debug store" memory area. 为此,我需要使用MSR IA32_DS_AREA提供“调试存储”存储区。 However, I am not sure how to allocate this memory and what address I need to use. 但是,我不确定如何分配该内存以及需要使用的地址。 I can allocate 2MB of contiguous physical memory (Linux HugeTLB with mlock()). 我可以分配2MB的连续物理内存(带有mlock()的Linux HugeTLB)。 I can also resolve the physical address of this memory (via procfs). 我也可以解析该内存的物理地址(通过procfs)。 However, I am not sure whether either the virtual or physical address is suitable as the "linear address" to supply for the MSR. 但是,我不确定虚拟地址还是物理地址是否适合作为MSR的“线性地址”。 (My concern is that the address may have to be in the kernel's virtual address space that I don't have access to.) (我担心的是,该地址可能必须位于我无法访问的内核的虚拟地址空间中。)

How can I prepare suitable memory for IA32_DS_AREA and logging PEBS events without writing a custom kernel module? 如何在不编写自定义内核模块的情况下为IA32_DS_AREA准备合适的内存并记录PEBS事件?

Yes, it is possible by using the perf infrastructure (you avoid using RDPMC/WRMSR). 是的,可以通过使用性能基础结构来实现(避免使用RDPMC / WRMSR)。 You can find several examples in this Github repo and more specifically tests within the tests/record_sample directory have multiple examples using the PEBS infrastructure through perf. 您可以在此Github存储库中找到几个示例,更具体地说, tests/record_sample目录中的tests/record_sample通过perf使用PEBS基础结构提供了多个示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM