linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Huang Ying <ying.huang@intel.com>
Subject: [PATCH 08/11] mm/rmap: Fix assumptions of THP size
Date: Tue,  8 Sep 2020 20:55:35 +0100	[thread overview]
Message-ID: <20200908195539.25896-9-willy@infradead.org> (raw)
In-Reply-To: <20200908195539.25896-1-willy@infradead.org>

Ask the page what size it is instead of assuming it's PMD size.  Do this
for anon pages as well as file pages for when someone decides to support
that.  Leave the assumption alone for pages which are PMD mapped; we
don't currently grow THPs beyond PMD size, so we don't need to change
this code yet.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/rmap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 83cc459edc40..10f93129648c 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1205,7 +1205,7 @@ void page_add_file_rmap(struct page *page, bool compound)
 	VM_BUG_ON_PAGE(compound && !PageTransHuge(page), page);
 	lock_page_memcg(page);
 	if (compound && PageTransHuge(page)) {
-		for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
+		for (i = 0, nr = 0; i < thp_nr_pages(page); i++) {
 			if (atomic_inc_and_test(&page[i]._mapcount))
 				nr++;
 		}
@@ -1246,7 +1246,7 @@ static void page_remove_file_rmap(struct page *page, bool compound)
 
 	/* page still mapped by someone else? */
 	if (compound && PageTransHuge(page)) {
-		for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
+		for (i = 0, nr = 0; i < thp_nr_pages(page); i++) {
 			if (atomic_add_negative(-1, &page[i]._mapcount))
 				nr++;
 		}
@@ -1293,7 +1293,7 @@ static void page_remove_anon_compound_rmap(struct page *page)
 		 * Subpages can be mapped with PTEs too. Check how many of
 		 * them are still mapped.
 		 */
-		for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
+		for (i = 0, nr = 0; i < thp_nr_pages(page); i++) {
 			if (atomic_add_negative(-1, &page[i]._mapcount))
 				nr++;
 		}
@@ -1303,10 +1303,10 @@ static void page_remove_anon_compound_rmap(struct page *page)
 		 * page of the compound page is unmapped, but at least one
 		 * small page is still mapped.
 		 */
-		if (nr && nr < HPAGE_PMD_NR)
+		if (nr && nr < thp_nr_pages(page))
 			deferred_split_huge_page(page);
 	} else {
-		nr = HPAGE_PMD_NR;
+		nr = thp_nr_pages(page);
 	}
 
 	if (unlikely(PageMlocked(page)))
-- 
2.28.0



  parent reply	other threads:[~2020-09-08 20:20 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 19:55 [PATCH 00/11] Remove assumptions of THP size Matthew Wilcox (Oracle)
2020-09-08 19:55 ` [PATCH 01/11] mm/filemap: Fix page cache removal for arbitrary sized THPs Matthew Wilcox (Oracle)
2020-09-09 14:27   ` Kirill A. Shutemov
2020-09-15  7:13   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 02/11] mm/memory: Remove page fault assumption of compound page size Matthew Wilcox (Oracle)
2020-09-09 14:29   ` Kirill A. Shutemov
2020-09-09 14:50     ` Matthew Wilcox
2020-09-11 14:51       ` Kirill A. Shutemov
2020-09-08 19:55 ` [PATCH 03/11] mm/page_owner: Change split_page_owner to take a count Matthew Wilcox (Oracle)
2020-09-09 14:42   ` Kirill A. Shutemov
2020-09-15  7:17   ` SeongJae Park
2020-10-13 13:52   ` Matthew Wilcox
2020-09-08 19:55 ` [PATCH 04/11] mm/huge_memory: Fix total_mapcount assumption of page size Matthew Wilcox (Oracle)
2020-09-15  7:21   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 05/11] mm/huge_memory: Fix split " Matthew Wilcox (Oracle)
2020-09-15  7:23   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 06/11] mm/huge_memory: Fix page_trans_huge_mapcount assumption of THP size Matthew Wilcox (Oracle)
2020-09-09 14:45   ` Kirill A. Shutemov
2020-09-15  7:24   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 07/11] mm/huge_memory: Fix can_split_huge_page " Matthew Wilcox (Oracle)
2020-09-09 14:46   ` Kirill A. Shutemov
2020-09-15  7:25   ` SeongJae Park
2020-09-16  1:44   ` Huang, Ying
2020-09-08 19:55 ` Matthew Wilcox (Oracle) [this message]
2020-09-09 14:47   ` [PATCH 08/11] mm/rmap: Fix assumptions " Kirill A. Shutemov
2020-09-15  7:27   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 09/11] mm/truncate: Fix truncation for pages of arbitrary size Matthew Wilcox (Oracle)
2020-09-09 14:50   ` Kirill A. Shutemov
2020-09-15  7:36   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 10/11] mm/page-writeback: Support tail pages in wait_for_stable_page Matthew Wilcox (Oracle)
2020-09-09 14:53   ` Kirill A. Shutemov
2020-09-15  7:37   ` SeongJae Park
2020-09-08 19:55 ` [PATCH 11/11] mm/vmscan: Allow arbitrary sized pages to be paged out Matthew Wilcox (Oracle)
2020-09-09 14:55   ` Kirill A. Shutemov
2020-09-15  7:40   ` SeongJae Park
2020-09-15 12:52     ` Matthew Wilcox
2020-09-16  1:40       ` Huang, Ying
2020-09-16  6:09         ` SeongJae Park
2020-09-30 12:13         ` Matthew Wilcox

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=20200908195539.25896-9-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    --cc=ying.huang@intel.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;
as well as URLs for NNTP newsgroup(s).