Hello everyone, I am trying to understand the kernel page frame reclaiming mechanism, but one thing's bothering me: How does the kernel 'know' which anonymous pages to evict? In the LRU scheme, 'referenced/used' information for each page is required (AFAIK). But anonymous pages can be used by user processes 'at any time' without the kernel knowing about it. Am i missing something? Or does the kernel just drop some random anon pages of a process? Is there a way to obtain the 'referenced' information about anonymous pages as well? Thanks, Prateek
Hi :) On Wed, Sep 28, 2011 at 00:14, Prateek Sharma <prateek3.14@gmail.com> wrote:
Hello everyone, I am trying to understand the kernel page frame reclaiming mechanism, but one thing's bothering me: How does the kernel 'know' which anonymous pages to evict? In the LRU scheme, 'referenced/used' information for each page is required (AFAIK). But anonymous pages can be used by user processes 'at any time' without the kernel knowing about it.
Same question hog my mind too so far :) The only satisfying self answer I could deduce is: kernel can't track every access to pages when you do it like e.g mov %ax,8(%esp). What kernel could track is when you access data via wrappers. I forgot which ones, but remember some of them are updating those "referenced" etc flags. Perhaps something like get_pages or alike. -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
On Tue, Sep 27, 2011 at 11:42 PM, Mulyadi Santosa <mulyadi.santosa@gmail.com> wrote:
Hi :)
On Wed, Sep 28, 2011 at 00:14, Prateek Sharma <prateek3.14@gmail.com> wrote:
Hello everyone, I am trying to understand the kernel page frame reclaiming mechanism, but one thing's bothering me: How does the kernel 'know' which anonymous pages to evict? In the LRU scheme, 'referenced/used' information for each page is required (AFAIK). But anonymous pages can be used by user processes 'at any time' without the kernel knowing about it.
Same question hog my mind too so far :)
The only satisfying self answer I could deduce is: kernel can't track every access to pages when you do it like e.g mov %ax,8(%esp). What kernel could track is when you access data via wrappers. I forgot which ones, but remember some of them are updating those "referenced" etc flags. Perhaps something like get_pages or alike.
-- regards,
Mulyadi Santosa Freelance Linux trainer and consultant
page_referenced_anon is called for anonymous pages by page_referenced. And as far as i could figure out, that uses mmu_notifiers. [calls pmdp_clear_flush_young_notify] Whether every anonymous page access is trapped, or only a few of them, i have not yet figured out. Linux-mm seems to be full of magic!
On Tue, Sep 27, 2011 at 11:56 PM, Prateek Sharma <prateek3.14@gmail.com>wrote:
On Tue, Sep 27, 2011 at 11:42 PM, Mulyadi Santosa <mulyadi.santosa@gmail.com> wrote:
Hi :)
On Wed, Sep 28, 2011 at 00:14, Prateek Sharma <prateek3.14@gmail.com> wrote:
Hello everyone, I am trying to understand the kernel page frame reclaiming mechanism, but one thing's bothering me: How does the kernel 'know' which anonymous pages to evict? In the LRU scheme, 'referenced/used' information for each page is required (AFAIK). But anonymous pages can be used by user processes 'at any time' without the kernel knowing about it.
(AFAIK) Anonymous pages do not correspond to any file. It may be part of a program's data area or stack & is written to the swap area. When a process tries to access the anonymous pages it notifies the swapper to get back the swap area in mem. In case of a process which holds the swap token, swapping of anonymous pages is avoided.
Same question hog my mind too so far :)
The only satisfying self answer I could deduce is: kernel can't track every access to pages when you do it like e.g mov %ax,8(%esp). What kernel could track is when you access data via wrappers. I forgot which ones, but remember some of them are updating those "referenced" etc flags. Perhaps something like get_pages or alike.
-- regards,
Mulyadi Santosa Freelance Linux trainer and consultant
page_referenced_anon is called for anonymous pages by page_referenced. And as far as i could figure out, that uses mmu_notifiers. [calls pmdp_clear_flush_young_notify]
Whether every anonymous page access is trapped, or only a few of them, i have not yet figured out.
Linux-mm seems to be full of magic!
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
I am trying to understand the kernel page frame reclaiming mechanism, but one thing's bothering me: How does the kernel 'know' which anonymous pages to evict? In the LRU scheme, 'referenced/used' information for each page is required (AFAIK). But anonymous pages can be used by user processes 'at any time' without the kernel knowing about it.
a. Every anonymous page starts out referenced. b. The process address space is described by the mm_struct, which has different regions defined by vm_area_struct(vma). c. A region may represent the process heap for use with malloc(), a memory mapped file such as a shared library or a block of anonymous memory allocated with mmap(). d. Every physical page(atleast those directly mapped into kernel linear address space) have a struct page associated with it. e. Now struct page has a struct address_space *mapping in it. In mapping, if low bit clear, points to inode address_space else if page mapped as anonymous low bit is set. f. Lets say low bit is set, then this mapping points to a anon_vma struct. This anon_vma is linked list of all vma's that have reference to that page. If the kernel needs to unmap a anonymous page, it must follow this linked list and examine every VMA it finds. Once the page is unmapped from every page table found from each vma(vma-->mm_struct-->pgd), it can be freed. -syed
participants (4)
-
Mulyadi Santosa -
Prateek Sharma -
rohan puri -
sk.syed2