출처 :
https://access.redhat.com/site/solutions/457083
What does vm.pagecache parameter mean in Red Hat Enterprise Linux 5 and what are the pros and cons of tweaking it?
Red Hat Enterprise Linux 5의 vm.pagecache 파라미터는 무엇을 의미하며 조정 시 장단점은 무엇인가?
문제
What does vm.pagecache parameter mean in Red Hat Enterprise Linux 5 and what are the pros and cons of tweaking it?
Red Hat Enterprise Linux 5의 vm.pagecache 파라미터는 무엇을 의미하며 조정 시 장단점은 무엇인가?
환경
Red Hat Enterprise Linux (RHEL) 5
해결
vm.pagecache controls the rate at which unmapped pages will be removed from the pagecache. It is a percentage of the total physical RAM. The default value is 100 and that disables it. If user sets it to a higher value, kernel will prefer to retain pagecache while lowering it will cause unmapped pages going into inactive list sooner.
역) vm.pagecache는 매핑되지 않은 page가 pagecache에서 제거되는 비율을 제어합니다. 그것은 전체 물리 RAM에서 차지하는 비율입니다. 기본값은 100이며 이 경우 해당 기능을 사용하지 않습니다. 사용자가 이 값을 높게 설정하면, 커널은 pagecache 유지를 선호하는 반면 낮게 설정하면 커널은 매핑되지 않은 page를 inactive list로 빨리 이동시킬 것입니다.
The technical rhetoric is here. We have this macro in include/linux/swap.h
Then, it goes to mm/swap.c
And in
Here the key is to understand that when the page is unmapped and vm.pagecache is greater than pagecache_maxpercent (default 100), we will move unmapped pages to inactive list and thereby facilitating quicker removal. However, if we reduce this value, then, we go to shrink_page_list() function in vmscan.c. There, we have
역) 핵심은 페이지가 unmap되고 vm.pagecache가 pagecache_maxpercent(default 100)보다 훨씬 클 때, 우리는 매핑되지 않은 페이지를 inactive list로 이동시키고 따라서 제거를 더 빠르게 촉진할 것임을 이해하는 것입니다. 그러나 우리가 이 값을 줄이면, vmscan.c의 shrink_page_list() 함수로 이동합니다. 거기에 우리는 갖고 있습니다.
Then we try to unmap the page and if it is dirty, it's written back to disk or if the page is clean, we can reclaim it directly. So, reducing vm.pagecache facilitates swapping i.e. reclaim of mapped pages and anonymous pages. As can be seen, swapping and pagecache limit are two opposite ends. We can't achieve both together. There is a tread-off and that is because of how things work. A file backed page can either be in cache or swap but not on both. So, the user has to decide which feature is desired.
역) 그 때 우리는 그 page를 unmap 시도하고 만약 그것이 dirty하다면 그것은 디스크에 write됩니다. page가 clean하다면 우리는 그것을 직접 reclaim할 수 있습니다. 그러므로 vm.pagecache를 줄이는 것은 swapping을 촉진, 즉 매핑된 page와 익명 page를 reclaim합니다. 알 수 있는 바와 같이, swapping과 pagecache limit는 상호 대조적입니다. 우리는 두 가지를 모두 달성할 수는 없습니다. tread-off가 있고 그것은 사물이 작동하는 방법 때문입니다. file backed page는 cache 또는 swap에 위치할 수 있으나 두 군데에 같이 있을 수는 없습니다. 따라서, 사용자는 어떤 기능이 바람직한지 결정해야 합니다.
https://access.redhat.com/site/solutions/457083
What does vm.pagecache parameter mean in Red Hat Enterprise Linux 5 and what are the pros and cons of tweaking it?
Red Hat Enterprise Linux 5의 vm.pagecache 파라미터는 무엇을 의미하며 조정 시 장단점은 무엇인가?
문제
What does vm.pagecache parameter mean in Red Hat Enterprise Linux 5 and what are the pros and cons of tweaking it?
Red Hat Enterprise Linux 5의 vm.pagecache 파라미터는 무엇을 의미하며 조정 시 장단점은 무엇인가?
환경
Red Hat Enterprise Linux (RHEL) 5
해결
vm.pagecache controls the rate at which unmapped pages will be removed from the pagecache. It is a percentage of the total physical RAM. The default value is 100 and that disables it. If user sets it to a higher value, kernel will prefer to retain pagecache while lowering it will cause unmapped pages going into inactive list sooner.
역) vm.pagecache는 매핑되지 않은 page가 pagecache에서 제거되는 비율을 제어합니다. 그것은 전체 물리 RAM에서 차지하는 비율입니다. 기본값은 100이며 이 경우 해당 기능을 사용하지 않습니다. 사용자가 이 값을 높게 설정하면, 커널은 pagecache 유지를 선호하는 반면 낮게 설정하면 커널은 매핑되지 않은 page를 inactive list로 빨리 이동시킬 것입니다.
The technical rhetoric is here. We have this macro in include/linux/swap.h
/* linux/mm/swap.c */ extern int pagecache_maxpercent; #define pagecache_over_max() \ (global_page_state(NR_FILE_PAGES) - total_swapcache_pages) > \ (totalram_pages * pagecache_maxpercent / 100)
Then, it goes to mm/swap.c
* * When the pagecache is over /proc/sys/vm/pagecache does the following: * - mark_page_accessed() keeps unmapped pages on the inactive_list. * - moves munmap()'d pages to the inactive_list. * - shrink_list() wont activate unmapped and referenced pages from * mapped object. */ int pagecache_maxpercent = 100; /* * Mark a page as having seen activity. * * inactive,unreferenced -> inactive,referenced * inactive,referenced -> active,unreferenced * active,unreferenced -> active,referenced * When pagecache_over_max() is true: * inactive,referenced,unmapped -> head of inactive,referenced */
And in
__pagevec_mark_accessed() function /* * Move unmapped pages to the head of the * inactive list. Move mapped pages to the * head of the active list. */ if (!page_mapped(page) && pagecache_over_max()) { list_move(&page->lru, &zone->inactive_list);
Here the key is to understand that when the page is unmapped and vm.pagecache is greater than pagecache_maxpercent (default 100), we will move unmapped pages to inactive list and thereby facilitating quicker removal. However, if we reduce this value, then, we go to shrink_page_list() function in vmscan.c. There, we have
역) 핵심은 페이지가 unmap되고 vm.pagecache가 pagecache_maxpercent(default 100)보다 훨씬 클 때, 우리는 매핑되지 않은 페이지를 inactive list로 이동시키고 따라서 제거를 더 빠르게 촉진할 것임을 이해하는 것입니다. 그러나 우리가 이 값을 줄이면, vmscan.c의 shrink_page_list() 함수로 이동합니다. 거기에 우리는 갖고 있습니다.
struct pagevec freed_pvec;
Then we try to unmap the page and if it is dirty, it's written back to disk or if the page is clean, we can reclaim it directly. So, reducing vm.pagecache facilitates swapping i.e. reclaim of mapped pages and anonymous pages. As can be seen, swapping and pagecache limit are two opposite ends. We can't achieve both together. There is a tread-off and that is because of how things work. A file backed page can either be in cache or swap but not on both. So, the user has to decide which feature is desired.
역) 그 때 우리는 그 page를 unmap 시도하고 만약 그것이 dirty하다면 그것은 디스크에 write됩니다. page가 clean하다면 우리는 그것을 직접 reclaim할 수 있습니다. 그러므로 vm.pagecache를 줄이는 것은 swapping을 촉진, 즉 매핑된 page와 익명 page를 reclaim합니다. 알 수 있는 바와 같이, swapping과 pagecache limit는 상호 대조적입니다. 우리는 두 가지를 모두 달성할 수는 없습니다. tread-off가 있고 그것은 사물이 작동하는 방법 때문입니다. file backed page는 cache 또는 swap에 위치할 수 있으나 두 군데에 같이 있을 수는 없습니다. 따라서, 사용자는 어떤 기능이 바람직한지 결정해야 합니다.