导致主要页面错误的日志存储器访问 [英] Log memory accesses that cause major page faults

查看:49
本文介绍了导致主要页面错误的日志存储器访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何获取导致页面错误的内存访问(指针)吗?我主要对主要页面错误感兴趣.

Does anyone know how to get the memory accesses (pointers) that cause page faults? I'm interested mostly in the major page faults.

关于我要实现的目标的一些背景知识.我有一个具有大内存占用的应用程序(数据库),并且我想将分页与对大型数据结构(例如表,使用mmap()分配的索引)的访问相关联.该过程的映射很容易从/proc//maps中检索.现在,如果我具有导致页面错误的内存访问,则可以跟踪访问每个数据结构时引起了多少页面错误.

A bit of background about what I'm trying to achieve. I have an application with a large memory footprint (a database) and I want to correlate paging with the accesses to the large data structures (such as tables, indexes which are allocated using mmap()). The mappings of the process are easy to retrieve from /proc//maps. Now, if I have the memory accesses that cause page faults I can track how many page faults are caused when accessing each data structure.

我认为perf或systemtap可以胜任.有什么想法吗?

I think perf or systemtap could do the job. Any ideas?

推荐答案

您的猜测是正确的.您可以使用perf工具来跟踪应用程序引起的页面错误数.

Your guess is right. You can use perf tool to track the number of page faults that your application has caused.

我建议您阅读本教程,以学习使用该工具.

I recommend you to read this tutorial to learn to use the tool.

要安装,只需使用:

您正在寻找事件 page-fault .您可以通过以下方式安装(在ubuntu或其他apt发行版中):

You are looking for the event page-fault. You can install (in ubuntu or other apt distribution) by:

sudo apt-get install linux-tools-common linux-base 
sudo apt-get install linux-tools-YOUR-KERNEL number

您可以通过以下方式获取内核号:ame -r

You can obtain your kernel number with: uname -r

作为示例,此命令在"ls"命令上运行perf工具:

As an example, this command runs the perf tool on the "ls" command:

perf record -e page-faults:u -F 250 ls

然后您可以通过以下方法查看结果("ls"的二进制文件没有调试信息,因此不要指望有一个漂亮的输出):

and then you can look at the results (the binary of "ls" has no debug information, so don't expect a pretty output) with:

perf report

这篇关于导致主要页面错误的日志存储器访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆