Memory management via mmap/mremap? How?

Memory management via mmap/mremap? How?

Post by Steven Bro » Thu, 30 Jan 1997 04:00:00



I'm trying to figure out how to handle memory allocation via the syscalls
mmap, mremap, and munmap.  I know how to do memory via paging, and this
looks like it will provide me with what I need if I use the MAP_FIXED
flag.  My problem is, how do I know where free 'addressing space' is so
that I can use MAP_FIXED without hitting something else?  I'm guessing
that there is a large free addressing space above where the program and
data are loaded, but how do I find where it starts, if it indeed exists?  
Thanks!

 
 
 

Memory management via mmap/mremap? How?

Post by Wolfram Gloge » Fri, 31 Jan 1997 04:00:00



> flag.  My problem is, how do I know where free 'addressing space' is so
> that I can use MAP_FIXED without hitting something else?  I'm guessing
> that there is a large free addressing space above where the program and
> data are loaded, but how do I find where it starts, if it indeed exists?  

There is no basic interface to this in the system libraries, but you
can always look at /proc/<pid>/maps to see how address space is
currently allocated.  Why do you need MAP_FIXED ?  mremap() was
designed in part to avoid the need for MAP_FIXED in memory management.

Regards,
Wolfram.

 
 
 

1. kernel documentation, memory management, kmalloc, mmap.

hi!

I'm looking for documentation about kernel programming. I'm used to the
BSD world, where there is lot of stuff about the kernel in section 9 of
the man pages, and I don't know where to find that kind of information
for Linux. Here are a few problem I have, and for which I'm looking some
documentation:

First problem: information about memory management: I did read that the
Linux kernel sees physical memory directly (ie: kernel virtual
addresses=physical addresses). Is it true? If not, how do I translate
between kernel virtual addresses and physical addresses?

Other problem: kmalloc and get_free_page feature a lot of options
(GFP_BUFFER, GFP_DMA, etc...). Where can I find info about them?

Last problem: I have a kernel resident buffer, with a kernel virtual
address kptr. Using an ioctl, I get this address in a user process. I
try to map the buffer in the user process virtual memory by issueing a
mmap on /dev/kmem at offset kptr:
  vptr = mmap(0, PAGESIZE, PROT_READ,
                   MAP_SHARED|MAP_FILE, fdkmem, (off_t)kptr);

The mmap is successful, but I don't get my buffer mapped (It's not the
data I did set up in kernel memory.) Why?

Thank you for any answer...

--
Emmanuel Dreyfus

2. How to run X11R6.3 / LBX ?

3. unix, linix memory management v/s windows95 memory management

4. Proper place to put shutdown activities?

5. shared memory via mmap()?

6. Telnet login fails after 60 sec

7. Memory Mapping of devices via mmap()

8. How do i make solaris 2.6 stop refusing me to connect to a certain socket

9. mmap, virtual memory, physical memory

10. Can I share, via shmat(), an mmap()'ed file?

11. xf86MapPciMem: Could not mmap PCI memory

12. Q: mmap() files in linux vs.data in memory

13. file mapping of memory (opposite of mmap())