iMX6 kmalloc'ed memory is slow

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

iMX6 kmalloc'ed memory is slow

跳至解决方案
2,162 次查看
SteveBakke
Contributor II

If we run completely in kernel and use kmalloc to allocate 1M buffers, it takes about 2ms to copy one to another. If run completely in userspace and use malloc to allocate 1M buffers, it takes about .5ms to copy them. We tried both standard memcpy and a NEON optimized copy for both, no difference. We changed the size of buffers and made no difference, always about 1/4 the speed.

Why is kmalloc'ed memory slower then malloc'ed memory? Is the cache different?

Running iMX6 DL Sabre SDP using latest Freescale ltib generated kernel (3.0.5.35-2039)

标签 (2)
标记 (1)
1 解答
1,621 次查看
JasonZhang1z
Contributor II

I thought maybe this related to the pressure of Kernel Normal Zone and High Memroy.

User malloc is all allocate from Hign Zone, and it was NOT phycal continue.

But Kmalloc is allocate from Normal Zone, and it was Physical continue.

So you maybe want to check:

1. what your memory free pages situation of each zone by /proc/zoneinfo

2. try the vmalloc in kernel, this can be compare to malloc in user space, kmalloc is physical continue, it's was very few 1M continue phy memory after kernel boot.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,622 次查看
JasonZhang1z
Contributor II

I thought maybe this related to the pressure of Kernel Normal Zone and High Memroy.

User malloc is all allocate from Hign Zone, and it was NOT phycal continue.

But Kmalloc is allocate from Normal Zone, and it was Physical continue.

So you maybe want to check:

1. what your memory free pages situation of each zone by /proc/zoneinfo

2. try the vmalloc in kernel, this can be compare to malloc in user space, kmalloc is physical continue, it's was very few 1M continue phy memory after kernel boot.

0 项奖励
回复
1,621 次查看
SteveBakke
Contributor II

Sorry to say I had tried vmalloc(), exact same results.

zone normal had 172K free, zone DMA had 42K free,  Both changed by ~1K pages when program was run, which was what they should have.

0 项奖励
回复
1,621 次查看
SteveBakke
Contributor II

I did find if I use mlock on the malloc'ed memory then the malloc'ed memory is the exact same speed as the kmalloc'ed memory.  Must be a cache flag somewhere.  

0 项奖励
回复