diff mbox series

Fix khugepaged's request size in collapse_file()

Message ID 159905616280.521200.12444250032673650063.stgit@warthog.procyon.org.uk (mailing list archive)
State New, archived
Headers show
Series Fix khugepaged's request size in collapse_file() | expand

Commit Message

David Howells Sept. 2, 2020, 2:16 p.m. UTC
collapse_file() in khugepaged passes PAGE_SIZE as the number of pages to be
read ahead to page_cache_sync_readahead().  It seems this was expressed as a
number of bytes rather than a number of pages.

Fix it to use the number of pages to the end of the window instead.

Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---

 mm/khugepaged.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yang Shi Sept. 2, 2020, 5:43 p.m. UTC | #1
On Wed, Sep 2, 2020 at 7:16 AM David Howells <dhowells@redhat.com> wrote:
>
> collapse_file() in khugepaged passes PAGE_SIZE as the number of pages to be
> read ahead to page_cache_sync_readahead().  It seems this was expressed as a
> number of bytes rather than a number of pages.
>
> Fix it to use the number of pages to the end of the window instead.
>
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Song Liu <songliubraving@fb.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Acked-by: Yang Shi <shy828301@gmail.com>

> ---
>
>  mm/khugepaged.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 6d199c353281..f2d243077b74 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1706,7 +1706,7 @@ static void collapse_file(struct mm_struct *mm,
>                                 xas_unlock_irq(&xas);
>                                 page_cache_sync_readahead(mapping, &file->f_ra,
>                                                           file, index,
> -                                                         PAGE_SIZE);
> +                                                         end - index);
>                                 /* drain pagevecs to help isolate_lru_page() */
>                                 lru_add_drain();
>                                 page = find_lock_page(mapping, index);
>
>
>
Pankaj Gupta Sept. 2, 2020, 6:54 p.m. UTC | #2
> collapse_file() in khugepaged passes PAGE_SIZE as the number of pages to be
> read ahead to page_cache_sync_readahead().  It seems this was expressed as a
> number of bytes rather than a number of pages.
>
> Fix it to use the number of pages to the end of the window instead.
>
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Song Liu <songliubraving@fb.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>
>  mm/khugepaged.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 6d199c353281..f2d243077b74 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1706,7 +1706,7 @@ static void collapse_file(struct mm_struct *mm,
>                                 xas_unlock_irq(&xas);
>                                 page_cache_sync_readahead(mapping, &file->f_ra,
>                                                           file, index,
> -                                                         PAGE_SIZE);
> +                                                         end - index);
>                                 /* drain pagevecs to help isolate_lru_page() */
>                                 lru_add_drain();
>                                 page = find_lock_page(mapping, index);
>

Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
diff mbox series

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 6d199c353281..f2d243077b74 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1706,7 +1706,7 @@  static void collapse_file(struct mm_struct *mm,
 				xas_unlock_irq(&xas);
 				page_cache_sync_readahead(mapping, &file->f_ra,
 							  file, index,
-							  PAGE_SIZE);
+							  end - index);
 				/* drain pagevecs to help isolate_lru_page() */
 				lru_add_drain();
 				page = find_lock_page(mapping, index);