How to understand lowmem_reserve in a zone?
Peter Teoh
htmldeveloper at gmail.com
Fri Aug 24 01:03:33 EDT 2012
On Sat, Aug 18, 2012 at 9:06 PM, Parmenides <mobile.parmenides at gmail.com>wrote:
> Hi,
>
> I have a question about the reseved page frames in a zone. The
> physical memory is splitted into some node, which is further divied
> into some zone. For each zone, the kernel try to reserve some page
> frames to statisfy requests on low memory condition. There is a
> lowmem_reserve[] in a zone descriptor, its defined like:
>
> struct zone {
> ....
> unsigned long lowmem_reserve[MAX_NR_ZONES];
> ...
> };
>
> It is obvious that lowmem_reserve[] contains MAX_NR_ZONES elements.
>
for mem, MAX_NR_ZONES is 4, which therefore mean 4 zone exists, and for
each zone there is a lowmem_reserve value, make sense?
The function: setup_per_zone_lowmem_reserve(void) will setup the value,
which is user-definable via a sysctl called "lowmem_reserve_ratio".
cat /proc/sys/vm/lowmem_reserve_ratio
256 256 32
and read the source code for explanation:
mm/page_alloc.c:
/*
* results with 256, 32 in the lowmem_reserve sysctl:
* 1G machine -> (16M dma, 800M-16M normal, 1G-800M high)
* 1G machine -> (16M dma, 784M normal, 224M high)
* NORMAL allocation will leave 784M/256 of ram reserved in the
ZONE_DMA
* HIGHMEM allocation will leave 224M/32 of ram reserved in ZONE_NORMAL
* HIGHMEM allocation will (224M+784M)/256 of ram reserved in ZONE_DMA
*
* TBD: should special case ZONE_DMA32 machines here - in those we normally
* don't need any ZONE_NORMAL reservation
*/
int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
> But, I think just a interger is enough to record the number of a
> zone's reserved page frames. Why do we have to use a
> array?
for each zone, and the zone name is defined in mm/page_alloc.c as well.
> Furthermore, lowmem_reserve[] merely stand for the amount. How
> does the kernel mark a page frame to be reserved?
>
> API is SetPageReserved(page), and queried with PageReserved(page) etc.
This API will use just one bit to store the reservation information for one
page.
_______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
--
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120824/61d63546/attachment.html
More information about the Kernelnewbies
mailing list