Date: Mon, 06 Dec 2004 11:16:51 +0530 From: "Kamal R. Prasad" <kamalp@acm.org> To: John-Mark Gurney <gurney_j@resnet.uoregon.edu> Cc: freebsd-hackers@freebsd.org Subject: Re: mmap() Message-ID: <41B3F24B.1000903@acm.org> In-Reply-To: <20041206025126.GO19624@funkthat.com> References: <41B20B19.3090204@acm.org> <20041206025126.GO19624@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
John-Mark Gurney wrote: >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.. > > > Thanks. But then, the mmap'ed() address was yet to be used by the user space and I don't see the need for multiple calls to my interface almost as if in a while loop. Is there any return value from the mmap() interface that could trigger another call? I am returning 0 after setting the param to vtophys(kernel virtual address). regards -kamal
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41B3F24B.1000903>