Skip to contentSkip to conversation

mm/z3fold.c: remove z3fold_migration trylock

PATCH In review Henry Burns 2 participants 3 messages Jul 10, 2019 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/z3fold.c: remove z3fold_migration trylock

z3fold_page_migrate() will never succeed because it attempts to acquire a lock that has already been taken by migrate.c in __unmap_and_move().

__unmap_and_move() migrate.c
trylock_page(oldpage)
move_to_new_page(oldpage_newpage)

    a_ops->migrate_page(oldpage, newpage)
      z3fold_page_migrate(oldpage, newpage)
        trylock_page(oldpage)
---
 mm/z3fold.c | 6 ------
 1 file changed, 6 deletions(-)
mm/z3fold.c +0 -6
index 985732c8b025..9fe9330ab8ae 100644
@@ -1335,16 +1335,11 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
 	zhdr = page_address(page);
 	pool = zhdr_to_pool(zhdr);
 
-	if (!trylock_page(page))
-		return -EAGAIN;
-
 	if (!z3fold_page_trylock(zhdr)) {
-		unlock_page(page);
 		return -EAGAIN;
 	}
 	if (zhdr->mapped_count != 0) {
 		z3fold_page_unlock(zhdr);
-		unlock_page(page);
 		return -EBUSY;
 	}
 	new_zhdr = page_address(newpage);
@@ -1376,7 +1371,6 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
 	queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);
 
 	page_mapcount_reset(page);
-	unlock_page(page);
 	put_page(page);
 	return 0;
 }
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Henry Burns

z3fold_page_migrate() will never succeed because it attempts to acquire a lock that has already been taken by migrate.c in __unmap_and_move().

__unmap_and_move() migrate.c
trylock_page(oldpage)
move_to_new_page(oldpage_newpage)

Quoted 6 lines
    a_ops->migrate_page(oldpage, newpage)
      z3fold_page_migrate(oldpage, newpage)
        trylock_page(oldpage)

Please add the Fixes tag as well.

Quoted 36 lines
---
 mm/z3fold.c | 6 ------
 1 file changed, 6 deletions(-)
mm/z3fold.c +0 -7
index 985732c8b025..9fe9330ab8ae 100644
@@ -1335,16 +1335,11 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
        zhdr = page_address(page);
        pool = zhdr_to_pool(zhdr);
 
-       if (!trylock_page(page))
-               return -EAGAIN;
-
        if (!z3fold_page_trylock(zhdr)) {
-               unlock_page(page);
                return -EAGAIN;
        }
        if (zhdr->mapped_count != 0) {
                z3fold_page_unlock(zhdr);
-               unlock_page(page);
                return -EBUSY;
        }
        new_zhdr = page_address(newpage);
@@ -1376,7 +1371,6 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
        queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);
 
        page_mapcount_reset(page);
-       unlock_page(page);
        put_page(page);
        return 0;
 }
--

2.22.0.410.gd8fdbe21b5-goog

#2 lore raw
Quoted 11 lines
Quoted 11 lines

z3fold_page_migrate() will never succeed because it attempts to acquire a lock that has already been taken by migrate.c in __unmap_and_move().

__unmap_and_move() migrate.c
trylock_page(oldpage)
move_to_new_page(oldpage_newpage)

    a_ops->migrate_page(oldpage, newpage)
      z3fold_page_migrate(oldpage, newpage)
        trylock_page(oldpage)
Quoted 5 lines
Quoted 1 line

Please add the Fixes tag as well.

Fixes 1f862989b04a ("mm/z3fold.c: support page migration")
Quoted 37 lines
Quoted 37 lines
---
 mm/z3fold.c | 6 ------
 1 file changed, 6 deletions(-)
mm/z3fold.c +0 -7
index 985732c8b025..9fe9330ab8ae 100644
@@ -1335,16 +1335,11 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
        zhdr = page_address(page);
        pool = zhdr_to_pool(zhdr);
 
-       if (!trylock_page(page))
-               return -EAGAIN;
-
        if (!z3fold_page_trylock(zhdr)) {
-               unlock_page(page);
                return -EAGAIN;
        }
        if (zhdr->mapped_count != 0) {
                z3fold_page_unlock(zhdr);
-               unlock_page(page);
                return -EBUSY;
        }
        new_zhdr = page_address(newpage);
@@ -1376,7 +1371,6 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa
        queue_work_on(new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);
 
        page_mapcount_reset(page);
-       unlock_page(page);
        put_page(page);
        return 0;
 }
--

2.22.0.410.gd8fdbe21b5-goog