Re: vmalloc size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dave,

Thank you for taking your time to provide this example. This is indeed very insightful.

On Mon, Jun 25, 2012 at 7:41 PM, Dave Hylands <dhylands@xxxxxxxxx> wrote:
Hi Subbu,

...snip,,,
>> __pa only works on kernel direct addresses.
>>
>> __pa doesn't work on the addresses from vmalloc
>>
>> Using __pa on VMALLOC_START or VMALLOC_END doesn't really make sense.
>> If there were any physical memory there, it would be highmem.
>>
> Okay, but my intention was to just print out the pa for the VMALLOC_START
> and END, just to know where they are.
> And I thought they will work. no?

You'll get some numbers, but they're meaningless.

Let's take a concrete example (using ARM mappings)

Suppose your machine has 1 GB of RAM with a physical addresses of
0x40000000 thru 0x7FFFFFFF

Let's suppose that PHYS_OFFSET = 0xC0000000
Let's suppose that VMALLOC_START is set to 0xE0000000 and VMALLOC_END
is at 0xEFFFFFFF (256 Mb)

Agreed! 
So what we have is that memory from 0xC0000000 thru 0xDFFFFFFF (512
Mb) is kernel direct mapped memory and maps to physical addresses
0x40000000 thru 0x5FFFFFFF

Agreed 
Physical memory from 0x60000000 thru 0x7FFFFFFF (512Mb) is considered
high-mem. For the most part this is only usable by user-space. From
kernel space, you need to use the kmap/kunmap functions to even access
the memory.

Agreed 
If you use __pa(VMALLOC_START) you'll ALWAYS (with the above example)
get 0xE0000000.
Calling __pa(VMALLOC_END) would return 0xEFFFFFFF which is some
address from the middle of high-memory, essentially a meaningless
number.

Agreed this one too!!!
 
However, if you call vmalloc and lets suppose that vmalloc just
happens to return 0xE0000000. The physical address of the first page
might be 0xD2345000.

What's important is that the physical pages which back up the vmalloc
area all come from the kernel direct mapped area. They won't ever be
backed by pages from high-memory. So the physical addresses will all
be in the range 0x40000000 thru 0x5FFFFFFF.

This is the one that I had a completely wrong understanding of!!!!!!!
I understand from the above statement that  the vmalloc'ed virtual address will _ALWAYS_  correspond to a  physical address from the lowmem region! I was under the impression that the carved out region for the vmalloc,
is the one that would back any vmalloc'ed virtual address, which is absolutely wrong by what you are saying.

Now this also means that increasing vmalloc inadvertently reduces lowmem. Why is this designed such a way?
Essentially, the idea that we increase vmalloc is because we expect more memory to be consumed via vmalloc
calls, and hence we might need more physical address backing. But increasing vmalloc decreases low mem, which would also mean that we have less backing. 
Am I missing something here too :)?


You can use vmalloc_to_pfn to return the PFN of the page which is
backing a vmalloc'd virtual address. (if the physical address of
0xE0000000 was 0xD2345000, then the pfn would be 0xD2345, assuming 4K
pages).
Agreed on this too!  Thanks again for your time and patience.

--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux