diff mbox series

[v2,3/5] mm: Support removing arbitrary sized pages from mapping

Message ID 20191017164223.2762148-4-songliubraving@fb.com (mailing list archive)
State New, archived
Headers show
Series Fixes for THP in page cache | expand

Commit Message

Song Liu Oct. 17, 2019, 4:42 p.m. UTC
From: William Kucharski <william.kucharski@oracle.com>

__remove_mapping() assumes that pages can only be either base pages
or HPAGE_PMD_SIZE.  Ask the page what size it is.

Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Signed-off-by: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
 mm/vmscan.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Yang Shi Oct. 17, 2019, 5:43 p.m. UTC | #1
On Thu, Oct 17, 2019 at 9:42 AM Song Liu <songliubraving@fb.com> wrote:
>
> From: William Kucharski <william.kucharski@oracle.com>
>
> __remove_mapping() assumes that pages can only be either base pages
> or HPAGE_PMD_SIZE.  Ask the page what size it is.
>
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Signed-off-by: William Kucharski <william.kucharski@oracle.com>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Signed-off-by: Song Liu <songliubraving@fb.com>

Acked-by: Yang Shi <yang.shi@linux.alibaba.com>

> ---
>  mm/vmscan.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index c6659bb758a4..f870da1f4bb7 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -932,10 +932,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
>          * Note that if SetPageDirty is always performed via set_page_dirty,
>          * and thus under the i_pages lock, then this ordering is not required.
>          */
> -       if (unlikely(PageTransHuge(page)) && PageSwapCache(page))
> -               refcount = 1 + HPAGE_PMD_NR;
> -       else
> -               refcount = 2;
> +       refcount = 1 + compound_nr(page);
>         if (!page_ref_freeze(page, refcount))
>                 goto cannot_free;
>         /* note: atomic_cmpxchg in page_ref_freeze provides the smp_rmb */
> --
> 2.17.1
>
>
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c6659bb758a4..f870da1f4bb7 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -932,10 +932,7 @@  static int __remove_mapping(struct address_space *mapping, struct page *page,
 	 * Note that if SetPageDirty is always performed via set_page_dirty,
 	 * and thus under the i_pages lock, then this ordering is not required.
 	 */
-	if (unlikely(PageTransHuge(page)) && PageSwapCache(page))
-		refcount = 1 + HPAGE_PMD_NR;
-	else
-		refcount = 2;
+	refcount = 1 + compound_nr(page);
 	if (!page_ref_freeze(page, refcount))
 		goto cannot_free;
 	/* note: atomic_cmpxchg in page_ref_freeze provides the smp_rmb */