<div dir="ltr">Thank you so much !!</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 15, 2015 at 8:48 PM, Arun KS <span dir="ltr"><<a href="mailto:getarunks@gmail.com" target="_blank">getarunks@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><p dir="ltr"><br>
On Mar 15, 2015 8:27 PM, "Sunny Shah" <<a href="mailto:shahsunny715@gmail.com" target="_blank">shahsunny715@gmail.com</a>> wrote:<br>
><br>
> Hi Arun,<br>
><br>
> Thanks for that excellent explanation. It's more or less clear to me now.<br>
><br>
> However, quoting what you said:<br>
><br>
> Because we have plenty of kernel virtual<br>
> address(3GB) and can easily map 2GB of RAM in to it.<br>
><br>
> Why should we have to map the whole RAM into the KVA? Shouldn't it be only LOW_MEM?</p>
</span><p dir="ltr">We dont need to. I was just telling we can do that aswell. When you go with 2:2 split, you are changing user space virtual memory layout. Which will bring in lot if other problems. So very common approach is to use high mem.</p>
<p dir="ltr"><span class="">><br>
> I also read on a stack overflow thread that LOW_MEM is memory that is permanently mapped into KVA, while HIGH_MEM is mapped as required. Is this true?<br></span>
Absolutely</p>
<p dir="ltr">Thanks,<br>
Arun</p><div><div class="h5"><br>
><br>
> Thanks,<br>
> Sunny<br>
><br>
> On Sun, Mar 15, 2015 at 1:17 PM, Arun KS <<a href="mailto:getarunks@gmail.com" target="_blank">getarunks@gmail.com</a>> wrote:<br>
>><br>
>> Hello Sunny,<br>
>><br>
>> On Sat, Mar 14, 2015 at 8:25 PM, Sunny Shah <<a href="mailto:shahsunny715@gmail.com" target="_blank">shahsunny715@gmail.com</a>> wrote:<br>
>> > Thank you guys!<br>
>> ><br>
>> > I have two more questions from your replies:<br>
>> ><br>
>> > I thought I had understood HIGH_MEM and LOW_MEM, but it appears I was wrong.<br>
>> > Does the concept of high memory/low memory correspond to physical address<br>
>> > space or virtual address space? Also, does LOW_MEM always have to be 1 GiB<br>
>> > maximum?<br>
>><br>
>> Physical memory is divided into HIGH_MEM and LOW_MEM.<br>
>> Why do we need two memory? To understand this, we need to know who<br>
>> all are consumers of kernel virtual address(KVA) which is limited to<br>
>> 1GB(in case of 3:1 split).<br>
>> 1. low mem( physical ram which has linear mapping to KVA).<br>
>> 2. IO memory address(for eg a DMA controller registers, Memory<br>
>> controller register, etc). When MMU is enabled all the address<br>
>> generated by the cpu are virtual address. Hence io memory should have<br>
>> a valid virtual to physical memory mapping.<br>
>> 3. Vmalloc address space. A dynamic kernel memory allocation<br>
>> mechanism, which only guarantees continuity in virtual address space.<br>
>> 4. Persistent kernel map. (if kernel want to use HIGH memory, it maps<br>
>> high memory to this portion of virtual address).<br>
>> 5. vector table.<br>
>><br>
>> Let me give a rough calculation for a better understanding. Lets say a<br>
>> system with configuration as follows,<br>
>> 2GB of physical RAM, 40 MB of physical io address space, 240 MB of<br>
>> vmalloc address space, 32 MB for persistent kernel map<br>
>> The maximum RAM which can be mapped as low mem = 1GB - (40 MB + 240 MB<br>
>> + 32MB) = 712MB.<br>
>><br>
>> Rest of RAM 1336MB( 1GB - 712MB) will fall as HIGH_MEM.<br>
>><br>
>> Now how system uses HIGH memory. Major user of HIGH mem is user space<br>
>> code. Kernel directly maps high mem to user space virtual address.<br>
>> Hight mem is also used by kernel though PK mappings. Even vmalloc<br>
>> allocation can also fall from HIGH mem region.<br>
>><br>
>> Now if we decides to use 1:3 user space to kernel space split, high<br>
>> memory is not required. Because we have plenty of kernel virtual<br>
>> address(3GB) and can easily map 2GB of RAM in to it.<br>
>><br>
>> HTH.<br>
>><br>
>> Thanks,<br>
>> Arun<br>
>><br>
>> > For a RAM of 896 MiB - 4096 MiB, the book says:<br>
>> > "In this case, the RAM cannot be mapped entirely into the kernel linear<br>
>> > address space. The best Linux can do during the initialization phase is to<br>
>> > map a RAM window of size 896 MB into the kernel linear address space."<br>
>> ><br>
>> > Why is there a need to map the whole RAM into the kernel space (the usage of<br>
>> > the word "entirely") ? Shouldn't it be only LOW_MEM ? Or am I confusing the<br>
>> > two things here ?<br>
>> ><br>
>> ><br>
>> > I believe all doubts are pointing to the concepts of LOW_MEM and HIGH_MEM,<br>
>> > but I'm still not being able to wrap my head around them.<br>
>> ><br>
>> > Thanks,<br>
>> > Sunny<br>
>> ><br>
>> > On Thu, Mar 12, 2015 at 11:49 PM, Jeff Haran <<a href="mailto:Jeff.Haran@citrix.com" target="_blank">Jeff.Haran@citrix.com</a>> wrote:<br>
>> >><br>
>> >> -----Original Message-----<br>
>> >> From: <a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a><br>
>> >> [mailto:<a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a>] On Behalf Of Arun KS<br>
>> >> Sent: Thursday, March 12, 2015 11:03 AM<br>
>> >> To: Sunny Shah<br>
>> >> Cc: kernelnewbies<br>
>> >> Subject: Re: Understanding the mapping of physical memory to kernel<br>
>> >> address space<br>
>> >><br>
>> >> Hello Sunny,<br>
>> >><br>
>> >> On Thu, Mar 12, 2015 at 10:32 PM, Sunny Shah <<a href="mailto:shahsunny715@gmail.com" target="_blank">shahsunny715@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > Hello,<br>
>> >> ><br>
>> >> > This is my first mail on this list, so please let me know if I'm erring.<br>
>> >> ><br>
>> >> > I'm reading Bovet and Cesati's "Understanding the Linux Kernel",<br>
>> >> > specifically the chapter "Memory Addressing", sub-section "Kernel Page<br>
>> >> > Tables". Here they describe how Linux initializes its page tables for<br>
>> >> > various RAM sizes and how much of the physical address space is mapped<br>
>> >> > onto the kernel virtual address space.<br>
>> >> ><br>
>> >> > I have several questions from my reading:<br>
>> >> ><br>
>> >> > My understanding is that the 32 bit virtual address space of a process<br>
>> >> > is split into 2 parts - the first 3 GiB for the user space and the<br>
>> >> > remaining 1GiB for the kernel (with the same kernel mapping being used<br>
>> >> > for all processes. However, although the kernel is mapped into the<br>
>> >> > higher portion of the address space, it resides in the lower 1 GiB of<br>
>> >> > RAM. Is this correct?<br>
>> >> Yes. Incase of 3:1 mapping, kernel virtual address starts at 0xc0000000.<br>
>> >> You can also have 2:2 mappings aswell. It is a configurable option<br>
>> >><br>
>> >> Just an FYI, I've seen 1:3 mapping too. We had to do that with the kernels<br>
>> >> we built<br>
>> >> when I was at one company because we needed 3GB of virtual address space<br>
>> >> to map all<br>
>> >> of the memory mapped registers on their ASICs.<br>
>> >><br>
>> >> There's lots of options here.<br>
>> >><br>
>> >> Jeff Haran<br>
>> >><br>
>> >><br>
>> ><br>
><br>
><br>
</div></div><p></p>
</blockquote></div><br></div>