public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Speed of RAM reserved with memmap kernel command line option.
@ 2011-10-17  7:51 Charles Buysschaert
  2011-10-17 13:23 ` Matthias Schniedermeyer
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Buysschaert @ 2011-10-17  7:51 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

Hello all, 

We are writing a PCI-e "frame grabber-like" driver for linux 2.6 kernel.

For exchanging data with the board, we would like to be able to use a big piece of consecutive memory.  
-> we reserve 512 megs after the first Gig of RAM by setting "memmap=512M$1024M" in grub.conf.

In order to give access to that memory in user space, I use "remap_pfn_range" : 

int myboard_mmap(struct file *filep, struct vm_area_struct *vma) {
  unsigned int board;

  board = MINOR(filep->f_dentry->d_inode->i_rdev);
  vma->vm_flags |= VM_LOCKED;

  if(remap_pfn_range(vma, vma->vm_start, myboard_var[board].dmablkp>>PAGE_SHIFT, DMA_BUFFER_SIZE, vma->vm_page_prot)) {
    printk(KERN_ERR "myboard: myboard_mmap: failed to mmap\n");
    return -EAGAIN;
  }

  return 0;
}

(I have set myboard_var[board].dmablkp to the address I set in grub.conf: 0x40000000)

However when writing or reading that part of memory, speed is terrible. 
I compared the performances to the ones I can reach using a piece of memory got with malloc: 
For transfering 128 megs:
With malloc"ed" RAM : 23053us
With "mmap"ed RAM : 1913389us

I guess cache is not used. Does anyone know if there is a way to speed this up? How could we set that area to "cached"? 

We have seen this post:
http://www.linux-mips.org/archives/linux-mips/2006-02/msg00120.html

And we tried adding this to our driver: 

static inline pgprot_t pgprot_cached(pgprot_t _prot)

{
    unsigned long prot = pgprot_val(_prot);
    prot = (prot & ~_CACHE_MASK);
    return __pgprot(prot);
}

vma->vm_page_prot = pgprot_cached(vma->vm_page_prot);

But it did not help...

Thank you in advance! 

Best regards,

Charles



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-28  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17  7:51 Speed of RAM reserved with memmap kernel command line option Charles Buysschaert
2011-10-17 13:23 ` Matthias Schniedermeyer
2011-10-28  9:30   ` Charles Buysschaert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox