Linux Internal/mm

mm: vmscan: shrink_zone

neodelicious 2017. 7. 22. 23:52

v4.4 기준


free memory 가 부족할 때를 memory pressure 가 있다고 표현한다.

memory pressure 가 있을 때 free memory 를 확보하기 위해서 memory 회수를 해야 한다.

memory 회수를 하는 kernel thread 가 kswapd 이다.


allocation context 에서 watermark LOW 이하의 free memory 상태에서 kswapd 를 wakeup 해 주고,

kswapd 가 background 에서 memory 를 회수하지만,

그 allocation context 도 mm internal 에서는 kswapd 와 동일한 회수 routine 을 통해 스스로 free memory 를 확보한 후 allocate 한다. 이 부분을 소위 direct reclaim 이라고 한다.


그 공통적인 mm internal 한 부분을 shrink_zone 라고 보면 되겠다.


kswapd 의 경우 아래 call path 로 shrink_zone 를 호출한다.

kswapd
balance_pgdat
kswapd_shrink_zone
shrink_zone


direct reclaim 의 경우 아래 call path 로 shrink_zones  를 호출한다.

__alloc_pages_nodemask
__alloc_pages_slowpath
__alloc_pages_direct_reclaim
__perform_reclaim
try_to_free_pages
shrink_zones
shrink_zone