From: Daniel Vetter Subject: Re: Questions about TTM buffer object maping Date: Thu, 11 Jul 2013 08:24:19 +0200 Message-ID: <20130711062419.GM6143@phenom.ffwll.local> References: <51DDFBD9.7000703@dumbbell.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-ee0-f50.google.com (mail-ee0-f50.google.com [74.125.83.50]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BEFEE5E07 for ; Wed, 10 Jul 2013 23:24:17 -0700 (PDT) Received: by mail-ee0-f50.google.com with SMTP id d49so5205818eek.37 for ; Wed, 10 Jul 2013 23:24:16 -0700 (PDT) Content-Disposition: inline In-Reply-To: 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: Jerome Glisse Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Wed, Jul 10, 2013 at 09:00:33PM -0400, Jerome Glisse wrote: > On Wed, Jul 10, 2013 at 8:27 PM, Jean-S=E9bastien P=E9dron > 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 ther= e'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() (calle= d 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 -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch