On Wed, Jul 10, 2013 at 8:27 PM, Jean-Sébastien Pédron <jean-sebastien.pedron@xxxxxxxxxxx> 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. > When a buffer object is moved, what happens to the mapping? unmap_mapping_range is call from ttm_bo_move (indirectly through the helper function). > > In particular, I see in ttm_bo_move_accel_cleanup() that the ttm structure > can be transferred to ghost_obj, which is destroyed shortly after. This ends > up in ttm_put_pages() which uses __free_page(), for each page of the buffer > object. At this stage, is the ghost object already munmap()'d? Or does > __free_page() unmap a page implicitly (ie. remove it from VMA)? Yes object is unmapped prior to move. Cheers, Jerome > > Sorry if my questions are stupid, I'm rather new to memory management. > > -- > Jean-Sébastien Pédron > _______________________________________________ > dri-devel mailing list > dri-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel