我发现我的MMIO读/写延迟非常高.我希望有人能给我一些建议.
在内核空间中,我编写了一个简单的程序来读取PCIe设备的BAR0地址中的4字节值.该设备是PCIe Intel 10G NIC,并插在我的Xeon E5服务器上的PCIe x16总线上.我使用rdtsc来测量MMIO读取开始和结束之间的时间,代码片段如下所示:
vaddr = ioremap_nocache(0xf8000000, 128); // addr is the BAR0 of the device
rdtscl(init);
ret = readl(vaddr);
rmb();
rdtscl(end);
Run Code Online (Sandbox Code Playgroud)
我期望(end,init)之间的经过时间小于1us,毕竟,遍历PCIe数据链路的数据应该只有几纳秒.但是,我的测试结果显示至少5.5用于执行MMIO PCIe设备读取.我想知道这是否合理.我将我的代码更改为远程内存屏障(rmb),但仍然可以获得大约5美分的延迟.
本文提到了PCIe延迟测量.通常它不到1us.www.cl.cam.ac.uk/~awm22/.../miller2009motivating.pdf我是否需要进行任何特殊配置(如内核或设备)才能获得更低的MMIO访问延迟?或者有没有人有过这样的经历?
我正在使用Linux 3.6.0的x86系统.对于某些实验,我需要知道IRQ如何映射到矢量.我从很多书中学到说,向量0x0到0x20用于陷阱和异常,从向量0x20开始用于外部器件中断.这也在源代码Linux/arch/x86/include/asm/irq_vectors.h中定义
但是,令我困惑的是,当我检查do_IRQ函数时,http: //lxr.linux.no/linux+v3.6/arch/x86/kernel/irq.c#L181 我发现IRQ是由查找"vector_irq"数组:
unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
{
struct pt_regs *old_regs = set_irq_regs(regs);
/* high bit used in ret_from_ code */
unsigned vector = ~regs->orig_ax;
unsigned irq;
...
irq = __this_cpu_read(vector_irq[vector]); // get the IRQ from the vector_irq
// print out the vector_irq
prink("CPU-ID:%d, vector: 0x%x - irq: %d", smp_processor_id(), vector, irq);
}
Run Code Online (Sandbox Code Playgroud)
通过使用printk检测代码,我得到的vector-irq映射如下所示,我不知道为什么这是映射.我虽然映射应该是(irq + 0x20 = vector),但似乎并非如此.
from: Linux/arch/x86/include/asm/irq_vector.h
* Vectors 0 ... 31 : system traps and exceptions - hardcoded events
* Vectors …Run Code Online (Sandbox Code Playgroud)