1. Signal handling in a kernel thread
2.
Sunday, February 21, 2010
Thursday, February 18, 2010
Locks while extracting pages from Free List (PCP and Buddy)
access pcp cache
----------------
get_cpu()
local_irq_save()
zone lock (nex)
access buddy to replenish
zone unlock (nex)
local_irq_restore()
put_cpu()
access buddy
------------
get_cpu()
zone lock (ex)
zone unlock (ex)
put_cpu()
zone_lock_irqsave: local_irq_save + zone_lock
zone_unlock_irqrestore: zone_unlock + local_irq_restore
* when a page is given to pcp, the page private is set to migration type.
----------------
get_cpu()
local_irq_save()
zone lock (nex)
access buddy to replenish
zone unlock (nex)
local_irq_restore()
put_cpu()
access buddy
------------
get_cpu()
zone lock (ex)
zone unlock (ex)
put_cpu()
zone_lock_irqsave: local_irq_save + zone_lock
zone_unlock_irqrestore: zone_unlock + local_irq_restore
* when a page is given to pcp, the page private is set to migration type.
Tuesday, July 28, 2009
Page Reclaim IV (Swap Cache)
pages in a swap cache has the following things...
page->mapping = NULL ... why is that? afaik, it should point to the swap cache addr space object
PG_swapcache flag is on
page->private = swapped-out page id
a swap cache page linked to a page slot in swap area and some processe(s).
a swapper_space address space object is used for the swap cache for the whole system. question: how is a page found inside a swap cache? ans: using the swapped out page identifier
It is possible to know how many processes were sharing a swapped out page. Until everyone gets it in, the page is temporarily stored in the swap cache.
swap area has clustering of page slots (for efficiency during r/w: swap in-out)
page->mapping = NULL ... why is that? afaik, it should point to the swap cache addr space object
PG_swapcache flag is on
page->private = swapped-out page id
a swap cache page linked to a page slot in swap area and some processe(s).
a swapper_space address space object is used for the swap cache for the whole system. question: how is a page found inside a swap cache? ans: using the swapped out page identifier
It is possible to know how many processes were sharing a swapped out page. Until everyone gets it in, the page is temporarily stored in the swap cache.
swap area has clustering of page slots (for efficiency during r/w: swap in-out)
Page Structure Finds
PG_swapcache: the page is in the swap cache
PG_locked: undergoing IO, in swap space update, in file r/w etc.
PG_locked: undergoing IO, in swap space update, in file r/w etc.
Friday, July 24, 2009
Page Reclaim I (Basics) - Swapping Subsystem (swapfile.c, swap_state.c)
3 kinds of pages handled:
1. anon mem pages (usr stack/heap)
2. dirty pages of private mem map (does not change the files on disk)
3. IPC shared pages
note that the dirty pages are not swapped out, they are just updated in disk and removed from RAM. because this has the same effect as swapping out.
swap area can be on a physical disk partition or a separate file inside a large partition. but these data is stored only as long as the system is on and discarded otherwise. so swap area has a very little control info (unlike the filesystem info)
extents and priority -- interesting
swap_info array contains all the swap areas (disk partition,bdev or files). they are kept in swap area descriptors.
swapped out page id: page slot index[8:31], area number[1:7], 0[0]
the difference between a blank pte and swapped pte is that the id for blank pte = 0...0
1. anon mem pages (usr stack/heap)
2. dirty pages of private mem map (does not change the files on disk)
3. IPC shared pages
note that the dirty pages are not swapped out, they are just updated in disk and removed from RAM. because this has the same effect as swapping out.
swap area can be on a physical disk partition or a separate file inside a large partition. but these data is stored only as long as the system is on and discarded otherwise. so swap area has a very little control info (unlike the filesystem info)
extents and priority -- interesting
swap_info array contains all the swap areas (disk partition,bdev or files). they are kept in swap area descriptors.
swapped out page id: page slot index[8:31], area number[1:7], 0[0]
the difference between a blank pte and swapped pte is that the id for blank pte = 0...0
Friday, June 26, 2009
Page Tables
the page->ptl is a spinlock which is used when this page is being used as a pmd full of ptes. this pmd page can be in high memory or normal zone.
there are two reserved fixmap vaddrs (KM_PTE0,1) to map the pmd page if you want the pmd page be in high memory addr.
pte_offset_map_lock gets you the pmd page table (locked) and the lock itself.
if we want to change any pte inside this table, we must have the lock on it. after finishing work, unlock the key. (use pte_unmap_unlock)
there are two reserved fixmap vaddrs (KM_PTE0,1) to map the pmd page if you want the pmd page be in high memory addr.
pte_offset_map_lock gets you the pmd page table (locked) and the lock itself.
if we want to change any pte inside this table, we must have the lock on it. after finishing work, unlock the key. (use pte_unmap_unlock)
Sunday, June 21, 2009
Page Reclamation V (Periodic Reclaim) - kswapd and vmscan.c
this is a kernel thread, runs one instance globally. because we need atomic memory allocation. so we should maintain a fairly descent amount of free pages in the system. try_to_free_pages does its work when mem is scarce which is a time consuming (not atomic) job to do.
each memory node has a kswapd which sleeps on kswapd_wait queue of that node.
reclaiming is done on behalf of a process.
each memory node has a kswapd which sleeps on kswapd_wait queue of that node.
reclaiming is done on behalf of a process.
Subscribe to:
Posts (Atom)