ARMv7 PMU(Performance Monitor Unit) 驱动(cache 命中率)

本文介绍了如何在ARMv7系统中利用PMU(Performance Monitor Unit)驱动来统计CPU缓存命中率。通过在kernel proc下添加驱动,实现了在/proc/cacheinfo下查看缓存命中率。驱动涉及到对PMU寄存器的操作,包括开启计数器、设置事件类型以及处理溢出情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[ARM CPU cache命中率(proc驱动支持)]

SOC项目需要对系统性能进行评价,因此需要对CPU cache命中率进行统计,幸好ARM CPU够强大,通过在kernel proc下添加相关驱动,成功解决,具体如下:

添加proc下的cache命中率统计模块

#include <linux/fs.h>

#include <linux/init.h>

#include <linux/proc_fs.h>

#include <linux/seq_file.h>



extern const struct seq_operations cacheinfo_op;

static int cacheinfo_open(struct inode *inode, struct file *file)

{

return seq_open(file, &cacheinfo_op);

}



static const struct file_operations proc_cacheinfo_operations = {

.open           = cacheinfo_open,

.read           = seq_read,

.llseek         = seq_lseek,

.release        = seq_release,

};



static int __init proc_cacheinfo_init(void)

{

proc_create("cacheinfo", 0, NULL, &proc_cacheinfo_operations);

return 0;

}

module_init(proc_cacheinfo_init);

之后实现cacheinfo_op:

const struct seq_operations cacheinfo_op = {

.start  = ca_start,

.next   = ca_next,

.stop   = ca_stop,

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值