linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Zach O'Keefe" <zokeefe@google.com>
To: linux-mm@kvack.org, Yang Shi <shy828301@gmail.com>
Cc: linux-kernel@vger.kernel.org, "Zach O'Keefe" <zokeefe@google.com>,
	 Matthew Wilcox <willy@infradead.org>
Subject: [PATCH v2 2/2] smaps: set THPeligible if file mapping supports large folios
Date: Fri, 18 Aug 2023 14:15:33 -0700	[thread overview]
Message-ID: <20230818211533.2523697-2-zokeefe@google.com> (raw)
In-Reply-To: <20230818211533.2523697-1-zokeefe@google.com>

File-backed memory can be backed by THPs either through collapse, when
CONFIG_READ_ONLY_THP_FOR_FS is enabled, or through fault, when the
filesystem supports large folio mappings.

Currently, smaps only knows about the former, so teach it about the
latter.

Signed-off-by: Zach O'Keefe <zokeefe@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
---
 mm/huge_memory.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index cd379b2c077b..d8d6e83820f3 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -136,7 +136,16 @@ bool hugepage_vma_check(struct vm_area_struct *vma, unsigned long vm_flags,
 			 */
 			!!vma->vm_ops->huge_fault :
 			/* Only regular file is valid in collapse path */
-			file_thp_enabled(vma);
+			file_thp_enabled(vma) ||
+			 /*
+			  * THPeligible bit of smaps should surface the
+			  * possibility of THP through fault if the filesystem
+			  * supports it.  We don't check this in fault path,
+			  * because we want to fallback to the actual ->fault()
+			  * handler to make the decision.
+			  */
+			 (smaps && vma->vm_file &&
+			 mapping_large_folio_support(vma->vm_file->f_mapping));
 
 	if (vma_is_temporary_stack(vma))
 		return false;
-- 
2.42.0.rc1.204.g551eb34607-goog



  reply	other threads:[~2023-08-18 21:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 21:15 [PATCH v2 1/2] mm/thp: fix "mm: thp: kill __transhuge_page_enabled()" Zach O'Keefe
2023-08-18 21:15 ` Zach O'Keefe [this message]
2023-08-18 22:14   ` [PATCH v2 2/2] smaps: set THPeligible if file mapping supports large folios Zach O'Keefe
2023-08-18 22:17     ` Matthew Wilcox
2023-08-18 23:10       ` Zach O'Keefe
2023-08-21 22:53 ` [PATCH v2 1/2] mm/thp: fix "mm: thp: kill __transhuge_page_enabled()" Yang Shi
2023-08-21 23:34   ` Zach O'Keefe

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=20230818211533.2523697-2-zokeefe@google.com \
    --to=zokeefe@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shy828301@gmail.com \
    --cc=willy@infradead.org \
    /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