kmalloc memory slower than malloc

Russell King - ARM Linux linux at arm.linux.org.uk
Tue Sep 10 07:44:20 EDT 2013


On Tue, Sep 10, 2013 at 11:36:34AM +0000, Duan Fugang-B38611 wrote:
> From: Thommy Jakobsson [mailto:thommyj at gmail.com] 
> Data: Tuesday, September 10, 2013 7:29 PM
> 
> > To: Duan Fugang-B38611
> > Cc: Lucas Stach; Thommy Jakobsson; linux-arm-kernel at lists.infradead.org
> > Subject: RE: kmalloc memory slower than malloc
> > 
> > 
> > 
> > On Tue, 10 Sep 2013, Duan Fugang-B38611 wrote:
> > 
> > > About the diff:
> > > dma_alloc_coherent in kernel   4.256s (s=0)
> > > dma_alloc_coherent userspace   0.566s (s=0)
> > >
> > > I think it call remap_pfn_range() with page attribute (vma->vm_page_prot)
> > transferred from mmap() maybe cacheable.
> > > So the performance is the same as malloc/kmalloc in userspace.
> > >
> > Thats probably true, or at least that is how I explained it to myself in
> > my head =)
> > 
> > Thanks,
> > Thommy
> 
> Can you add below code to your device_mmap() to test the performance for above two cases:
> 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

No, that is not match the page table settings that dma_mmap_coherent
would use.  That gets you strongly ordered memory which will be
(a) a violation of the ARM architecture requirements, being a different
"memory type", and (b) will be a different mapping type compared to
that used by the virtual address returned from dma_alloc_coherent().

The appropriate modification here would be pgprot_dmacoherent().



More information about the linux-arm-kernel mailing list