From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 6 02:51:27 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 70C6916A4CE for ; Mon, 6 Dec 2004 02:51:27 +0000 (GMT) Received: from mail1.speakeasy.net (mail1.speakeasy.net [216.254.0.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3194843D5D for ; Mon, 6 Dec 2004 02:51:27 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 29839 invoked from network); 6 Dec 2004 02:51:27 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail1.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 6 Dec 2004 02:51:26 -0000 Received: from hydrogen.funkthat.com (kvenmb@localhost.funkthat.com [127.0.0.1])iB62pQGH096297; Sun, 5 Dec 2004 18:51:26 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id iB62pQa4096296; Sun, 5 Dec 2004 18:51:26 -0800 (PST) Date: Sun, 5 Dec 2004 18:51:26 -0800 From: John-Mark Gurney To: "Kamal R. Prasad" Message-ID: <20041206025126.GO19624@funkthat.com> Mail-Followup-To: "Kamal R. Prasad" , freebsd-hackers@freebsd.org References: <41B20B19.3090204@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41B20B19.3090204@acm.org> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: freebsd-hackers@freebsd.org Subject: Re: mmap() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2004 02:51:27 -0000 Kamal R. Prasad wrote this message on Sun, Dec 05, 2004 at 00:38 +0530: > I wrote an mmap() interface for a USB device. But when I made a call to > it using mmap(), I saw that mmap interface is called 3-4 times. The > calls are being made from within mmap() i.e. sys/vm/vm_mmap.c. Can > someone tell me if there is something like a re-try going on for some > reason? > From userspace, I called it as > addr = mmap(NULL, 1024, PROT_READ, MAP_SHARED, fd, 0); > The version of OS is Freebsd 5.3(stable). each mmap call will be called whenever the kernel needs to map that specific page.. say you map 16k of your device... it won't map any of the 16k until the first time it is accessed, then it will call the mmap routine for each page as it is accessed... it is also possible that memory for the mappings needs to be reclaimed, at which point those page mappings will be reaped, and your mmap function will be called again when they need to be accessed again.. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."