SYNOLOGY STUDY GROUP
Linux Kernel Development
- Robert Love/3e
Chapter 16 - cache
Reporter:
JeasonH /黃志勝
Outlines
● Cache Mode
● Cache Eviction
● Address space
● Radix tree
● Buffer cache
● Flusher thread
Cache Mode
 Write back
 Write through
 No Write
Cache Eviction
● Clairvoyant - adj.有超人之目力或洞察力的
n.千里眼)
● LRU - Least Recent Used
● LRU/2, LRU/n
address_space
(physical_pages_of_a_file)
Radix tree
Buffer cache
(ch14 block I/O device)
Linux 2.4:
● Buffer cache – 以block為操作單位
● Page cache – 以page為操作單位
一份資料可能同時cache在buffer與page 上
浪費記憶體空間,並且需要同步。
Flusher thread
● dirty_background_ratio
● dirty_expire_interval,
dirty_writeback_interval
● sync(), fsync()
Flusher thread
Laptop mode –
/proc/sys/vm/lap_top_mode = 0/1
當寫回發生時,順便將所有其他的dirty資料寫回Disk (搭
順風車)
配合lap_top_mode將值調大
dirty_expire_interval, dirty_writeback_interval
Flusher thread
Linux 2.6 before – bdflush (dirty_background_ratio)
kupdated (dirty_expire_interval)
(dirty_writeback_interval)
Linux 2.6 – pdfush : 2 to 8 threads
Linux 2.6.32 – flusher : one thread for one block device
THANKS YOUR ATTENTION!

Ch16