diff options
Diffstat (limited to 'mm/rmap.c')
| -rw-r--r-- | mm/rmap.c | 19 | 
1 files changed, 12 insertions, 7 deletions
| diff --git a/mm/rmap.c b/mm/rmap.c index 92eeb3866494..ac4f783d6ec2 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1463,12 +1463,12 @@ static __always_inline void __folio_add_anon_rmap(struct folio *folio,  	}  	/* -	 * For large folio, only mlock it if it's fully mapped to VMA. It's -	 * not easy to check whether the large folio is fully mapped to VMA -	 * here. Only mlock normal 4K folio and leave page reclaim to handle -	 * large folio. +	 * Only mlock it if the folio is fully mapped to the VMA. +	 * +	 * Partially mapped folios can be split on reclaim and part outside +	 * of mlocked VMA can be evicted or freed.  	 */ -	if (!folio_test_large(folio)) +	if (folio_nr_pages(folio) == nr_pages)  		mlock_vma_folio(folio, vma);  } @@ -1601,8 +1601,13 @@ static __always_inline void __folio_add_file_rmap(struct folio *folio,  	__folio_add_rmap(folio, page, nr_pages, vma, level); -	/* See comments in folio_add_anon_rmap_*() */ -	if (!folio_test_large(folio)) +	/* +	 * Only mlock it if the folio is fully mapped to the VMA. +	 * +	 * Partially mapped folios can be split on reclaim and part outside +	 * of mlocked VMA can be evicted or freed. +	 */ +	if (folio_nr_pages(folio) == nr_pages)  		mlock_vma_folio(folio, vma);  } | 
