shrink_page_list: save page_mapped() to local val
Subsystems (3)
RFC PATCH 1/1 shrink_page_list: save page_mapped() to local val
In funtion shrink_page_list(), page_mapped() is called several times,save it to local val to reduce atomic_read.
--- mm/vmscan.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
mm/vmscan.c +5 -3
@@ -637,6 +637,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,struct address_space *mapping;struct page *page;int may_enter_fs; +int page_mapcount;cond_resched ();
@@ -653,11 +654,12 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (unlikely (!page_evictable (page,NULL ))) goto cull_mlocked; -if (!sc->may_unmap &&page_mapped (page)) + page_mapcount =page_mapped (page); +if (!sc->may_unmap && page_mapcount) goto keep_locked;/* Double the slab pressure for mapped and swapcache pages */ -if (page_mapped (page) ||PageSwapCache (page)) +if (page_mapcount ||PageSwapCache (page)) sc->nr_scanned++; may_enter_fs = (sc->gfp_mask & __GFP_FS) ||
@@ -707,7 +709,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,* The page is mapped into the page tables of one or more * processes. Try to unmap it here. */ -if (page_mapped (page) && mapping) { +if (page_mapcount && mapping) {switch (try_to_unmap (page,TTU_UNMAP )) {case SWAP_FAIL : goto activate_locked;
Signature · 7 lines
1.5.6.3 -- 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
maintainerHi,
Quoted 23 lines · Bob Liu
In funtion
shrink_page_list(),page_mapped()is called several times,save it to local val to reduceatomic_read.Signed-off-by Bob Liu <[email protected]>--- mm/vmscan.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)mm/vmscan.c +1
-0@@ -637,6 +637,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,struct address_space *mapping;struct page *page;int may_enter_fs; +int page_mapcount;cond_resched ();@@ -653,11 +654,12 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (unlikely (!page_evictable (page,NULL ))) goto cull_mlocked;
mm/vmscan.c static unsigned long shrink_page_list(struct list_head *page_list, · line 663
Quoted 10 lines
mm/vmscan.c +3
-2-if (!sc->may_unmap &&page_mapped (page)) + page_mapcount =page_mapped (page); +if (!sc->may_unmap && page_mapcount) goto keep_locked;/* Double the slab pressure for mapped and swapcache pages */ -if (page_mapped (page) ||PageSwapCache (page)) +if (page_mapcount ||PageSwapCache (page)) sc->nr_scanned++;
Note that the mapcount is unstable and might very well drop while this code runs.
The first two instances are close enough together that a change is unlikely, but between them and the below check before try_to_unmap() we might be even waiting for writeback to complete.
try_to_unmap() will figure it out, but it would lock the mapping first and then read the mapcount.
I am unsure whether the change is worth it.
mm/vmscan.c static unsigned long shrink_page_list(struct list_head *page_list, · line 715
Quoted 10 lines
mm/vmscan.c +1
-1may_enter_fs = (sc->gfp_mask & __GFP_FS) ||@@ -707,7 +709,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,* The page is mapped into the page tables of one or more * processes. Try to unmap it here. */ -if (page_mapped (page) && mapping) { +if (page_mapcount && mapping) {switch (try_to_unmap (page,TTU_UNMAP )) {case SWAP_FAIL : goto activate_locked;
--
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>