firstly i have to admit that i'm a newbie. so don't go hard on me plz. i want to reserve memory at boot time and then use this memory in a kernel module in order to be sure that this module is the only one using this space . i m going like this : add mem= , and memmap= to kerenl parameters to reserve memory @ boot time . my questions begin here :
- if i use ioremap over this space in my module code will it be accessible in other modules ? or other kernel subsystems cant still see it?
- second question : how can i be sure that this reserved memory will never move to swap space ?
- third one : how can i access this memory like block devices ? i mean like /dev/sda or ..... .
(1) By using
ioremap
, you're establishing a kernel virtual address for the memory. Any other code in kernel space can access it simply by sticking the right value into a pointer variable. AFAIK, there's no way of "locking" any area of memory to a single kernel module. All parts of the kernel are all-powerful and hence can access any memory they like -- or at least, they can do all the operations that might be required to allow them to access any memory they like. By the same token, there is no reason that another piece of kernel code is going to access the memory unless you cause that somehow. After all, you've told the rest of the kernel that it's not normal memory.(2) By excluding the memory from the kernel memory map, then using
ioremap
you're in effect telling the kernel that it's some kind of special "I/O" memory (think a PCI device's I/O memory region, for example), and hence wouldn't be considered for paging for that reason.I don't know of any way you can achieve your goal in (3) without implementing your own device interface for the memory. However, if that's what you want to use it for, why not simply create a ramdisk filesystem? No (additional) kernel programming required for that. (See
Documentation/blockdev/ramdisk.txt
in the kernel source tree.)