From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: akpm@linux-foundation.org
Cc: hughd@google.com, willy@infradead.org, david@redhat.com,
21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com,
ziy@nvidia.com, baolin.wang@linux.alibaba.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] mm: khugepaged: expand the is_refcount_suitable() to support file folios
Date: Mon, 19 Aug 2024 16:14:02 +0800 [thread overview]
Message-ID: <d6f8e4451910da1de0420eb82724dd85c368741c.1724054125.git.baolin.wang@linux.alibaba.com> (raw)
In-Reply-To: <cover.1724054125.git.baolin.wang@linux.alibaba.com>
Expand the is_refcount_suitable() to support reference checks for file folios,
as preparation for supporting shmem mTHP collapse.
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
mm/khugepaged.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index cdd1d8655a76..f11b4f172e61 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -549,8 +549,14 @@ static bool is_refcount_suitable(struct folio *folio)
int expected_refcount;
expected_refcount = folio_mapcount(folio);
- if (folio_test_swapcache(folio))
+ if (folio_test_anon(folio)) {
+ expected_refcount += folio_test_swapcache(folio) ?
+ folio_nr_pages(folio) : 0;
+ } else {
expected_refcount += folio_nr_pages(folio);
+ if (folio_test_private(folio))
+ expected_refcount++;
+ }
return folio_ref_count(folio) == expected_refcount;
}
@@ -2285,8 +2291,7 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,
break;
}
- if (folio_ref_count(folio) !=
- 1 + folio_mapcount(folio) + folio_test_private(folio)) {
+ if (!is_refcount_suitable(folio)) {
result = SCAN_PAGE_COUNT;
break;
}
--
2.39.3
next prev parent reply other threads:[~2024-08-19 8:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 8:14 [PATCH 0/5] support shmem mTHP collapse Baolin Wang
2024-08-19 8:14 ` Baolin Wang [this message]
2024-08-19 8:36 ` [PATCH 1/5] mm: khugepaged: expand the is_refcount_suitable() to support file folios David Hildenbrand
2024-08-19 8:42 ` Baolin Wang
2024-08-19 8:14 ` [PATCH 2/5] mm: khugepaged: use the number of pages in the folio to check the reference count Baolin Wang
2024-08-19 9:40 ` David Hildenbrand
2024-08-19 10:05 ` Baolin Wang
2024-08-19 8:14 ` [PATCH 3/5] mm: khugepaged: support shmem mTHP copy Baolin Wang
2024-08-19 8:14 ` [PATCH 4/5] mm: khugepaged: support shmem mTHP collapse Baolin Wang
2024-08-19 8:14 ` [PATCH 5/5] selftests: mm: support shmem mTHP collapse testing Baolin Wang
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=d6f8e4451910da1de0420eb82724dd85c368741c.1724054125.git.baolin.wang@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.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
all inboxes | Powered by JetHome®