Skip to content

Commit ad6b670

Browse files
minchanktorvalds
authored andcommitted
mm: remove SWAP_MLOCK in ttu
ttu doesn't need to return SWAP_MLOCK. Instead, just return SWAP_FAIL because it means the page is not-swappable so it should move to another LRU list(active or unevictable). putback friends will move it to right list depending on the page's LRU flag. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Minchan Kim <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 192d723 commit ad6b670

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

include/linux/rmap.h

-1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,5 @@ static inline int page_mkclean(struct page *page)
297297
#define SWAP_SUCCESS 0
298298
#define SWAP_AGAIN 1
299299
#define SWAP_FAIL 2
300-
#define SWAP_MLOCK 3
301300

302301
#endif /* _LINUX_RMAP_H */

mm/rmap.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
13291329
*/
13301330
mlock_vma_page(page);
13311331
}
1332-
ret = SWAP_MLOCK;
1332+
ret = SWAP_FAIL;
13331333
page_vma_mapped_walk_done(&pvmw);
13341334
break;
13351335
}
@@ -1506,7 +1506,6 @@ static int page_mapcount_is_zero(struct page *page)
15061506
* SWAP_SUCCESS - we succeeded in removing all mappings
15071507
* SWAP_AGAIN - we missed a mapping, try again later
15081508
* SWAP_FAIL - the page is unswappable
1509-
* SWAP_MLOCK - page is mlocked.
15101509
*/
15111510
int try_to_unmap(struct page *page, enum ttu_flags flags)
15121511
{

mm/vmscan.c

+7-13
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
987987
sc->nr_scanned++;
988988

989989
if (unlikely(!page_evictable(page)))
990-
goto cull_mlocked;
990+
goto activate_locked;
991991

992992
if (!sc->may_unmap && page_mapped(page))
993993
goto keep_locked;
@@ -1152,8 +1152,6 @@ static unsigned long shrink_page_list(struct list_head *page_list,
11521152
goto activate_locked;
11531153
case SWAP_AGAIN:
11541154
goto keep_locked;
1155-
case SWAP_MLOCK:
1156-
goto cull_mlocked;
11571155
case SWAP_SUCCESS:
11581156
; /* try to free the page below */
11591157
}
@@ -1295,20 +1293,16 @@ static unsigned long shrink_page_list(struct list_head *page_list,
12951293
list_add(&page->lru, &free_pages);
12961294
continue;
12971295

1298-
cull_mlocked:
1299-
if (PageSwapCache(page))
1300-
try_to_free_swap(page);
1301-
unlock_page(page);
1302-
list_add(&page->lru, &ret_pages);
1303-
continue;
1304-
13051296
activate_locked:
13061297
/* Not a candidate for swapping, so reclaim swap space. */
1307-
if (PageSwapCache(page) && mem_cgroup_swap_full(page))
1298+
if (PageSwapCache(page) && (mem_cgroup_swap_full(page) ||
1299+
PageMlocked(page)))
13081300
try_to_free_swap(page);
13091301
VM_BUG_ON_PAGE(PageActive(page), page);
1310-
SetPageActive(page);
1311-
pgactivate++;
1302+
if (!PageMlocked(page)) {
1303+
SetPageActive(page);
1304+
pgactivate++;
1305+
}
13121306
keep_locked:
13131307
unlock_page(page);
13141308
keep:

0 commit comments

Comments
 (0)