Re: vmalloc size

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

 



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)

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

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.

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.

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.

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).

-- 
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