Re: anonymous pages

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

 



Sorry, the answer was only partially correct.

On 2/24/08, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote:
> "An anonymous page is a page that is not associated with a particular
>  vnode, or file/directory." (this I extracted from
>  http://developers.sun.com/solaris/articles/multiproc/multiproc.html)
>  Ie, page->mapping is NULL - someone can confirm this?
>  

look at the implementation of PageAnon():

/*
* On an anonymous page mapped into a user virtual memory area,
* page->mapping points to its anon_vma, not to a struct address_space;
* with the PAGE_MAPPING_ANON bit set to distinguish it.
*
* Please note that, confusingly, "page_mapping" refers to the inode
* address_space which maps the page from disk; whereas "page_mapped"
* refers to user virtual address space into which the page is mapped.
*/
#define PAGE_MAPPING_ANON 1

static inline int PageAnon(struct page *page)
{
return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
}

>  And without this address space pointer, there is no swap device to
>  swap out, correct?   Other than that, what are all the other
>  implications of page->mapping being NULL?
>

Above is incorrect as well.

Quoting from:

http://lixiang.cn/?q=node/55

"File-backed pages can be flushed by writing them back to their file on disk. But anonymous mappings by definition don't have any backing file.
Where can they be flushed to? Swap space, of course. Swap partitions or files on Linux hold pages that aren't backed by a file."   So anonymous pages can be swapped out.   Correct?   So THAT MEANS non-anonymous page DOES NOT need swap page, since it is backed by file anyway, otherwise there will be double backed up?   Please comment on my comments.   But this also means that swap file is solely for the purpose of anonymous pages....does not sound right either????? I am confused.

Some usage of anonymous pages, for example:

while (!list_empty(&l_hold)) {
cond_resched();
page = lru_to_page(&l_hold);
list_del(&page->lru);
if (page_mapped(page)) {
if (!reclaim_mapped ||
(total_swap_pages == 0 && PageAnon(page)) ||
page_referenced(page, 0, sc->mem_cgroup)) {
list_add(&page->lru, &l_active);
continue;
}
}
list_add(&page->lru, &l_inactive);
}

From above I inferred that anonymous pages are always added to the active list (when total_swap_pages==0), why?   In other words, is it saying that if there are enough pages (total_swap_pages==0) for memory,
then please queue the page under the active list - except for anonymous pages?   (ie, inactive pages means that SOON it may be swapped out?)
  
Anonymous pages have vma derived from anon_vma.   For more info on anon_vma:

http://lwn.net/Articles/74295/

where it is mentioned it is motivated by reverse mapping - in rmap.c the anon_vma_cachep is allocated as kmem_cache_create():

THerefore doing a "cat /proc/slabinfo" u can see that it is part of the permanently allocated structure (truncated list below):

/proc>cat slabinfo
slabinfo - version: 2.1
# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
buffer_head 33899 35843 56 73 1 : tunables 0 0 0 : slabdata 491 491 0
mm_struct 554 567 448 9 1 : tunables 0 0 0 : slabdata 63 63 0
vm_area_struct 9292 9476 88 46 1 : tunables 0 0 0 : slabdata 206 206 0
files_cache 119 130 384 10 1 : tunables 0 0 0 : slabdata 13 13 0
sighand_cache 155 156 1344 6 2 : tunables 0 0 0 : slabdata 26 26 0
task_struct 234 236 1680 4 2 : tunables 0 0 0 : slabdata 59 59 0
anon_vma 4008 4096 16 256 1 : tunables 0 0 0 : slabdata 16 16 0
pid_namespace 1112 1122 40 102 1 : tunables 0 0 0 : slabdata 11 11 0
kmalloc-2048 317 320 2048 4 2 : tunables 0 0 0 : slabdata 80 80 0
And "cat /proc/meminfo" gave about 400M out of total of 1GB of physical mem.

>
>  On Sat, Feb 23, 2008 at 7:13 PM, shyam Burkule <shyam.burkule@xxxxxxxxx> wrote:
>  > what do we exactly mean by anonymous page ?
>  > Why special treatment is give for user process address space pages and
>  > anonymous pages , in case of reclamation?
>  >
>  > --
>  > Shyam
>  >   "Born To Learn"
>  



[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