LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mapping Kernel virtual address space to Physical memory zones (ZONE_DMA, ZONE_NORMAL) (https://www.linuxquestions.org/questions/linux-newbie-8/mapping-kernel-virtual-address-space-to-physical-memory-zones-zone_dma-zone_normal-842251/)

kumart 11-04-2010 01:09 AM

Mapping Kernel virtual address space to Physical memory zones (ZONE_DMA, ZONE_NORMAL)
 
As i undertsand - out of 1GB of the virtual Address space for Kernel from 3GB to 4GB of the process address space,

Kernel image (code, data, bss, stack, heap) resides staring @0x0 address. Vmalloc area starts either at the end of Physical ram size or at 896M. This 896M cap is mandated to ensure that minimum of 128MB is reserved as vmalloc_reserve for vmalloc,kmap etc.

Is the understanding correct?

Now trying to map Physical Zones into this 1GB address space

Initial 16MB is mapped to ZONE_DMA
16MB - 896MB is mapped to ZONE_NORMAL
896MB - 1024MB is mapped to ZONE_HIGHMEM

Does this mean that Kernel image is residing in ZONE_DMA area?
Any call to vmalloc() in kernel code will return address beyond 896M?
insmod of any LKM will internally invoke vmalloc() to obtain contiguous area - where will this code physically located along with rest of kernel code in ZONE_DMA or in ZONE_HIGHMEM?

Thanks.

paulsm4 11-04-2010 01:38 AM

So what makes you feel a "virtual address" is any less real than a "physical address"? Or that a virtual address's physical addresses won't change as the system runs?

Remember - even though the OS *manages* physical::logical address mapping, it's essentially a *hardware* operation.

This is a good link:

http://lwn.net/images/pdf/LDD3/ch15.pdf

PS:
No: "the kernel" does NOT "reside" in ZONE_DMA. The kernel manages ZONE_DMA (as discussed in the above link).

No: vmalloc() returns a VIRTUAL address. It may or may not be mapped to a physical address. And, in fact, it's entirely possible that the region allocated may NEVER actually be mapped to an actual physical address!

No: a logically contiguous area (consisting of N pages) may or may not map to physically contiguous area. Except possibly in the case of DMA buffers. Again: refer to the above link.

You might also find this article useful:

2.6 Kernel memory allocation: Robert Love

'Hope that helps!

firo 04-03-2012 09:11 AM

I meet this confusions when I read linux book Professional Linux Kernel Architecture.
 
I use Ubuntu 12.04, kernel version is 3.2.

firo@snow:~/linux$ dmesg | grep -e ".init " -A 2
[ 0.000000] .init : 0xc1833000 - 0xc18e5000 ( 712 kB)
[ 0.000000] .data : 0xc157e844 - 0xc1832180 (2766 kB)
[ 0.000000] .text : 0xc1000000 - 0xc157e844 (5626 kB)
These output of my computer show that:
.text is start at 0xc1000000,the actual physical address is 0x01000000 (16Mb).

these link mybe useful:
http://forum.kernelnewbies.org/read.php?13,2193,2193
http://lists.gnu.org/archive/html/gr.../msg00251.html


All times are GMT -5. The time now is 09:22 PM.