If it is not the last entire map, we are sure the folio is not partially mapped. Move the check when there is no entire map. Signed-off-by: Wei Yang Cc: David Hildenbrand Cc: Lorenzo Stoakes Cc: Rik van Riel Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Harry Yoo --- mm/rmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index a927437a56c2..645d924bfc7d 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1757,9 +1757,9 @@ static __always_inline void __folio_remove_rmap(struct folio *folio, /* An add of ENTIRELY_MAPPED raced ahead */ nr = 0; } - } - partially_mapped = nr && nr < nr_pmdmapped; + partially_mapped = nr && nr < nr_pmdmapped; + } break; default: BUILD_BUG(); -- 2.34.1