From: Matthew Wilcox <willy@infradead.org>
To: Song Liu <songliubraving@fb.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
akpm@linux-foundation.org, matthew.wilcox@oracle.com,
kernel-team@fb.com, william.kucharski@oracle.com,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH 3/4] mm/thp: allow drop THP from page cache
Date: Thu, 17 Oct 2019 09:12:47 -0700 [thread overview]
Message-ID: <20191017161247.GK32665@bombadil.infradead.org> (raw)
In-Reply-To: <20191016073731.4076725-4-songliubraving@fb.com>
On Wed, Oct 16, 2019 at 12:37:30AM -0700, Song Liu wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>
> Once a THP is added to the page cache, it cannot be dropped via
> /proc/sys/vm/drop_caches. Fix this issue with proper handling in
> invalidate_mapping_pages() and __remove_mapping().
>
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Tested-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
> mm/truncate.c | 12 ++++++++++++
> mm/vmscan.c | 3 ++-
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index c6659bb758a4..1d80a188ad4a 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -932,7 +932,8 @@ 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))
> + if (unlikely(PageTransHuge(page)) &&
> + (PageSwapCache(page) || !PageSwapBacked(page)))
> refcount = 1 + HPAGE_PMD_NR;
> else
> refcount = 2;
Kirill suggests that this patch would be better (for this part of the patch;
the part in truncate.c should remain as it is)
commit ddcee327f96d57cb9d5310486d21e43892b7a368
Author: William Kucharski <william.kucharski@oracle.com>
Date: Fri Sep 20 16:14:51 2019 -0400
mm: Support removing arbitrary sized pages from mapping
__remove_mapping() assumes that pages can only be either base pages
or HPAGE_PMD_SIZE. Further, it assumes that large pages are
swap-backed. Support all kinds of pages by unconditionally asking how
many pages this page references.
Signed-off-by: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
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 */
next prev parent reply other threads:[~2019-10-17 16:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 7:37 [PATCH 0/4] Fixes for THP in " Song Liu
2019-10-16 7:37 ` [PATCH 1/4] proc/meminfo: fix output alignment Song Liu
2019-10-16 7:37 ` [PATCH 2/4] mm/thp: fix node page state in split_huge_page_to_list() Song Liu
2019-10-16 7:37 ` [PATCH 3/4] mm/thp: allow drop THP from page cache Song Liu
2019-10-17 16:12 ` Matthew Wilcox [this message]
2019-10-17 16:36 ` Song Liu
2019-10-16 7:37 ` [PATCH 4/4] uprobe: only do FOLL_SPLIT_PMD for uprobe register Song Liu
2019-10-16 12:10 ` Oleg Nesterov
2019-10-16 16:10 ` Song Liu
2019-10-17 8:47 ` Oleg Nesterov
2019-10-17 14:05 ` Song Liu
2019-10-17 14:28 ` Oleg Nesterov
2019-10-17 15:34 ` Song Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191017161247.GK32665@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=kernel-team@fb.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.wilcox@oracle.com \
--cc=songliubraving@fb.com \
--cc=william.kucharski@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox