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)

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.

Tuesday, June 9, 2009

using pcp list of another cpu from one cpu

there will be a main module bind with some specific cpu
the main module will have a workqueue on that cpu

inside the main module, create 2 kernel threads (kernel_threads)
then bind them to different cpus (kthread_bind)
each of them will register timers which will be running on specific cpu
and take out pages from that specific cpu pcp list
and put them on the common workqueue

they will have completion mechanism to flag their completion and do_exit()

during cleanup_module(), the main module will flag completion for both of the kernel threads.

but those pages will be tested on the testing function on a specific cpu

Saturday, June 6, 2009

Manual Extraction of Free pages from pcp or buddy list

Page count must be 0 when returning a page to the list of free pages (page->_count)

page->lru keeps the link inside pcp

count=1 just after extracting the page from any free list

pcp is locally locked by get_cpu()/put_cpu() and irq_save()/irq_restore().

buddy is globally locked by the corresponding zone's spinlocks. rmqueue* functions work on buddy allocator by using that lock. this spinlock does not make conflict with the pcp local locks.