Skip to content

Commit 192d723

Browse files
minchanktorvalds
authored andcommitted
mm: make try_to_munlock() return void
try_to_munlock returns SWAP_MLOCK if the one of VMAs mapped the page has VM_LOCKED flag. In that time, VM set PG_mlocked to the page if the page is not pte-mapped THP which cannot be mlocked, either. With that, __munlock_isolated_page can use PageMlocked to check whether try_to_munlock is successful or not without relying on try_to_munlock's retval. It helps to make try_to_unmap/try_to_unmap_one simple with upcoming patches. [[email protected]: remove PG_Mlocked VM_BUG_ON check] Link: http://lkml.kernel.org/r/20170411025615.GA6545@bbox Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Minchan Kim <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Sasha Levin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 22ffb33 commit 192d723

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

include/linux/rmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ int page_mkclean(struct page *);
235235
* called in munlock()/munmap() path to check for other vmas holding
236236
* the page mlocked.
237237
*/
238-
int try_to_munlock(struct page *);
238+
void try_to_munlock(struct page *);
239239

240240
void remove_migration_ptes(struct page *old, struct page *new, bool locked);
241241

mm/mlock.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,15 @@ static bool __munlock_isolate_lru_page(struct page *page, bool getpage)
123123
*/
124124
static void __munlock_isolated_page(struct page *page)
125125
{
126-
int ret = SWAP_AGAIN;
127-
128126
/*
129127
* Optimization: if the page was mapped just once, that's our mapping
130128
* and we don't need to check all the other vmas.
131129
*/
132130
if (page_mapcount(page) > 1)
133-
ret = try_to_munlock(page);
131+
try_to_munlock(page);
134132

135133
/* Did try_to_unlock() succeed or punt? */
136-
if (ret != SWAP_MLOCK)
134+
if (!PageMlocked(page))
137135
count_vm_event(UNEVICTABLE_PGMUNLOCKED);
138136

139137
putback_lru_page(page);

mm/rmap.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,18 +1552,10 @@ static int page_not_mapped(struct page *page)
15521552
* Called from munlock code. Checks all of the VMAs mapping the page
15531553
* to make sure nobody else has this page mlocked. The page will be
15541554
* returned with PG_mlocked cleared if no other vmas have it mlocked.
1555-
*
1556-
* Return values are:
1557-
*
1558-
* SWAP_AGAIN - no vma is holding page mlocked, or,
1559-
* SWAP_AGAIN - page mapped in mlocked vma -- couldn't acquire mmap sem
1560-
* SWAP_FAIL - page cannot be located at present
1561-
* SWAP_MLOCK - page is now mlocked.
15621555
*/
1563-
int try_to_munlock(struct page *page)
1564-
{
1565-
int ret;
15661556

1557+
void try_to_munlock(struct page *page)
1558+
{
15671559
struct rmap_walk_control rwc = {
15681560
.rmap_one = try_to_unmap_one,
15691561
.arg = (void *)TTU_MUNLOCK,
@@ -1573,9 +1565,9 @@ int try_to_munlock(struct page *page)
15731565
};
15741566

15751567
VM_BUG_ON_PAGE(!PageLocked(page) || PageLRU(page), page);
1568+
VM_BUG_ON_PAGE(PageCompound(page) && PageDoubleMap(page), page);
15761569

1577-
ret = rmap_walk(page, &rwc);
1578-
return ret;
1570+
rmap_walk(page, &rwc);
15791571
}
15801572

15811573
void __put_anon_vma(struct anon_vma *anon_vma)

0 commit comments

Comments
 (0)