From owner-freebsd-current@FreeBSD.ORG Tue May 31 20:45:25 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95208106564A for ; Tue, 31 May 2011 20:45:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id EF3B48FC23 for ; Tue, 31 May 2011 20:45:24 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p4VKjJSB095072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 31 May 2011 23:45:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p4VKjI03095022; Tue, 31 May 2011 23:45:18 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p4VKjIVB095021; Tue, 31 May 2011 23:45:18 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 31 May 2011 23:45:18 +0300 From: Kostik Belousov To: Luigi Rizzo Message-ID: <20110531204518.GX48734@deviant.kiev.zoral.com.ua> References: <20110531202142.GA7105@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OkGsJQGtcVL5ZVbY" Content-Disposition: inline In-Reply-To: <20110531202142.GA7105@onelab2.iet.unipi.it> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: current@freebsd.org Subject: Re: "lazy" mmap for a device driver ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2011 20:45:25 -0000 --OkGsJQGtcVL5ZVbY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 31, 2011 at 10:21:42PM +0200, Luigi Rizzo wrote: > hi, > i have a kernel module implementing a memory mapped special device > which exports a large block of memory to the process. > I see that when the process calls mmap(), my routine foo_mmap() > is called immediately once per page, even though the process is > not actually touching the pages. I believe this happens > through dev_pager_alloc(). >=20 > Right now i can live with that because all the memory is allocated > at module load time, but i might want to have a sparse memory > region which is populated dynamically, so i was wondering if > there is a way to achieve this. I see there are two other > device routines, d_mmap2 and d_mmap_single, any pointer to > documentation or comments on how they differ ? During the porting of GEM to our kernel, I had to make a device pager interface more flexible. In particular, the updated pager allows the device to handle individual faults and return an explicit page to satisfy the fault, instead of the physical address. More, the driver can do any appropriate setup by ctr method. The new interface is supposed to be used with d_mmap_single(). http://people.freebsd.org/~kib/misc/device_pager.2.patch --OkGsJQGtcVL5ZVbY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk3lU14ACgkQC3+MBN1Mb4hTmQCeIGrYXrb4zPG3zCucFqYg4l8/ 5KgAmwbc0cbg0vMlQqJ2r4yybRIcX5Su =tk7A -----END PGP SIGNATURE----- --OkGsJQGtcVL5ZVbY--