On Thu, Jul 11, 2013 at 2:24 AM, Daniel Vetter daniel@ffwll.ch wrote:
On Wed, Jul 10, 2013 at 09:00:33PM -0400, Jerome Glisse wrote:
On Wed, Jul 10, 2013 at 8:27 PM, Jean-Sébastien Pédron jean-sebastien.pedron@dumbbell.fr wrote:
Hello,
I'm trying to understand how TTM buffer object mapping works on Linux, to make this behave properly on FreeBSD.
Here's what I think I understand:
When a buffer object is mmap()'d, ttm_bo_vm_open() is called. When there's a page fault, the page is looked up and inserted in the VMA using vm_insert_mixed(). When a buffer object is munmap()'d, ttm_bo_vm_close() is called, which drops a reference. When the last reference is dropped, the buffer object is destroyed.
What's still not clear to me is how munmap() works here. After talking about this on IRC with some people, I think that unmap_mapping_range() (called by ttm_bo_unmap_virtual_locked()) is equivalent to calling munmap() from userland. Is that true?
Yes that's true.
Afaik unmap_mapping_range only kills the ptes and doesn't remove the vma. So not equivalent to a munmap from userspace. It simply allows us to intercept the next access in the page fault handler and move the buffer back into place. -Daniel
Yes, i was talking from a page point of view, ie page no longer have mapping and can be free.
Cheers, Jerome