swsusp: shrink file cache first
Subsystems (3)
Johannes Weiner
maintainercover swsusp: shrink file cache first
[ grumble. always check software for new behaviour after upgrade.
sorry for the mess up :/ ]
Hello!
here are three patches that adjust the memory shrinking code used for suspend-to-disk.
The first two patches are cleanups only and can probably go in regardless of the third one.
The third patch changes the shrink_all_memory() logic to drop the file cache first before touching any mapped files and only then goes for anon pages.
The reason is that everything not shrunk before suspension has to go into the image and will be 'prefaulted' before the processes can resume and the system is usable again, so the image should be small and contain only pages that are likely to be used right after resume again. And this in turn means that the inactive file cache is the best point to start decimating used memory.
Also, right now, subsequent faults of contiguously mapped files are likely to perform better than swapin (see
http://kernelnewbies.org/KernelProjects/SwapoutClustering), so not only file cache is preferred over other pages, but file pages over anon pages in general.
Testing up to this point shows that the patch does what is intended, shrinking file cache in favor of anon pages. But whether the idea is correct to begin with is a bit hard to quantify and I am still working on it, so RFC only.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerPATCH 1/3 swsusp: clean up shrink_all_zones()
Move local variables to innermost possible scopes and use local variables to cache calculations/reads done more than once.
No change in functionality (intended).
--- mm/vmscan.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
mm/vmscan.c +11 -12
@@ -2057,31 +2057,31 @@ static unsigned long shrink_all_zones(un int pass, struct scan_control *sc) { struct zone *zone; -unsigned long nr_to_scan, ret =0 ; -enum lru_list l; +unsigned long ret =0 ;for_each_zone (zone) { +enum lru_list l;if (!populated_zone (zone))continue ; -if (zone_is_all_unreclaimable (zone) && prio !=DEF_PRIORITY )continue ;for_each_evictable_lru (l) { +enum zone_stat_item ls =NR_LRU_BASE + l; +unsigned long lru_pages =zone_page_state (zone, ls); +/* For pass = 0, we don't shrink the active list */ -if (pass ==0 && - (l ==LRU_ACTIVE || l ==LRU_ACTIVE_FILE )) +if (pass ==0 && (l ==LRU_ACTIVE_ANON || + l ==LRU_ACTIVE_FILE ))continue ; - zone->lru[l].nr_scan += - (zone_page_state (zone,NR_LRU_BASE + l) - >> prio) +1 ; + zone->lru[l].nr_scan += (lru_pages >> prio) +1 ;if (zone->lru[l].nr_scan >= nr_pages || pass >3 ) { +unsigned long nr_to_scan; + zone->lru[l].nr_scan =0 ; - nr_to_scan =min (nr_pages, -zone_page_state (zone, -NR_LRU_BASE + l)); + nr_to_scan =min (nr_pages, lru_pages); ret +=shrink_list (l, nr_to_scan, zone, sc, prio);if (ret >= nr_pages)
@@ -2089,7 +2089,6 @@ static unsigned long shrink_all_zones(un } } } -return ret; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/3] swsusp: clean up shrink_all_zones()
Quoted 9 lines
Move local variables to innermost possible scopes and use local variables to cache calculations/reads done more than once.
No change in functionality (intended).
Signed-off-by Johannes Weiner <[email protected]>--- mm/vmscan.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
ok. good cleanup.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerPATCH 2/3 swsusp: dont fiddle with swappiness
In reply to Johannes Weinersc.swappiness is not used in the swsusp memory shrinking path, do not set it.
--- mm/vmscan.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/vmscan.c +1 -4
@@ -2111,7 +2111,6 @@ unsigned long shrink_all_memory(unsigned .may_swap = 0, .swap_cluster_max = nr_pages, .may_writepage = 1, - .swappiness = vm_swappiness, .isolate_pages = isolate_pages_global, };
@@ -2145,10 +2144,8 @@ unsigned long shrink_all_memory(unsignedint prio;/* Force reclaiming mapped pages in the passes #3 and #4 */ -if (pass >2 ) { +if (pass >2 ) sc.may_swap =1 ; - sc.swappiness =100 ; - }for (prio =DEF_PRIORITY ; prio >=0 ; prio--) {unsigned long nr_to_scan = nr_pages - ret;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/3] swsusp: dont fiddle with swappiness
Quoted 7 lines
sc.swappiness is not used in the swsusp memory shrinking path, do not set it.
Signed-off-by Johannes Weiner <[email protected]>--- mm/vmscan.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
I agree. currently shrink_all_memory() use shrink_list() directly.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerRFC PATCH 3/3 swsusp: shrink file cache first
In reply to Johannes WeinerFile cache pages are saved to disk either through normal writeback by reclaim or by including them in the suspend image written to a swapfile.
Writing them either way should take the same amount of time but doing normal writeback and unmap changes the fault behaviour on resume from prefault to on-demand paging, smoothening out resume and giving previously cached pages the chance to stay out of memory completely if they are not used anymore.
Another reason for preferring file page eviction is that the locality principle is visible in fault patterns and swap might perform really bad with subsequent faulting of contiguously mapped pages.
Since anon and file pages now live on different lists, selectively scanning one type only is straight-forward.
This patch also removes the scanning of anon pages without allowing to swap, which does not make much sense.
The five memory shrinking passes now look like this:
Pass 0: shrink inactive file cache
This has the best chances of not being used any time soon again after resume, so trade inactive file cache against space for anon pages.
Pass 1: shrink file cache
Essentially the same as before but replenish the inactive file list with borderline active pages.
Pass 2: shrink all file pages and inactive anon
Reclaim mapped pages file pages and go for aged anon pages as well.
Pass 3: shrink all file pages and anon
Same as before but also shrink the active anon list to have enough anon pages for actual reclaim should we need pass 4.
Pass 4: repeat pass 3
--- mm/vmscan.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
mm/vmscan.c +22 -12
@@ -2069,13 +2069,23 @@ static unsigned long shrink_all_zones(unfor_each_evictable_lru (l) {enum zone_stat_item ls =NR_LRU_BASE + l; -unsigned long lru_pages =zone_page_state (zone, ls); +unsigned long lru_pages; -/* For pass = 0, we don't shrink the active list */ -if (pass ==0 && (l ==LRU_ACTIVE_ANON || - l ==LRU_ACTIVE_FILE )) -continue ; +switch (pass) { +case 0 : +if (l ==LRU_ACTIVE_FILE ) +continue ; +case 1 : +if (l ==LRU_INACTIVE_ANON ) +continue ; +case 2 : +if (l ==LRU_ACTIVE_ANON ) +continue ; +default : +break ; + } + lru_pages =zone_page_state (zone, ls); zone->lru[l].nr_scan += (lru_pages >> prio) +1 ;if (zone->lru[l].nr_scan >= nr_pages || pass >3 ) {unsigned long nr_to_scan;
@@ -2134,17 +2144,17 @@ unsigned long shrink_all_memory(unsigned/* * We try to shrink LRUs in 5 passes: -* 0 = Reclaim from inactive_list only -* 1 = Reclaim from active list but don't reclaim mapped -* 2 = 2nd pass of type 1 -* 3 = Reclaim mapped (normal reclaim) -* 4 = 2nd pass of type 3 +* 0 = Reclaim unmapped inactive file pages +* 1 = Reclaim unmapped file pages +* 2 = Reclaim file and inactive anon pages +* 3 = Reclaim file and anon pages +* 4 = Second pass 3 */ for (pass =0 ; pass <5 ; pass++) {int prio; -/* Force reclaiming mapped pages in the passes #3 and #4 */ -if (pass >2 ) +/* Reclaim mapped pages in higher passes */ +if (pass >1 ) sc.may_swap =1 ;for (prio =DEF_PRIORITY ; prio >=0 ; prio--) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi
I have some comment.
Quoted 10 lines
File cache pages are saved to disk either through normal writeback by reclaim or by including them in the suspend image written to a swapfile.
Writing them either way should take the same amount of time but doing normal writeback and unmap changes the fault behaviour on resume from prefault to on-demand paging, smoothening out resume and giving previously cached pages the chance to stay out of memory completely if they are not used anymore.
Quoted 6 lines
Another reason for preferring file page eviction is that the locality principle is visible in fault patterns and swap might perform really bad with subsequent faulting of contiguously mapped pages.
Since anon and file pages now live on different lists, selectively scanning one type only is straight-forward.
I don't understand your point.
Which do you want to improve suspend performance or resume performance?
if we think suspend performance, we should consider swap device and file-backed device are different block device.
the interleave of file-backed page out and swap out can improve total write out performce.
if we think resume performance, we shold how think the on-disk contenious of the swap consist process's virtual address contenious.
it cause to reduce unnecessary seek.
but your patch doesn't this.
Could you explain this patch benefit?
and, I think you should mesure performence result.
<snip>
mm/vmscan.c unsigned long shrink_all_memory(unsigned · line 2148
Quoted 11 lines
mm/vmscan.c +2
-5@@ -2134,17 +2144,17 @@ unsigned long shrink_all_memory(unsigned/* * We try to shrink LRUs in 5 passes: -* 0 = Reclaim from inactive_list only -* 1 = Reclaim from active list but don't reclaim mapped -* 2 = 2nd pass of type 1 -* 3 = Reclaim mapped (normal reclaim) -* 4 = 2nd pass of type 3 +* 0 = Reclaim unmapped inactive file pages +* 1 = Reclaim unmapped file pages
I think your patch reclaim mapped file at priority 0 and 1 too.
mm/vmscan.c unsigned long shrink_all_memory(unsigned · line 2158
Quoted 12 lines
mm/vmscan.c +5
-2+* 2 = Reclaim file and inactive anon pages +* 3 = Reclaim file and anon pages +* 4 = Second pass 3 */ for (pass =0 ; pass <5 ; pass++) {int prio; -/* Force reclaiming mapped pages in the passes #3 and #4 */ -if (pass >2 ) +/* Reclaim mapped pages in higher passes */ +if (pass >1 ) sc.may_swap =1 ;
Why need this line?
If you reclaim only file backed lru, may_swap isn't effective. So, Can't we just remove this line and always set may_swap=1 ?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 18 lines · KOSAKI Motohiro
Hi
I have some comment.
Quoted 14 lines
File cache pages are saved to disk either through normal writeback by reclaim or by including them in the suspend image written to a swapfile.
Writing them either way should take the same amount of time but doing normal writeback and unmap changes the fault behaviour on resume from prefault to on-demand paging, smoothening out resume and giving previously cached pages the chance to stay out of memory completely if they are not used anymore.
Another reason for preferring file page eviction is that the locality principle is visible in fault patterns and swap might perform really bad with subsequent faulting of contiguously mapped pages.
Quoted 5 lines
Quoted 2 lines
Since anon and file pages now live on different lists, selectively scanning one type only is straight-forward.
I don't understand your point.
Which do you want to improve suspend performance or resume performance?
If there is lots of clean file cache, memory shrinking time on suspend is fast. In a test here, a shrink that swaps a lot had 60mb/s throughput while a shrink on memory crowded with file cache had a throughput of 500mb/s.
If we have to shrink n pages, aggressively shrinking the cheap-to-evict ones is a speed improvement already.
The patch is also an improvement in suspend time becauses it doesn't scan the anon list while it's not allowed to swap. And what should it do with anon pages if not swap them out? :)
But that is more a nice side effect.
Quoted 3 lines
if we think suspend performance, we should consider swap device and file-backed device are different block device.
the interleave of file-backed page out and swap out can improve total write out performce.
Hm, good point. We could probably improve that but I don't think it's too pressing because at least on my test boxen, actual shrinking time is really short compared to the total of suspending to disk.
Quoted 6 lines
if we think resume performance, we shold how think the on-disk contenious of the swap consist process's virtual address contenious.
it cause to reduce unnecessary seek.
but your patch doesn't this.Could you explain this patch benefit?
The patch tries to shrink those pages first that are most unlikely to be needed again after resume. It assumes that active anon pages are immediately needed after resume while inactive file pages are not. So it defers shrinking anon pages after file cache.
But I just noticed that the old behaviour defers it as well, because even if it does scan anon pages from the beginning, it allows writing only starting from pass 3.
I couldn't quite understand what you wrote about on-disk contiguousness, but that claim still stands: faulting in contiguous pages from swap can be much slower than faulting file pages. And my patch prefers mapped file pages over anon pages. This is probably where I have seen the improvements after resume in my tests.
So assuming that we can not save the whole working set, it's better to preserve as much as possible of those pages that are the most expensive ones to refault.
Quoted 1 line
and, I think you should mesure performence result.
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Quoted 5 lines
<snip>
Quoted 2 lines
(quoted diff) +0
-0@@ -2134,17 +2144,17 @@ unsigned long shrink_all_memory(unsigned
Quoted 11 lines
mm/vmscan.c unsigned long shrink_all_memory(unsigned · line 2148
Quoted 9 lines
mm/vmscan.c +2
-5/* * We try to shrink LRUs in 5 passes: -* 0 = Reclaim from inactive_list only -* 1 = Reclaim from active list but don't reclaim mapped -* 2 = 2nd pass of type 1 -* 3 = Reclaim mapped (normal reclaim) -* 4 = 2nd pass of type 3 +* 0 = Reclaim unmapped inactive file pages +* 1 = Reclaim unmapped file pages I think your patch reclaim mapped file at priority 0 and 1 too.
Doesn't the following check in shrink_page_list prevent this:
if (!sc->may_swap && page_mapped(page))
goto keep_locked;?
Quoted 7 lines
Quoted 7 lines
mm/vmscan.c +3
-0+* 2 = Reclaim file and inactive anon pages +* 3 = Reclaim file and anon pages +* 4 = Second pass 3 */ for (pass =0 ; pass <5 ; pass++) {int prio;
Quoted 9 lines
mm/vmscan.c unsigned long shrink_all_memory(unsigned · line 2158
Quoted 5 lines
mm/vmscan.c +2
-2-/* Force reclaiming mapped pages in the passes #3 and #4 */ -if (pass >2 ) +/* Reclaim mapped pages in higher passes */ +if (pass >1 ) sc.may_swap =1 ;Why need this line?
If you reclaim only file backed lru,may_swapisn't effective. So, Can't we just remove this line and always set may_swap=1 ?
Same as the above, I think mapped pages are not touched when may_swap is 0 due to the check quoted above. Please correct me if I'm wrong.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi
Quoted 7 lines
Quoted 3 lines
if we think suspend performance, we should consider swap device and file-backed device are different block device.
the interleave of file-backed page out and swap out can improve total write out performce.Hm, good point. We could probably improve that but I don't think it's too pressing because at least on my test boxen, actual shrinking time is really short compared to the total of suspending to disk.
ok.
only remain problem is mesurement result posting :)
Quoted 11 lines
Quoted 6 lines
if we think resume performance, we shold how think the on-disk contenious of the swap consist process's virtual address contenious.
it cause to reduce unnecessary seek.
but your patch doesn't this.Could you explain this patch benefit?
The patch tries to shrink those pages first that are most unlikely to be needed again after resume. It assumes that active anon pages are immediately needed after resume while inactive file pages are not. So it defers shrinking anon pages after file cache.
hmm, I'm confusing.
I agree active anon is important than inactive file.
but I don't understand why scanning order at suspend change resume order.
Quoted 3 lines
But I just noticed that the old behaviour defers it as well, because even if it does scan anon pages from the beginning, it allows writing only starting from pass 3.
Ah, I see.
it's obiously wrong.
Quoted 5 lines
I couldn't quite understand what you wrote about on-disk contiguousness, but that claim still stands: faulting in contiguous pages from swap can be much slower than faulting file pages. And my patch prefers mapped file pages over anon pages. This is probably where I have seen the improvements after resume in my tests.
sorry, I don't understand yet.
Why "prefers mapped file pages over anon pages" makes large improvement?
Quoted 11 lines
So assuming that we can not save the whole working set, it's better to preserve as much as possible of those pages that are the most expensive ones to refault.
Quoted 1 line
and, I think you should mesure performence result.
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
thanks.
I'm looking for this :)
Quoted 14 lines
Quoted 13 lines
mm/vmscan.c unsigned long shrink_all_memory(unsigned · line 2148
Quoted 11 lines
mm/vmscan.c +2
-5@@ -2134,17 +2144,17 @@ unsigned long shrink_all_memory(unsigned/* * We try to shrink LRUs in 5 passes: -* 0 = Reclaim from inactive_list only -* 1 = Reclaim from active list but don't reclaim mapped -* 2 = 2nd pass of type 1 -* 3 = Reclaim mapped (normal reclaim) -* 4 = 2nd pass of type 3 +* 0 = Reclaim unmapped inactive file pages +* 1 = Reclaim unmapped file pages I think your patch reclaim mapped file at priority 0 and 1 too.
Quoted 6 lines
Doesn't the following check in
shrink_page_listprevent this:if (!sc->may_swap && page_mapped(page)) goto keep_locked;?
Grr, you are right.
I agree, currently may_swap doesn't control swap out or not. so I think we should change it correct name ;)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 21 lines · KOSAKI Motohiro
Hi
Quoted 7 lines
Quoted 3 lines
if we think suspend performance, we should consider swap device and file-backed device are different block device.
the interleave of file-backed page out and swap out can improve total write out performce.Hm, good point. We could probably improve that but I don't think it's too pressing because at least on my test boxen, actual shrinking time is really short compared to the total of suspending to disk.
ok.
only remain problem is mesurement result posting :)Quoted 7 lines
Quoted 6 lines
if we think resume performance, we shold how think the on-disk contenious of the swap consist process's virtual address contenious.
it cause to reduce unnecessary seek.
but your patch doesn't this.Could you explain this patch benefit?
Quoted 8 lines
Quoted 4 lines
The patch tries to shrink those pages first that are most unlikely to be needed again after resume. It assumes that active anon pages are immediately needed after resume while inactive file pages are not. So it defers shrinking anon pages after file cache.
hmm, I'm confusing.
I agree active anon is important than inactive file.
but I don't understand why scanning order at suspend change resume order.
This is the problem: on suspend, we can only save about 50% of memory through the suspend image because of the snapshotting. So we have to shrink memory before suspend. Since you probably always have more RAM used than 50%, you always have to shrink. And the image is always the same size.
After restoring the image, resuming processes want to continue their work immediately and the user wants to use the applications again as soon as possible.
Everything that is saved in the suspend image is restored and back in memory when the processes resume their work.
Everything that is NOT saved in the suspend image is still on swap or not yet in the page page when the processes resume their work.
So if we shrink the memory in the wrong order, after restoring the image we have page cache in memory that is not needed and those anon pages that are needed are swapped out.
And the goal is that after restoring the image we have as much of the working set back in memory and those pages in swap and on disk-only that are unlikely to be used immediately by the resumed processes, so they can continue their work without much disk io.
Quoted 7 lines
Quoted 3 lines
But I just noticed that the old behaviour defers it as well, because even if it does scan anon pages from the beginning, it allows writing only starting from pass 3.
Ah, I see.
it's obiously wrong.
Quoted 8 lines
Quoted 5 lines
I couldn't quite understand what you wrote about on-disk contiguousness, but that claim still stands: faulting in contiguous pages from swap can be much slower than faulting file pages. And my patch prefers mapped file pages over anon pages. This is probably where I have seen the improvements after resume in my tests.
sorry, I don't understand yet.
Why "prefers mapped file pages over anon pages" makes large improvement?
Because contigously mapped file pages are faster to read in than a group of anon pages. Or at least that is my claim.
And if we have to evict some of the working set just because the working set is bigger than 50% of memory, then it's better to evict those pages that are cheaper to refault.
Does that make sense?
Quoted 8 lines
Quoted 5 lines
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
thanks.
I'm looking for this :)
Thanks to YOU, also for for reviewing!
Quoted 16 lines
Quoted 16 lines
Quoted 13 lines
Review unsigned long shrink_all_memory(unsigned · line 2148
Quoted 11 lines
(quoted diff) +2
-5@@ -2134,17 +2144,17 @@ unsigned long shrink_all_memory(unsigned /* * We try to shrink LRUs in 5 passes: - * 0 = Reclaim from inactive_list only - * 1 = Reclaim from active list but don't reclaim mapped - * 2 = 2nd pass of type 1 - * 3 = Reclaim mapped (normal reclaim) - * 4 = 2nd pass of type 3 + * 0 = Reclaim unmapped inactive file pages + * 1 = Reclaim unmapped file pagesI think your patch reclaim mapped file at priority 0 and 1 too.
Doesn't the following check in
shrink_page_listprevent this:
Quoted 8 lines
Quoted 4 lines
if (!sc->may_swap && page_mapped(page)) goto keep_locked;?
Grr, you are right.
I agree, currentlymay_swapdoesn't control swap out or not. so I think we should change it correct name ;)
Agreed. What do you think about the following patch?
---
Subject: vmscan: rename may_swap scan control knob
may_swap applies not only to anon pages but to mapped file pages as well. Rename it to may_unmap which is the actual meaning.
---
mm/vmscan.c +10 -10
@@ -60,8 +60,8 @@ struct scan_control {int may_writepage; -/* Can pages be swapped as part of reclaim? */ -int may_swap; +/* Reclaim mapped pages */ +int may_unmap;/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX.
@@ -606,7 +606,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (unlikely (!page_evictable (page,NULL ))) goto cull_mlocked; -if (!sc->may_swap &&page_mapped (page)) +if (!sc->may_unmap &&page_mapped (page)) goto keep_locked;/* Double the slab pressure for mapped and swapcache pages */
@@ -1694,7 +1694,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .gfp_mask = gfp_mask, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, - .may_swap = 1, + .may_unmap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,
@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, {struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,
@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_swap =0 ; + sc.may_unmap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );
@@ -1762,7 +1762,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct reclaim_state *reclaim_state = current->reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,
@@ -2109,7 +2109,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct reclaim_state reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =0 , + .may_unmap =0 , .swap_cluster_max = nr_pages, .may_writepage =1 , .swappiness = vm_swappiness,
@@ -2147,7 +2147,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)/* Force reclaiming mapped pages in the passes #3 and #4 */ if (pass >2 ) { - sc.may_swap =1 ; + sc.may_unmap =1 ; sc.swappiness =100 ; }
@@ -2292,7 +2292,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)int priority;struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), - .may_swap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Thanks for kind explaining and good discussion, Hannes and Kosaki-san. Always, I learn lots of thing with such good discussion. :)
Quoted 44 lines · Johannes Weiner
Quoted 21 lines · KOSAKI Motohiro
Hi
Quoted 7 lines
Quoted 3 lines
if we think suspend performance, we should consider swap device and file-backed device are different block device.
the interleave of file-backed page out and swap out can improve total write out performce.Hm, good point. We could probably improve that but I don't think it's too pressing because at least on my test boxen, actual shrinking time is really short compared to the total of suspending to disk.
ok.
only remain problem is mesurement result posting :)Quoted 7 lines
Quoted 6 lines
if we think resume performance, we shold how think the on-disk contenious of the swap consist process's virtual address contenious.
it cause to reduce unnecessary seek.
but your patch doesn't this.Could you explain this patch benefit?
Quoted 8 lines
Quoted 4 lines
The patch tries to shrink those pages first that are most unlikely to be needed again after resume. It assumes that active anon pages are immediately needed after resume while inactive file pages are not. So it defers shrinking anon pages after file cache.
hmm, I'm confusing.
I agree active anon is important than inactive file.
but I don't understand why scanning order at suspend change resume order.This is the problem: on suspend, we can only save about 50% of memory through the suspend image because of the snapshotting. So we have to shrink memory before suspend. Since you probably always have more RAM used than 50%, you always have to shrink. And the image is always the same size.
After restoring the image, resuming processes want to continue their work immediately and the user wants to use the applications again as soon as possible.
Everything that is saved in the suspend image is restored and back in memory when the processes resume their work.
Quoted 6 lines
Everything that is NOT saved in the suspend image is still on swap or not yet in the page page when the processes resume their work.
So if we shrink the memory in the wrong order, after restoring the image we have page cache in memory that is not needed and those anon pages that are needed are swapped out.
It make sense.
Quoted 5 lines
And the goal is that after restoring the image we have as much of the working set back in memory and those pages in swap and on disk-only that are unlikely to be used immediately by the resumed processes, so they can continue their work without much disk io.
Your intention is good to me.
Quoted 13 lines
Quoted 13 lines
Quoted 3 lines
But I just noticed that the old behaviour defers it as well, because even if it does scan anon pages from the beginning, it allows writing only starting from pass 3.
Ah, I see.
it's obiously wrong.Quoted 5 lines
I couldn't quite understand what you wrote about on-disk contiguousness, but that claim still stands: faulting in contiguous pages from swap can be much slower than faulting file pages. And my patch prefers mapped file pages over anon pages. This is probably where I have seen the improvements after resume in my tests.
Quoted 5 lines
Quoted 2 lines
sorry, I don't understand yet.
Why "prefers mapped file pages over anon pages" makes large improvement?Because contigously mapped file pages are faster to read in than a group of anon pages. Or at least that is my claim.
It make sense if general resume process happens fault which have locality pattern
so, you should prove this.
Quoted 6 lines
And if we have to evict some of the working set just because the working set is bigger than 50% of memory, then it's better to evict those pages that are cheaper to refault.
Does that make sense?
Indeed!
Quoted 30 lines
Quoted 8 lines
Quoted 5 lines
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
thanks.
I'm looking for this :)Thanks to YOU, also for for reviewing!
Quoted 19 lines
Quoted 19 lines
Quoted 13 lines
Review unsigned long shrink_all_memory(unsigned · line 2148
Quoted 11 lines
(quoted diff) +2
-5@@ -2134,17 +2144,17 @@ unsigned long shrink_all_memory(unsigned /* * We try to shrink LRUs in 5 passes: - * 0 = Reclaim from inactive_list only - * 1 = Reclaim from active list but don't reclaim mapped - * 2 = 2nd pass of type 1 - * 3 = Reclaim mapped (normal reclaim) - * 4 = 2nd pass of type 3 + * 0 = Reclaim unmapped inactive file pages + * 1 = Reclaim unmapped file pagesI think your patch reclaim mapped file at priority 0 and 1 too.
Doesn't the following check in
shrink_page_listprevent this:if (!sc->may_swap && page_mapped(page)) goto keep_locked;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
?
Grr, you are right.
I agree, currentlymay_swapdoesn't control swap out or not. so I think we should change it correct name ;)Agreed. What do you think about the following patch?
As for me, I can't agree with you.
There are two kinds of file-mapped pages.
1. file-mapped and dirty page.
2. file-mapped and no-dirty page
Both pages are not swapped.
File-mapped and dirty page is synced with original file File-mapped and no-dirty page is just discarded with viewpoint of reclaim.
So, may_swap is just related to anon-pages
Thus, I think may_swap is reasonable.
How about you ?
Quoted 104 lines
---
Subject: vmscan: renamemay_swapscan control knob
may_swapapplies not only to anon pages but to mapped file pages as well. Rename it tomay_unmapwhich is the actual meaning.Signed-off-by Johannes Weiner <[email protected]>---
mm/vmscan.c +10
-11@@ -60,8 +60,8 @@ struct scan_control {int may_writepage; -/* Can pages be swapped as part of reclaim? */ -int may_swap; +/* Reclaim mapped pages */ +int may_unmap;/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. @@ -606,7 +606,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (unlikely (!page_evictable (page,NULL ))) goto cull_mlocked; -if (!sc->may_swap &&page_mapped (page)) +if (!sc->may_unmap &&page_mapped (page)) goto keep_locked;/* Double the slab pressure for mapped and swapcache pages */ @@ -1694,7 +1694,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .gfp_mask = gfp_mask, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, - .may_swap = 1, + .may_unmap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, {struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_swap =0 ; + sc.may_unmap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );@@ -1762,7 +1762,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct reclaim_state *reclaim_state = current->reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,@@ -2109,7 +2109,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct reclaim_state reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =0 , + .may_unmap =0 , .swap_cluster_max = nr_pages, .may_writepage =1 , .swappiness = vm_swappiness,@@ -2147,7 +2147,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)/* Force reclaiming mapped pages in the passes #3 and #4 */ if (pass >2 ) { - sc.may_swap =1 ; + sc.may_unmap =1 ; sc.swappiness =100 ; }@@ -2292,7 +2292,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)int priority;struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), - .may_swap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask, --To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kinds regards, MinChan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines
Grr, you are right.
I agree, currentlymay_swapdoesn't control swap out or not. so I think we should change it correct name ;)Agreed. What do you think about the following patch?
As for me, I can't agree with you.
There are two kinds of file-mapped pages.1. file-mapped and dirty page.
2. file-mapped and no-dirty page
Quoted 7 lines
Both pages are not swapped.
File-mapped and dirty page is synced with original file File-mapped and no-dirty page is just discarded with viewpoint of reclaim.So,
may_swapis just related to anon-pages
Thus, I thinkmay_swapis reasonable.
How about you ?
Sorry for misunderstood your point.
It would be better to remain more detaily for git log ?
'may_swap' applies not only to anon pages but to mapped file pages as well. 'may_swap' term is sometime used for 'swap', sometime used for 'sync|discard'.
In case of anon pages, 'may_swap' determines whether pages were swapout or not. but In case of mapped file pages, it determines whether pages are synced or discarded. so, 'may_swap' is rather awkward. Rename it to 'may_unmap' which is the actual meaning.
If you find wrong word and sentence, Please, fix it. :)
Quoted 112 lines
Quoted 100 lines
---
Subject: vmscan: renamemay_swapscan control knob
may_swapapplies not only to anon pages but to mapped file pages as well. Rename it tomay_unmapwhich is the actual meaning.Signed-off-by Johannes Weiner <[email protected]>---
mm/vmscan.c +10
-11@@ -60,8 +60,8 @@ struct scan_control {int may_writepage; -/* Can pages be swapped as part of reclaim? */ -int may_swap; +/* Reclaim mapped pages */ +int may_unmap;/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. @@ -606,7 +606,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (unlikely (!page_evictable (page,NULL ))) goto cull_mlocked; -if (!sc->may_swap &&page_mapped (page)) +if (!sc->may_unmap &&page_mapped (page)) goto keep_locked;/* Double the slab pressure for mapped and swapcache pages */ @@ -1694,7 +1694,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .gfp_mask = gfp_mask, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, - .may_swap = 1, + .may_unmap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, {struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_swap =0 ; + sc.may_unmap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );@@ -1762,7 +1762,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct reclaim_state *reclaim_state = current->reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,@@ -2109,7 +2109,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct reclaim_state reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =0 , + .may_unmap =0 , .swap_cluster_max = nr_pages, .may_writepage =1 , .swappiness = vm_swappiness,@@ -2147,7 +2147,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)/* Force reclaiming mapped pages in the passes #3 and #4 */ if (pass >2 ) { - sc.may_swap =1 ; + sc.may_unmap =1 ; sc.swappiness =100 ; }@@ -2292,7 +2292,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)int priority;struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), - .may_swap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask, --Quoted 5 lines
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>--
Kinds regards,
MinChan Kim
Signature · 8 lines
Kinds regards, MinChan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 31 lines · MinChan Kim
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines
Grr, you are right.
I agree, currentlymay_swapdoesn't control swap out or not. so I think we should change it correct name ;)Agreed. What do you think about the following patch?
As for me, I can't agree with you.
There are two kinds of file-mapped pages.1. file-mapped and dirty page.
2. file-mapped and no-dirty pageQuoted 7 lines
Both pages are not swapped.
File-mapped and dirty page is synced with original file File-mapped and no-dirty page is just discarded with viewpoint of reclaim.So,
may_swapis just related to anon-pages
Thus, I thinkmay_swapis reasonable.
How about you ?Sorry for misunderstood your point.
It would be better to remain more detaily for git log ?'
may_swap' applies not only to anon pages but to mapped file pages as well. 'may_swap' term is sometime used for 'swap', sometime used for 'sync|discard'.
In case of anon pages, 'may_swap' determines whether pages were swapout or not. but In case of mapped file pages, it determines whether pages are synced or discarded. so, 'may_swap' is rather awkward. Rename it to 'may_unmap' which is the actual meaning.
Quoted 1 line
If you find wrong word and sentence, Please, fix it. :)
Cool, thanks. I will resend an updated version soon with your changelog text. And on top of the two fixlets of this series which Andrew already picked up.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerPATCH 1/1 vmscan: rename sc.may_swap to may_unmap
In reply to MinChan Kimsc.may_swap does not only influence reclaiming of anon pages but pages mapped into pagetables in general, which also includes mapped file pages.
Quoted 1 line
From
shrink_page_list():
if (!sc->may_swap && page_mapped(page)) goto keep_locked;
For anon pages, this makes sense as they are always mapped and reclaiming them always requires swapping.
But mapped file pages are skipped here as well and it has nothing to do with swapping.
The real effect of the knob is whether mapped pages are unmapped and reclaimed or not. Rename it to `may_unmap' to have its name match its actual meaning more precisely.
--- mm/vmscan.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
Quoted 11 lines · MinChan Kim
Sorry for misunderstood your point.
It would be better to remain more detaily for git log ?'
may_swap' applies not only to anon pages but to mapped file pages as well. 'may_swap' term is sometime used for 'swap', sometime used for 'sync|discard'.
In case of anon pages, 'may_swap' determines whether pages were swapout or not. but In case of mapped file pages, it determines whether pages are synced or discarded. so, 'may_swap' is rather awkward. Rename it to 'may_unmap' which is the actual meaning.
Quoted 1 line
If you find wrong word and sentence, Please, fix it. :)
Is the above description okay for you?
Andrew, this is on top of the two earlier clean ups in vmscan.c:
+ swsusp-clean-up-shrink_all_zones.patch
+ swsusp-dont-fiddle-with-swappiness.patch
mm/vmscan.c +10 -10
@@ -60,8 +60,8 @@ struct scan_control {int may_writepage; -/* Can pages be swapped as part of reclaim? */ -int may_swap; +/* Can mapped pages be reclaimed? */ +int may_unmap;/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX.
@@ -606,7 +606,7 @@ static unsigned long shrink_page_list(stif (unlikely (!page_evictable (page,NULL ))) goto cull_mlocked; -if (!sc->may_swap &&page_mapped (page)) +if (!sc->may_unmap &&page_mapped (page)) goto keep_locked;/* Double the slab pressure for mapped and swapcache pages */
@@ -1694,7 +1694,7 @@ unsigned long try_to_free_pages(struct z .gfp_mask = gfp_mask, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, - .may_swap = 1, + .may_unmap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,
@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pag {struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,
@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pagstruct zonelist *zonelist;if (noswap) - sc.may_swap =0 ; + sc.may_unmap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );
@@ -1762,7 +1762,7 @@ static unsigned long balance_pgdat(pg_dastruct reclaim_state *reclaim_state = current->reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,
@@ -2108,7 +2108,7 @@ unsigned long shrink_all_memory(unsignedstruct reclaim_state reclaim_state;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .may_swap =0 , + .may_unmap =0 , .swap_cluster_max = nr_pages, .may_writepage =1 , .isolate_pages = isolate_pages_global,
@@ -2145,7 +2145,7 @@ unsigned long shrink_all_memory(unsigned/* Force reclaiming mapped pages in the passes #3 and #4 */ if (pass >2 ) - sc.may_swap =1 ; + sc.may_unmap =1 ;for (prio =DEF_PRIORITY ; prio >=0 ; prio--) {unsigned long nr_to_scan = nr_pages - ret;
@@ -2288,7 +2288,7 @@ static int __zone_reclaim(struct zone *zint priority;struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), - .may_swap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch] vmscan: rename sc.may_swap to may_unmap
Quoted 36 lines · Johannes Weiner
sc.may_swap does not only influence reclaiming of anon pages but pages mapped into pagetables in general, which also includes mapped file pages.
From
shrink_page_list():if (!sc->may_swap && page_mapped(page)) goto keep_locked;For anon pages, this makes sense as they are always mapped and reclaiming them always requires swapping.
But mapped file pages are skipped here as well and it has nothing to do with swapping.
The real effect of the knob is whether mapped pages are unmapped and reclaimed or not. Rename it to `may_unmap' to have its name match its actual meaning more precisely.
Signed-off-by Johannes Weiner <[email protected]>--- mm/vmscan.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)Quoted 11 lines · MinChan Kim
Sorry for misunderstood your point.
It would be better to remain more detaily for git log ?'
may_swap' applies not only to anon pages but to mapped file pages as well. 'may_swap' term is sometime used for 'swap', sometime used for 'sync|discard'.
In case of anon pages, 'may_swap' determines whether pages were swapout or not. but In case of mapped file pages, it determines whether pages are synced or discarded. so, 'may_swap' is rather awkward. Rename it to 'may_unmap' which is the actual meaning.
Quoted 4 lines
Quoted 1 line
If you find wrong word and sentence, Please, fix it. :)
Is the above description okay for you?
It looks good to me. :)
Signature · 8 lines
Kinds regards, MinChan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
KOSAKI Motohiro
Reviewed-byRe: [patch] vmscan: rename sc.may_swap to may_unmap
Quoted 20 lines · Johannes Weiner
Quoted 19 lines
sc.may_swap does not only influence reclaiming of anon pages but pages mapped into pagetables in general, which also includes mapped file pages.
From
shrink_page_list():if (!sc->may_swap && page_mapped(page)) goto keep_locked;For anon pages, this makes sense as they are always mapped and reclaiming them always requires swapping.
But mapped file pages are skipped here as well and it has nothing to do with swapping.
The real effect of the knob is whether mapped pages are unmapped and reclaimed or not. Rename it to `may_unmap' to have its name match its actual meaning more precisely.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Johannes Weiner <[email protected]>--- mm/vmscan.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)It looks good to me. :)
Reviewed-by MinChan Kim <[email protected]>
me too :)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
In reply to Johannes WeinerAdded
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>
I'm sorry for replying to a very old mail.
Quoted 10 lines
(quoted diff) +1
-1@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pag { struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap = 1, + .may_unmap = 1, .swap_cluster_max = SWAP_CLUSTER_MAX, .swappiness = swappiness, .order = 0,
Review unsigned long try_to_free_mem_cgroup_pag · line 1729
Quoted 8 lines
(quoted diff) +1
-1@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pag struct zonelist *zonelist; if (noswap) - sc.may_swap = 0; + sc.may_unmap = 0; sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
IIUC, memcg had used may_swap as a flag for "we need to use swap?" as the name indicate.
Because, when mem+swap hits the limit, trying to swapout pages is meaningless as it doesn't change mem+swap usage.
What do you think of this patch?
===
From: Daisuke Nishimura <[email protected]>
vmscan-rename-scmay_swap-to-may_unmap.patch removed may_swap flag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.
And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
re-introduce may_swap flag and handle it at shrink_page_list.
This patch doesn't influence any scan_control users other than memcg.
--- mm/vmscan.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-)
mm/vmscan.c +14 -1
@@ -64,6 +64,9 @@ struct scan_control {/* Can mapped pages be reclaimed? */ int may_unmap; +/* Can pages be swapped as part of reclaim? */ +int may_swap; +/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. * In this context, it doesn't matter that we scan the
@@ -616,6 +619,11 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (!sc->may_unmap &&page_mapped (page)) goto keep_locked; +if (!sc->may_swap &&PageSwapBacked (page) +/* SwapCache uses 'swap' already */ + && !PageSwapCache (page)) + goto keep_locked; +/* Double the slab pressure for mapped and swapcache pages */ if (page_mapped (page) ||PageSwapCache (page)) sc->nr_scanned++;
@@ -1696,6 +1704,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, .may_unmap = 1, + .may_swap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,
@@ -1715,6 +1724,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct scan_control sc = { .may_writepage = !laptop_mode, .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,
@@ -1724,7 +1734,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_unmap =0 ; + sc.may_swap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );
@@ -1764,6 +1774,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,
@@ -2110,6 +2121,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =0 , + .may_swap =1 , .may_writepage =1 , .isolate_pages = isolate_pages_global, };
@@ -2292,6 +2304,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_swap =1 , .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 22 lines · On Fri, 27 Mar 2009 15:19:26 +0900 Daisuke Nishimura…
Added
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>I'm sorry for replying to a very old mail.
Quoted 16 lines
mm/vmscan.c +2
-2@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pag {struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pagstruct zonelist *zonelist;if (noswap) - sc.may_swap =0 ; + sc.may_unmap =0 ;
Quoted 7 lines
mm/vmscan.c unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, · line 1740
Quoted 2 lines
mm/vmscan.c +0
-0sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );IIUC, memcg had used
may_swapas a flag for "we need to use swap?" as the name indicate.Because, when mem+swap hits the limit, trying to swapout pages is meaningless as it doesn't change mem+swap usage.
Good catch...sigh, I missed this disussion.
Quoted 11 lines
What do you think of this patch?
===
From: Daisuke Nishimura <[email protected]>vmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
When mem+swap hits the limit, swap-out anonymous page doesn't reduce the amount of usage of mem+swap, so, swap-out should be avoided.
Quoted 7 lines
re-introduce
may_swapflag and handle it atshrink_page_list.This patch doesn't influence any
scan_controlusers other than memcg.Signed-off-by Daisuke Nishimura <[email protected]>
Seems good,
But hum....Maybe this lru scan work in the same way as the case of !total_swap_pages. (means don't scan anon LRU.) revisit this later.
-Kame
Quoted 73 lines
--- mm/vmscan.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-)mm/vmscan.c +13
-1@@ -64,6 +64,9 @@ struct scan_control {/* Can mapped pages be reclaimed? */ int may_unmap; +/* Can pages be swapped as part of reclaim? */ +int may_swap; +/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. * In this context, it doesn't matter that we scan the @@ -616,6 +619,11 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (!sc->may_unmap &&page_mapped (page)) goto keep_locked; +if (!sc->may_swap &&PageSwapBacked (page) +/* SwapCache uses 'swap' already */ + && !PageSwapCache (page)) + goto keep_locked; +/* Double the slab pressure for mapped and swapcache pages */ if (page_mapped (page) ||PageSwapCache (page)) sc->nr_scanned++;@@ -1696,6 +1704,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, .may_unmap = 1, + .may_swap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,@@ -1715,6 +1724,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct scan_control sc = { .may_writepage = !laptop_mode, .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,@@ -1724,7 +1734,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_unmap =0 ; + sc.may_swap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );@@ -1764,6 +1774,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,@@ -2110,6 +2121,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =0 , + .may_swap =1 , .may_writepage =1 , .isolate_pages = isolate_pages_global, };
mm/vmscan.c static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) · line 2310
Quoted 7 lines
mm/vmscan.c +1
-0@@ -2292,6 +2304,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_swap =1 , .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 56 lines
Quoted 22 lines · On Fri, 27 Mar 2009 15:19:26 +0900 Daisuke Nishimura…
Added
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>I'm sorry for replying to a very old mail.
Quoted 16 lines
(quoted diff) +2
-2@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pag { struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap = 1, + .may_unmap = 1, .swap_cluster_max = SWAP_CLUSTER_MAX, .swappiness = swappiness, .order = 0,@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pag struct zonelist *zonelist; if (noswap) - sc.may_swap = 0; + sc.may_unmap = 0;Quoted 7 lines
Review unsigned long try_to_free_mem_cgroup_pag · line 1729
Quoted 2 lines
(quoted diff) +0
-0sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);IIUC, memcg had used
may_swapas a flag for "we need to use swap?" as the name indicate.Because, when mem+swap hits the limit, trying to swapout pages is meaningless as it doesn't change mem+swap usage.
Good catch...sigh, I missed this disussion.
Quoted 11 lines
What do you think of this patch?
===
From: Daisuke Nishimura <[email protected]>vmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
When mem+swap hits the limit, swap-out anonymous page doesn't reduce the amount of usage of mem+swap, so, swap-out should be avoided.
Quoted 4 lines
re-introduce
may_swapflag and handle it atshrink_page_list.This patch doesn't influence any
scan_controlusers other than memcg.
Quoted 8 lines
Quoted 1 line
Signed-off-by Daisuke Nishimura <[email protected]>Seems good,
Reviewed-by KAMEZAWA Hiroyuki <[email protected]>But hum....Maybe this lru scan work in the same way as the case of !total_swap_pages. (means don't scan anon LRU.) revisit this later.
Well, How about following patch?
So, I have to agree my judgement of may_unmap was wrong. You explain memcg can use may_swap instead may_unmap. and I think other may_unmap user (zone_reclaim and shrink_all_list) can convert may_unmap code to may_swap.
IOW, Nishimura-san, you explain we can remove the branch of the may_unmap from shrink_page_list().
it's really good job. thanks!
========
Subject: vmswan: reintroduce sc->may_swap
vmscan-rename-scmay_swap-to-may_unmap.patch removed may_swap flag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.
And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
re-introduce may_swap flag and handle it at get_scan_ratio(). This patch doesn't influence any scan_control users other than memcg.
--
mm/vmscan.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
mm/vmscan.c +10 -2
@@ -63,6 +63,9 @@ struct scan_control {/* Can mapped pages be reclaimed? */ int may_unmap; +/* Can pages be swapped as part of reclaim? */ +int may_swap; +/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. * In this context, it doesn't matter that we scan the
@@ -1379,7 +1382,7 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,struct zone_reclaim_stat *reclaim_stat =get_reclaim_stat (zone, sc);/* If we have no swap space, do not bother scanning anon pages. */ -if (nr_swap_pages <=0 ) { +if (!sc->may_swap || (nr_swap_pages <=0 )) { percent[0 ] =0 ; percent[1 ] =100 ;return ;
@@ -1695,6 +1698,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, .may_unmap = 1, + .may_swap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,
@@ -1714,6 +1718,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct scan_control sc = { .may_writepage = !laptop_mode, .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,
@@ -1723,7 +1728,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_unmap =0 ; + sc.may_swap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );
@@ -1763,6 +1768,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,
@@ -2109,6 +2115,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =0 , + .may_swap =1 , .swap_cluster_max = nr_pages, .may_writepage =1 , .isolate_pages = isolate_pages_global,
@@ -2289,6 +2296,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_swap =1 , .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 58 lines · KOSAKI Motohiro
Quoted 58 lines
Quoted 22 lines · On Fri, 27 Mar 2009 15:19:26 +0900 Daisuke Nishimura…
Added
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>I'm sorry for replying to a very old mail.
Quoted 16 lines
mm/vmscan.c +2
-2@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pag {struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap =1 , + .may_unmap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pagstruct zonelist *zonelist;if (noswap) - sc.may_swap =0 ; + sc.may_unmap =0 ;Quoted 7 lines
mm/vmscan.c unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, · line 1734
Quoted 2 lines
mm/vmscan.c +0
-0sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );IIUC, memcg had used
may_swapas a flag for "we need to use swap?" as the name indicate.Because, when mem+swap hits the limit, trying to swapout pages is meaningless as it doesn't change mem+swap usage.
Good catch...sigh, I missed this disussion.
Quoted 11 lines
What do you think of this patch?
===
From: Daisuke Nishimura <[email protected]>vmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
When mem+swap hits the limit, swap-out anonymous page doesn't reduce the amount of usage of mem+swap, so, swap-out should be avoided.
Quoted 7 lines
re-introduce
may_swapflag and handle it atshrink_page_list.This patch doesn't influence any
scan_controlusers other than memcg.Signed-off-by Daisuke Nishimura <[email protected]>
Quoted 9 lines
Quoted 6 lines
Seems good,
Reviewed-by KAMEZAWA Hiroyuki <[email protected]>But hum....Maybe this lru scan work in the same way as the case of !total_swap_pages. (means don't scan anon LRU.) revisit this later.
Well, How about following patch?
I think your patch looks better because vain scanning of anon list is avoided.
Thanks,
Daisuke Nishimura.
Quoted 98 lines
So, I have to agree my judgement of
may_unmapwas wrong. You explain memcg can usemay_swapinsteadmay_unmap. and I think othermay_unmapuser (zone_reclaimandshrink_all_list) can convertmay_unmapcode tomay_swap.IOW, Nishimura-san, you explain we can remove the branch of the
may_unmapfromshrink_page_list().
it's really good job. thanks!========
Subject: vmswan: reintroducesc->may_swapvmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
re-introduce
may_swapflag and handle it atget_scan_ratio(). This patch doesn't influence anyscan_controlusers other than memcg.Signed-off-by KOSAKI Motohiro <[email protected]>Signed-off-by Daisuke Nishimura <[email protected]>--
mm/vmscan.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)mm/vmscan.c +9
-2@@ -63,6 +63,9 @@ struct scan_control {/* Can mapped pages be reclaimed? */ int may_unmap; +/* Can pages be swapped as part of reclaim? */ +int may_swap; +/* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. * In this context, it doesn't matter that we scan the @@ -1379,7 +1382,7 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,struct zone_reclaim_stat *reclaim_stat =get_reclaim_stat (zone, sc);/* If we have no swap space, do not bother scanning anon pages. */ -if (nr_swap_pages <=0 ) { +if (!sc->may_swap || (nr_swap_pages <=0 )) { percent[0 ] =0 ; percent[1 ] =100 ;return ;@@ -1695,6 +1698,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, .may_unmap = 1, + .may_swap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,@@ -1714,6 +1718,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct scan_control sc = { .may_writepage = !laptop_mode, .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = swappiness, .order =0 ,@@ -1723,7 +1728,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,struct zonelist *zonelist;if (noswap) - sc.may_unmap =0 ; + sc.may_swap =0 ; sc.gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK );@@ -1763,6 +1768,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =1 , + .may_swap =1 , .swap_cluster_max =SWAP_CLUSTER_MAX , .swappiness = vm_swappiness, .order = order,@@ -2109,6 +2115,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)struct scan_control sc = { .gfp_mask =GFP_KERNEL , .may_unmap =0 , + .may_swap =1 , .swap_cluster_max = nr_pages, .may_writepage =1 , .isolate_pages = isolate_pages_global,
mm/vmscan.c static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) · line 2302
Quoted 7 lines
mm/vmscan.c +1
-0@@ -2289,6 +2296,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode &RECLAIM_WRITE ), .may_unmap = !!(zone_reclaim_mode &RECLAIM_SWAP ), + .may_swap =1 , .swap_cluster_max = max_t(unsigned long, nr_pages,SWAP_CLUSTER_MAX ), .gfp_mask = gfp_mask,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
In reply to KOSAKI MotohiroHi,
Quoted 101 lines · KOSAKI Motohiro
Quoted 56 lines
Quoted 22 lines · On Fri, 27 Mar 2009 15:19:26 +0900 Daisuke Nishimura…
Added
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>I'm sorry for replying to a very old mail.
Quoted 16 lines
mm/vmscan.c +2
-2@@ -1713,7 +1713,7 @@ unsigned long try_to_free_mem_cgroup_pag { struct scan_control sc = { .may_writepage = !laptop_mode, - .may_swap = 1, + .may_unmap = 1, .swap_cluster_max = SWAP_CLUSTER_MAX, .swappiness = swappiness, .order = 0,@@ -1723,7 +1723,7 @@ unsigned long try_to_free_mem_cgroup_pag struct zonelist *zonelist; if (noswap) - sc.may_swap = 0; + sc.may_unmap = 0;Quoted 7 lines
Quoted 2 lines
sc.gfp_mask = (
gfp_mask&GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE& ~GFP_RECLAIM_MASK);IIUC, memcg had used
may_swapas a flag for "we need to use swap?" as the name indicate.Because, when mem+swap hits the limit, trying to swapout pages is meaningless as it doesn't change mem+swap usage.
Good catch...sigh, I missed this disussion.
Quoted 11 lines
What do you think of this patch?
===
From: Daisuke Nishimura <[email protected]>vmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
When mem+swap hits the limit, swap-out anonymous page doesn't reduce the amount of usage of mem+swap, so, swap-out should be avoided.
Quoted 4 lines
re-introduce
may_swapflag and handle it atshrink_page_list.This patch doesn't influence any
scan_controlusers other than memcg.Quoted 8 lines
Quoted 1 line
Signed-off-by Daisuke Nishimura <[email protected]>Seems good,
Reviewed-by KAMEZAWA Hiroyuki <[email protected]>But hum....Maybe this lru scan work in the same way as the case of !total_swap_pages. (means don't scan anon LRU.) revisit this later.
Well, How about following patch?
So, I have to agree my judgement of
may_unmapwas wrong. You explain memcg can usemay_swapinsteadmay_unmap. and I think othermay_unmapuser (zone_reclaimandshrink_all_list) can convertmay_unmapcode tomay_swap.IOW, Nishimura-san, you explain we can remove the branch of the
may_unmapfromshrink_page_list().
it's really good job. thanks!========
Subject: vmswan: reintroducesc->may_swapvmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
re-introduce
may_swapflag and handle it atget_scan_ratio(). This patch doesn't influence anyscan_controlusers other than memcg.Signed-off-by KOSAKI Motohiro <[email protected]>Signed-off-by Daisuke Nishimura <[email protected]>--
mm/vmscan.c | 12 ++++++++++--1 files changed, 10 insertions(+), 2 deletions(-)mm/vmscan.c +0
-0
mm/vmscan.c struct scan_control { · line 68
Quoted 6 lines
mm/vmscan.c +3
-0@@ -63,6 +63,9 @@ struct scan_control { /* Can mapped pages be reclaimed? */ int may_unmap; + /* Can pages be swapped as part of reclaim? */ + int may_swap; +
Sorry for too late response.
I don't know memcg well.
The memcg managed to use may_swap well with global page reclaim until now. I think that was because may_swap can represent both meaning. Do we need each variables really ?
How about using union variable ?
---
struct scan_control {
/* Incremented by the number of inactive pages that were scanned */ unsigned long nr_scanned;
...
union {
int may_swap; /* memcg: Cap pages be swapped as part of reclaim? */ int may_unmap /* global: Can mapped pages be reclaimed? */
};
Quoted 66 lines
mm/vmscan.c +4
-2/* This context's SWAP_CLUSTER_MAX. If freeing memory for* suspend, we effectively ignore SWAP_CLUSTER_MAX. * In this context, it doesn't matter that we scan the @@ -1379,7 +1382,7 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc, struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc); /* If we have no swap space, do not bother scanning anon pages. */ - if (nr_swap_pages <= 0) { + if (!sc->may_swap || (nr_swap_pages <= 0)) { percent[0] = 0; percent[1] = 100; return;@@ -1695,6 +1698,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .may_writepage = !laptop_mode, .swap_cluster_max = SWAP_CLUSTER_MAX, .may_unmap = 1, + .may_swap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL,@@ -1714,6 +1718,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, struct scan_control sc = { .may_writepage = !laptop_mode, .may_unmap = 1, + .may_swap = 1, .swap_cluster_max = SWAP_CLUSTER_MAX, .swappiness = swappiness, .order = 0,@@ -1723,7 +1728,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, struct zonelist *zonelist; if (noswap) - sc.may_unmap = 0; + sc.may_swap = 0;sc.gfp_mask = (
gfp_mask&GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE& ~GFP_RECLAIM_MASK);mm/vmscan.c +3
-0@@ -1763,6 +1768,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order) struct scan_control sc = { .gfp_mask = GFP_KERNEL, .may_unmap = 1, + .may_swap = 1, .swap_cluster_max = SWAP_CLUSTER_MAX, .swappiness = vm_swappiness, .order = order,@@ -2109,6 +2115,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages) struct scan_control sc = { .gfp_mask = GFP_KERNEL, .may_unmap = 0, + .may_swap = 1, .swap_cluster_max = nr_pages, .may_writepage = 1, .isolate_pages = isolate_pages_global,@@ -2289,6 +2296,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) struct scan_control sc = { .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE), .may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP), + .may_swap = 1, .swap_cluster_max = max_t(unsigned long, nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = gfp_mask,
Signature · 8 lines
Kinds regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 15 lines · On Tue, 31 Mar 2009 10:26:17 +0900 Minchan Kim <[email protected]> wrote:
Quoted 11 lines
mm/vmscan.c +0
-0@@ -63,6 +63,9 @@ struct scan_control {A A A A /* Can mapped pages be reclaimed? */ A A A A int may_unmap;+ A A A /* Can pages be swapped as part of reclaim? */ + A A A int may_swap;+
Sorry for too late response.
I don't know memcg well.
Quoted 5 lines
The memcg managed to use
may_swapwell with global page reclaim until now. I think that was becausemay_swapcan represent both meaning. Do we need each variables really ?How about using union variable ?
or Just removing one of them ?
Thanks,
-Kame
Quoted 71 lines
---
struct
scan_control{
/* Incremented by the number of inactive pages that were scanned */ unsigned longnr_scanned;
...
union {
intmay_swap; /* memcg: Cap pages be swapped as part of reclaim? */ intmay_unmap/* global: Can mapped pages be reclaimed? */
};Quoted 58 lines
A A A A /* This context's SWAP_CLUSTER_MAX. If freeing memory for A A A A * suspend, we effectively ignore SWAP_CLUSTER_MAX. A A A A * In this context, it doesn't matter that we scan themm/vmscan.c +0
-0@@ -1379,7 +1382,7 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc, A A A A struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);A A A A /* If we have no swap space, do not bother scanning anon pages. */
- A A A if (nr_swap_pages <= 0) { + A A A if (!sc->may_swap || (nr_swap_pages <= 0)) { A A A A A A A A percent[0] = 0; A A A A A A A A percent[1] = 100; A A A A A A A A return;mm/vmscan.c +3
-1@@ -1695,6 +1698,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, A A A A A A A A .may_writepage = !laptop_mode, A A A A A A A A .swap_cluster_max = SWAP_CLUSTER_MAX, A A A A A A A A .may_unmap = 1, + A A A A A A A .may_swap = 1, A A A A A A A A .swappiness = vm_swappiness, A A A A A A A A .order = order, A A A A A A A A .mem_cgroup = NULL,@@ -1714,6 +1718,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, A A A A struct scan_control sc = { A A A A A A A A .may_writepage = !laptop_mode, A A A A A A A A .may_unmap = 1, + A A A A A A A .may_swap = 1, A A A A A A A A .swap_cluster_max = SWAP_CLUSTER_MAX, A A A A A A A A .swappiness = swappiness, A A A A A A A A .order = 0,@@ -1723,7 +1728,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, A A A A struct zonelist *zonelist; A A A A if (noswap) - A A A A A A A sc.may_unmap = 0; + A A A A A A A sc.may_swap = 0;A A A A sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | A A A A A A A A A A A A (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);mm/vmscan.c +3
-0@@ -1763,6 +1768,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order) A A A A struct scan_control sc = { A A A A A A A A .gfp_mask = GFP_KERNEL, A A A A A A A A .may_unmap = 1, + A A A A A A A .may_swap = 1, A A A A A A A A .swap_cluster_max = SWAP_CLUSTER_MAX, A A A A A A A A .swappiness = vm_swappiness, A A A A A A A A .order = order,@@ -2109,6 +2115,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages) A A A A struct scan_control sc = { A A A A A A A A .gfp_mask = GFP_KERNEL, A A A A A A A A .may_unmap = 0, + A A A A A A A .may_swap = 1, A A A A A A A A .swap_cluster_max = nr_pages, A A A A A A A A .may_writepage = 1, A A A A A A A A .isolate_pages = isolate_pages_global,@@ -2289,6 +2296,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) A A A A struct scan_control sc = { A A A A A A A A .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE), A A A A A A A A .may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP), + A A A A A A A .may_swap = 1,
Quoted 15 lines
Quoted 8 lines
mm/vmscan.c +0
-0A A A A A A A A .swap_cluster_max = max_t(unsigned long, nr_pages, A A A A A A A A A A A A A A A A A A A A SWAP_CLUSTER_MAX), A A A A A A A A .gfp_mask = gfp_mask,Signature · 2 lines
Kinds regards, Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 10 lines
Quoted 8 lines
Sorry for too late response.
I don't know memcg well.The memcg managed to use
may_swapwell with global page reclaim until now. I think that was becausemay_swapcan represent both meaning. Do we need each variables really ?How about using union variable ?
or Just removing one of them ?
I hope all may_unmap user convert to using may_swap. may_swap is more efficient and cleaner meaning.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerRe: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 7 lines · KOSAKI Motohiro
Quoted 7 lines
Quoted 7 lines
Sorry for too late response.
I don't know memcg well.The memcg managed to use
may_swapwell with global page reclaim until now. I think that was becausemay_swapcan represent both meaning. Do we need each variables really ?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
How about using union variable ?
or Just removing one of them ?
I hope all
may_unmapuser convert to usingmay_swap.may_swapis more efficient and cleaner meaning.
How about making may_swap mean the following:
@@ -642,6 +639,8 @@ static unsigned long shrink_page_list(st
* Try to allocate it some swap space here.
*/
if (PageAnon(page) && !PageSwapCache(page)) {
+ if (!sc->map_swap)
+ goto keep_locked;
if (!(sc->gfp_mask & __GFP_IO))
goto keep_locked;
if (!add_to_swap(page))try_to_free_pages() always sets it.
try_to_free_mem_cgroup_pages() sets it depending on whether it really wants swapping, and only swapping, right? But the above would still reclaim already swapped anon pages and I don't know the memory controller.
balance_pgdat() always sets it.
__zone_reclaim() sets it depending on zone_reclaim_mode. The RECLAIM_SWAP bit of this field and its documentation in Documentation/sysctl/vm.txt suggests it also really only means swap.
shrink_all_memory() would be the sole user of may_unmap because it really wants to eat cache first. But this could be figured out on a different occasion.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 17 lines · Johannes Weiner
Quoted 7 lines · KOSAKI Motohiro
Quoted 7 lines
Quoted 7 lines
Sorry for too late response.
I don't know memcg well.The memcg managed to use
may_swapwell with global page reclaim until now. I think that was becausemay_swapcan represent both meaning. Do we need each variables really ?Quoted 6 lines
Quoted 3 lines
Quoted 1 line
How about using union variable ?
or Just removing one of them ?
I hope all
may_unmapuser convert to usingmay_swap.may_swapis more efficient and cleaner meaning.How about making
may_swapmean the following:
Quoted 10 lines
@@ -642,6 +639,8 @@ static unsigned long shrink_page_list(st
* Try to allocate it some swap space here.
*/
if (PageAnon(page) && !PageSwapCache(page)) {
+ if (!sc->map_swap)
+ goto keep_locked;
if (!(sc->gfp_mask & __GFP_IO))
goto keep_locked;
if (!add_to_swap(page))but it doesn't work for shmem/tmpfs, does it?
So, I did in my first patch like:
@@ -616,6 +619,11 @@ static unsigned long shrink_page_list(struct list_head *page_list,
if (!sc->may_unmap && page_mapped(page))
goto keep_locked;
+ if (!sc->may_swap && PageSwapBacked(page)
+ /* SwapCache uses 'swap' already */
+ && !PageSwapCache(page))
+ goto keep_locked;
+
/* Double the slab pressure for mapped and swapcache pages */ if (page_mapped(page) || PageSwapCache(page))
sc->nr_scanned++;
Quoted 4 lines
try_to_free_pages()always sets it.
try_to_free_mem_cgroup_pages()sets it depending on whether it really wants swapping, and only swapping, right?
right.
Quoted 1 line
But the above would still reclaim already swapped anon pages
then, it would be better to add a check at shrink_page_list anyway..
Kosaki-san, what do you think?
Thanks,
Daisuke Nishimura.
Quoted 9 lines
and I don't know the memory
controller.
balance_pgdat()always sets it.
__zone_reclaim()sets it depending onzone_reclaim_mode. TheRECLAIM_SWAPbit of this field and its documentation inDocumentation/sysctl/vm.txtsuggests it also really only means swap.
Quoted 5 lines
shrink_all_memory()would be the sole user ofmay_unmapbecause it really wants to eat cache first. But this could be figured out on a different occasion.Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
In reply to Johannes WeinerQuoted 27 lines · On Wed, 1 Apr 2009 06:09:51 +0200 Johannes Weiner <[email protected]> wrote:
Quoted 7 lines · KOSAKI Motohiro
Quoted 7 lines
Quoted 7 lines
Sorry for too late response.
I don't know memcg well.The memcg managed to use
may_swapwell with global page reclaim until now. I think that was becausemay_swapcan represent both meaning. Do we need each variables really ?Quoted 6 lines
Quoted 3 lines
Quoted 1 line
How about using union variable ?
or Just removing one of them ?
I hope all
may_unmapuser convert to usingmay_swap.may_swapis more efficient and cleaner meaning.How about making
may_swapmean the following:@@ -642,6 +639,8 @@ static unsigned long shrink_page_list(st * Try to allocate it some swap space here. */ if (PageAnon(page) && !PageSwapCache(page)) { + if (!sc->map_swap) + goto keep_locked; if (!(sc->gfp_mask & __GFP_IO)) goto keep_locked; if (!add_to_swap(page))
Quoted 2 lines
try_to_free_pages()always sets it.
What is the advantage than _not_ scanning ANON LRU at all ?
Quoted 5 lines
try_to_free_mem_cgroup_pages()sets it depending on whether it really wants swapping, and only swapping, right? But the above would still reclaim already swapped anon pages and I don't know the memory controller.
memory cgroup has 2 calls to this shrink_zone.
1. memory usage hits the limit.
2. mem+swap usage hits the limit.
At "2", swap-out doesn't decrease the usage of mem+swap, then set may_swap=0. So, we want to kick out only file caches.
But, we can reclaim file cache and "unmap file cache and reclaim it!" is necessary even if may_swap=0.
Then, scanning only FILE LRU makes sense at may_swap=0 *if* memcg is the only user of may_swap=0.
Let's see others.
- __zone_reclaim sets may_unmap to be 0 when they don't want swap-out. .....can be replaced with may_swap.
- shrink_all_memory sets may_swap to be 0. Is this called by hibernation ? If you don't want to unmap file caches while hibernation, adding may_unmap as *new* paramter makes sense, I think.
The change you proposed is for dropping unused SwapCache pages. Right ? But this will be dropped by kswapd if necessary.
As far as memcg concerns, scanning ANON LRU even when may_swap=0 is just a waste of cpu time.
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 21 lines
memory cgroup has 2 calls to this
shrink_zone.
1. memory usage hits the limit.
2. mem+swap usage hits the limit.At "2", swap-out doesn't decrease the usage of mem+swap, then set may_swap=0. So, we want to kick out only file caches.
But, we can reclaim file cache and "unmap file cache and reclaim it!" is necessary even if may_swap=0.Then, scanning only FILE LRU makes sense at may_swap=0 *if* memcg is the only user of may_swap=0.
Let's see others.
-
__zone_reclaimsetsmay_unmapto be 0 when they don't want swap-out. .....can be replaced withmay_swap.-
shrink_all_memorysetsmay_swapto be 0. Is this called by hibernation ? If you don't want to unmap file caches while hibernation, addingmay_unmapas *new* paramter makes sense, I think.
Quoted 5 lines
The change you proposed is for dropping unused SwapCache pages. Right ? But this will be dropped by kswapd if necessary.
As far as memcg concerns, scanning ANON LRU even when may_swap=0 is just a waste of cpu time.
this sentence just explain my intention.
1. memcg, zone_reclaim scanning ANON LRU is just waste of cpu.
2. kswapd and normal direct reclaim can reclaim stealed swapcache anyway. then above trick don't cause any system hang-up and performance degression.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerRe: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
In reply to KAMEZAWA HiroyukiQuoted 30 lines · KAMEZAWA Hiroyuki
Quoted 27 lines · On Wed, 1 Apr 2009 06:09:51 +0200 Johannes Weiner <[email protected]> wrote:
Quoted 7 lines · KOSAKI Motohiro
Quoted 7 lines
Quoted 7 lines
Sorry for too late response.
I don't know memcg well.The memcg managed to use
may_swapwell with global page reclaim until now. I think that was becausemay_swapcan represent both meaning. Do we need each variables really ?Quoted 6 lines
Quoted 3 lines
Quoted 1 line
How about using union variable ?
or Just removing one of them ?
I hope all
may_unmapuser convert to usingmay_swap.may_swapis more efficient and cleaner meaning.How about making
may_swapmean the following:@@ -642,6 +639,8 @@ static unsigned long shrink_page_list(st * Try to allocate it some swap space here. */ if (PageAnon(page) && !PageSwapCache(page)) { + if (!sc->map_swap) + goto keep_locked; if (!(sc->gfp_mask & __GFP_IO)) goto keep_locked; if (!add_to_swap(page))
Quoted 3 lines
Quoted 2 lines
try_to_free_pages()always sets it.What is the advantage than _not_ scanning ANON LRU at all ?
I thought we could collect anon pages that don't need swap io.
Quoted 5 lines
Quoted 5 lines
try_to_free_mem_cgroup_pages()sets it depending on whether it really wants swapping, and only swapping, right? But the above would still reclaim already swapped anon pages and I don't know the memory controller.
Quoted 8 lines
memory cgroup has 2 calls to this
shrink_zone.
1. memory usage hits the limit.
2. mem+swap usage hits the limit.At "2", swap-out doesn't decrease the usage of mem+swap, then set may_swap=0. So, we want to kick out only file caches.
But, we can reclaim file cache and "unmap file cache and reclaim it!" is necessary even if may_swap=0.
Yes.
Quoted 11 lines
Then, scanning only FILE LRU makes sense at may_swap=0 *if* memcg is the only user of may_swap=0.
Let's see others.
-
__zone_reclaimsetsmay_unmapto be 0 when they don't want swap-out. .....can be replaced withmay_swap.-
shrink_all_memorysetsmay_swapto be 0. Is this called by hibernation ? If you don't want to unmap file caches while hibernation, addingmay_unmapas *new* paramter makes sense, I think.
Yep, that was my idea too. At least for now and then reevaluate whether it shouldn't just reclaim in lru order without this flag...
Quoted 5 lines
The change you proposed is for dropping unused SwapCache pages. Right ? But this will be dropped by kswapd if necessary.
As far as memcg concerns, scanning ANON LRU even when may_swap=0 is just a waste of cpu time.
Okay.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
How about making
may_swapmean the following:@@ -642,6 +639,8 @@ static unsigned long shrink_page_list(st * Try to allocate it some swap space here. */ if (PageAnon(page) && !PageSwapCache(page)) { + if (!sc->map_swap) + goto keep_locked; if (!(sc->gfp_mask & __GFP_IO)) goto keep_locked; if (!add_to_swap(page))
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
try_to_free_pages()always sets it.What is the advantage than _not_ scanning ANON LRU at all ?
I thought we could collect anon pages that don't need swap io.
Yes. but Is this important?
if memcg reclaim don't collect sleal swapcache, other global reclaim can.
Am I missing any viewpoint?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerRe: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
Quoted 14 lines · KOSAKI Motohiro
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
How about making
may_swapmean the following:@@ -642,6 +639,8 @@ static unsigned long shrink_page_list(st * Try to allocate it some swap space here. */ if (PageAnon(page) && !PageSwapCache(page)) { + if (!sc->map_swap) + goto keep_locked; if (!(sc->gfp_mask & __GFP_IO)) goto keep_locked; if (!add_to_swap(page))
try_to_free_pages()always sets it.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What is the advantage than _not_ scanning ANON LRU at all ?
I thought we could collect anon pages that don't need swap io.
Yes. but Is this important?
if memcg reclaim don't collect sleal swapcache, other global reclaim can.Am I missing any viewpoint?
Nothing I am aware of, it should work as you suggest. I just wasn't sure about the memory controller.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] vmscan: memcg needs may_swap (Re: [patch] vmscan: rename sc.may_swap to may_unmap)
In reply to Minchan KimHi,
Quoted 27 lines
Quoted 27 lines
========
Subject: vmswan: reintroducesc->may_swapvmscan-rename-scmay_swap-to-may_unmap.patch removed
may_swapflag, but memcg had used it as a flag for "we need to use swap?", as the name indicate.And in current implementation, memcg cannot reclaim mapped file caches when mem+swap hits the limit.
re-introduce
may_swapflag and handle it atget_scan_ratio(). This patch doesn't influence anyscan_controlusers other than memcg.Signed-off-by KOSAKI Motohiro <[email protected]>Signed-off-by Daisuke Nishimura <[email protected]>--
Amm/vmscan.c| A 12 ++++++++++--
A 1 files changed, 10 insertions(+), 2 deletions(-)mm/vmscan.c +0
-0@@ -63,6 +63,9 @@ struct scan_control {A A A A /* Can mapped pages be reclaimed? */ A A A A int may_unmap;
Quoted 8 lines
Quoted 3 lines
+ A A A /* Can pages be swapped as part of reclaim? */ + A A A int may_swap;+
Sorry for too late response.
I don't know memcg well.The memcg managed to use
may_swapwell with global page reclaim until now.
memcg had a bug that it cannot reclaim mapped file caches when it hit the mem+swap limit :(
Thanks,
Daisuke Nishimura.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 7 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
The patch bugs me.
The whole darn point behind the whole darn page reclaim is "reclaim the pages which we aren't likely to need soon". There's nothing special about the swsusp code at all! We want it to do exactly what page reclaim normally does, only faster.
So why do we need to write special hand-rolled code to implement something which we've already spent ten years writing?
hm? And if this approach leads to less-than-optimum performance after resume then the fault lies with core page reclaim - it reclaimed the wrong pages!
That actually was my thinking when I first worked on shrink_all_memory() and it did turn out to be surprisingly hard to simply reuse the existing reclaim code for this application. Things kept on going wrong. IIRC this was because we were freeing pages as we were reclaiming, so the page reclaim logic kept on seeing all these free pages and kept on wanting to bale out.
Now, the simple and obvious fix to this is not to free the pages - just keep on allocating pages and storing them locally until we have "enough" memory. Then when we're all done, dump them all straight onto to the freelists.
But for some reason which I do not recall, we couldn't do that.
It would be good to revisit all this.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 5 lines · Andrew Morton
Quoted 2 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Quoted 8 lines
Quoted 5 lines
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
Okay.
Quoted 1 line
The patch bugs me.
Please ignore it, it is broken as is. My verbal cortex got obviously disconnected from my code cortex when writing the changelog... And I will reconsider the actual change bits, I still think that we shouldn't scan anon page lists while may_swap is zero.
Quoted 19 lines
The whole darn point behind the whole darn page reclaim is "reclaim the pages which we aren't likely to need soon". There's nothing special about the swsusp code at all! We want it to do exactly what page reclaim normally does, only faster.
So why do we need to write special hand-rolled code to implement something which we've already spent ten years writing?
hm? And if this approach leads to less-than-optimum performance after resume then the fault lies with core page reclaim - it reclaimed the wrong pages!
That actually was my thinking when I first worked on
shrink_all_memory()and it did turn out to be surprisingly hard to simply reuse the existing reclaim code for this application. Things kept on going wrong. IIRC this was because we were freeing pages as we were reclaiming, so the page reclaim logic kept on seeing all these free pages and kept on wanting to bale out.
Quoted 8 lines
Now, the simple and obvious fix to this is not to free the pages - just keep on allocating pages and storing them locally until we have "enough" memory. Then when we're all done, dump them all straight onto to the freelists.
But for some reason which I do not recall, we couldn't do that.
It would be good to revisit all this.
Thanks for the comments, I will see what I can come up with.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 15 lines · Johannes Weiner
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Quoted 8 lines
Quoted 5 lines
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
Quoted 6 lines
Okay.
Quoted 1 line
The patch bugs me.
Please ignore it, it is broken as is. My verbal cortex got obviously disconnected from my code cortex when writing the changelog...
If I understood this correctly, patch 3/3 is to be disregarded.
Quoted 2 lines
And I will reconsider the actual change bits, I still think that we shouldn't scan anon page lists while
may_swapis zero.
Hm, can you please remind me what may_swap == 0 acutally means?
Rafael
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 23 lines · Rafael J. Wysocki
Quoted 15 lines · Johannes Weiner
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Quoted 8 lines
Quoted 5 lines
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
Quoted 6 lines
Okay.
Quoted 1 line
The patch bugs me.
Please ignore it, it is broken as is. My verbal cortex got obviously disconnected from my code cortex when writing the changelog...
Quoted 6 lines
If I understood this correctly, patch 3/3 is to be disregarded.
Quoted 2 lines
And I will reconsider the actual change bits, I still think that we shouldn't scan anon page lists while
may_swapis zero.Hm, can you please remind me what
may_swap== 0 acutally means?
That no mapped pages are reclaimed. These are also mapped file pages, but more importantly in this case, anon pages. See this check in shrink_page_list():
if (!sc->may_swap && page_mapped(page))
goto keep_locked;So scanning anon lists without allowing to unmap doesn't free memory.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi.
Quoted 35 lines · Andrew Morton
Quoted 7 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
The patch bugs me.
The whole darn point behind the whole darn page reclaim is "reclaim the pages which we aren't likely to need soon". There's nothing special about the swsusp code at all! We want it to do exactly what page reclaim normally does, only faster.
So why do we need to write special hand-rolled code to implement something which we've already spent ten years writing?
hm? And if this approach leads to less-than-optimum performance after resume then the fault lies with core page reclaim - it reclaimed the wrong pages!
That actually was my thinking when I first worked on
shrink_all_memory()and it did turn out to be surprisingly hard to simply reuse the existing reclaim code for this application. Things kept on going wrong. IIRC this was because we were freeing pages as we were reclaiming, so the page reclaim logic kept on seeing all these free pages and kept on wanting to bale out.
Quoted 8 lines
Now, the simple and obvious fix to this is not to free the pages - just keep on allocating pages and storing them locally until we have "enough" memory. Then when we're all done, dump them all straight onto to the freelists.
But for some reason which I do not recall, we couldn't do that.
It would be good to revisit all this.
It would be. It would be good, too, if 'we' could make it actually free the number of pages it's asked for, too. At the moment, you generally get something like 90% of what you ask for. Makes carefully calculating how much you need to ask for a bit pointless :\
Nigel
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
2009/2/7 Andrew Morton <[email protected]>:
Quoted 35 lines
Quoted 7 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
The patch bugs me.
The whole darn point behind the whole darn page reclaim is "reclaim the pages which we aren't likely to need soon". There's nothing special about the swsusp code at all! We want it to do exactly what page reclaim normally does, only faster.
So why do we need to write special hand-rolled code to implement something which we've already spent ten years writing?
hm? And if this approach leads to less-than-optimum performance after resume then the fault lies with core page reclaim - it reclaimed the wrong pages!
That actually was my thinking when I first worked on
shrink_all_memory()and it did turn out to be surprisingly hard to simply reuse the existing reclaim code for this application. Things kept on going wrong. IIRC this was because we were freeing pages as we were reclaiming, so the page reclaim logic kept on seeing all these free pages and kept on wanting to bale out.
Quoted 6 lines
Now, the simple and obvious fix to this is not to free the pages - just keep on allocating pages and storing them locally until we have "enough" memory. Then when we're all done, dump them all straight onto to the freelists.
But for some reason which I do not recall, we couldn't do that.
current strategy is introduced commit d6277db4ab271862ed599da08d78961c70f00002 quotation here.
Author: Rafael J. Wysocki <[email protected]>
Date: Fri Jun 23 02:03:18 2006 -0700
Subject: [PATCH] swsusp: rework memory shrinker
Rework the swsusp's memory shrinker in the following way:
- Simplify balance_pgdat() by removing all of the swsusp-related code from it.
- Make shrink_all_memory() use shrink_slab() and a new function shrink_all_zones() which calls shrink_active_list() and shrink_inactive_list() directly for each zone in a way that's optimized for suspend.
In shrink_all_memory() we try to free exactly as many pages as the caller asks for, preferably in one shot, starting from easier targets. ?If slab caches are huge, they are most likely to have enough pages to reclaim. ?The inactive lists are next (the zones with more inactive pages go first) etc.
Each time shrink_all_memory() attempts to shrink the active and inactive lists for each zone in 5 passes. ?In the first pass, only the inactive lists are taken into consideration. ?In the next two passes the active lists are also shrunk, but mapped pages are not reclaimed. ?In the last two passes the active and inactive lists are shrunk and mapped pages are reclaimed as well. The aim of this is to alter the reclaim logic to choose the best pages to keep on resume and improve the responsiveness of the
and related discussion mail here.
akpm wrote:
--------------
And what was the observed effect of all this?
Rafael wrote:
--------------
Measurable effects:
1) It tends to free only as much memory as required, eg. if the image_size is set to 450 MB, the actual image sizes are almost always well above 400 MB and they tended to be below that number without the patch (~5-10% of a difference, but still :-)).
2) If image_size = 0, it frees everything that can be freed without any workarounds (we had to add the additional loop checking for ret >= nr_pages with the additional blk_congestion_wait() to the "original" shrinker to achieve this).
my conclusion is, nobody says "we can't". it's performance improvement purpose commit.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi.
Quoted 11 lines · KOSAKI Motohiro
akpm wrote:
--------------
And what was the observed effect of all this?Rafael wrote:
--------------
Measurable effects:
1) It tends to free only as much memory as required, eg. if theimage_sizeis set to 450 MB, the actual image sizes are almost always well above 400 MB and they tended to be below that number without the patch (~5-10% of a difference, but still :-)).
Do you always get at least the number of pages you ask for, if that's possible?
Regards,
Nigel
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 35 lines · Andrew Morton
Quoted 7 lines · On Fri, 6 Feb 2009 05:49:07 +0100 Johannes Weiner <[email protected]> wrote:
Quoted 1 line
and, I think you should mesure performence result.
Yes, I'm still thinking about ideas how to quantify it properly. I have not yet found a reliable way to check for whether the working set is intact besides seeing whether the resumed applications are responsive right away or if they first have to swap in their pages again.
Describing your subjective non-quantitative impressions would be better than nothing...
The patch bugs me.
The whole darn point behind the whole darn page reclaim is "reclaim the pages which we aren't likely to need soon". There's nothing special about the swsusp code at all! We want it to do exactly what page reclaim normally does, only faster.
So why do we need to write special hand-rolled code to implement something which we've already spent ten years writing?
hm? And if this approach leads to less-than-optimum performance after resume then the fault lies with core page reclaim - it reclaimed the wrong pages!
That actually was my thinking when I first worked on
shrink_all_memory()and it did turn out to be surprisingly hard to simply reuse the existing reclaim code for this application. Things kept on going wrong. IIRC this was because we were freeing pages as we were reclaiming, so the page reclaim logic kept on seeing all these free pages and kept on wanting to bale out.
Quoted 6 lines
Now, the simple and obvious fix to this is not to free the pages - just keep on allocating pages and storing them locally until we have "enough" memory. Then when we're all done, dump them all straight onto to the freelists.
But for some reason which I do not recall, we couldn't do that.
We used to do that. I remember having loop doing get_free_page and doing linklist of them. I believe it was considered quite an hack.
.....one reason is that ee don't want to OOMkill anything if memory is low, we want to abort the hibernation...
Sorry for being late.....
Signature · 8 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 18 lines
Quoted 11 lines
hm? And if this approach leads to less-than-optimum performance after resume then the fault lies with core page reclaim - it reclaimed the wrong pages!
That actually was my thinking when I first worked on
shrink_all_memory()and it did turn out to be surprisingly hard to simply reuse the existing reclaim code for this application. Things kept on going wrong. IIRC this was because we were freeing pages as we were reclaiming, so the page reclaim logic kept on seeing all these free pages and kept on wanting to bale out.Quoted 6 lines
Now, the simple and obvious fix to this is not to free the pages - just keep on allocating pages and storing them locally until we have "enough" memory. Then when we're all done, dump them all straight onto to the freelists.
But for some reason which I do not recall, we couldn't do that.
Quoted 7 lines
We used to do that. I remember having loop doing
get_free_pageand doing linklist of them. I believe it was considered quite an hack......one reason is that ee don't want to OOMkill anything if memory is low, we want to abort the hibernation...
Sorry for being late.....
Not at all.
your information is really helpful.
maybe, I expect we can make simplification without oomkill...
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi, Johannes.
I have some questions.
Just out of curiosity. :)
Quoted 7 lines · Johannes Weiner
File cache pages are saved to disk either through normal writeback by reclaim or by including them in the suspend image written to a swapfile.
Writing them either way should take the same amount of time but doing normal writeback and unmap changes the fault behaviour on resume from prefault to on-demand paging, smoothening out resume and giving
What do you mean "unmap"?
Why normal writeback and unmap chnages the fault behavior on resume ?
Quoted 6 lines
previously cached pages the chance to stay out of memory completely if they are not used anymore.
Another reason for preferring file page eviction is that the locality principle is visible in fault patterns and swap might perform really bad with subsequent faulting of contiguously mapped pages.
Why do you think that swap might perform bad with subsequent faulting of contiguusly mapped page ?
You mean normal file system is faster than swap due to readahead and smart block of allocation ?
Signature · 8 lines
Kinds Regards MinChan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · MinChan Kim
Hi, Johannes.
I have some questions.
Just out of curiosity. :)Quoted 4 lines · Johannes Weiner
File cache pages are saved to disk either through normal writeback by reclaim or by including them in the suspend image written to a swapfile.
Quoted 6 lines
Quoted 3 lines
Writing them either way should take the same amount of time but doing normal writeback and unmap changes the fault behaviour on resume from prefault to on-demand paging, smoothening out resume and giving
What do you mean "unmap"?
Why normal writeback and unmap chnages the fault behavior on resume ?
Please, Ignore poor first my question. :(
I agree with your opinion.
Quoted 11 lines
Quoted 6 lines
previously cached pages the chance to stay out of memory completely if they are not used anymore.
Another reason for preferring file page eviction is that the locality principle is visible in fault patterns and swap might perform really bad with subsequent faulting of contiguously mapped pages.
Why do you think that swap might perform bad with subsequent faulting of contiguusly mapped page ?
You mean normal file system is faster than swap due to readahead and smart block of allocation ?
But, I still can't understand this issue.
what mean "page eviction" ? Is it reclaim or swap out ?
Quoted 6 lines
--
Kinds Regards
MinChan Kim
Signature · 8 lines
Kinds regards, MinChan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 5 lines · MinChan Kim
Quoted 4 lines · MinChan Kim
Quoted 3 lines
Another reason for preferring file page eviction is that the locality principle is visible in fault patterns and swap might perform really bad with subsequent faulting of contiguously mapped pages.
Quoted 7 lines
Quoted 4 lines
Why do you think that swap might perform bad with subsequent faulting of contiguusly mapped page ?
You mean normal file system is faster than swap due to readahead and smart block of allocation ?But, I still can't understand this issue.
what mean "page eviction" ? Is it reclaim or swap out ?
Reclaim evicts pages from memory by swap out (and writeback).
In the suspend case, "reclaim" is perhaps not 100% correct. We are not directly interested in the amount of free pages as you are with reclaim, but interested in the amount of pages in use as those are the pages we have to write to disk. So "shrinking" is the better term.
But yes, I mean what you said:
You mean normal file system is faster than swap due to readahead and smart block of allocation ?
Yes.
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>