From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?= Subject: Questions about TTM buffer object maping Date: Thu, 11 Jul 2013 02:27:05 +0200 Message-ID: <51DDFBD9.7000703@dumbbell.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail.made4.biz (ns25270.ovh.net [91.121.29.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B8F5E5DC7 for ; Wed, 10 Jul 2013 17:55:38 -0700 (PDT) Received: from 141.7.19.93.rev.sfr.net ([93.19.7.141] helo=[192.168.1.176]) by mail.made4.biz with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1Ux4iw-000IKE-1J for dri-devel@lists.freedesktop.org; Thu, 11 Jul 2013 02:27:06 +0200 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org 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? When a buffer object is moved, what happens to the mapping? 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)? Sorry if my questions are stupid, I'm rather new to memory management. -- = Jean-S=E9bastien P=E9dron