mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gregory Price <gourry@gourry.net>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	david@redhat.com, ying.huang@intel.com, nphamcs@gmail.com,
	nehagholkar@meta.com, abhishekd@meta.com,
	Johannes Weiner <hannes@cmpxchg.org>
Subject: [PATCH 1/3] migrate: Allow migrate_misplaced_folio APIs without a VMA
Date: Sat,  3 Aug 2024 05:47:13 -0400	[thread overview]
Message-ID: <20240803094715.23900-2-gourry@gourry.net> (raw)
In-Reply-To: <20240803094715.23900-1-gourry@gourry.net>

To migrate unmapped pagecache folios, migrate_misplaced_folio and
migrate_misplaced_folio_prepare must handle folios without VMAs.

migrate_misplaced_folio_prepare checks VMA for exec bits, so allow
a NULL VMA when it does not have a mapping. migrate_misplaced_folio
does not require a VMA, remove it from the argument list.

Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Gregory Price <gourry@gourry.net>
---
 include/linux/migrate.h | 6 ++----
 mm/huge_memory.c        | 2 +-
 mm/memory.c             | 2 +-
 mm/migrate.c            | 7 +++----
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 644be30b69c8..553bdb4a65db 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -141,16 +141,14 @@ const struct movable_operations *page_movable_ops(struct page *page)
 #ifdef CONFIG_NUMA_BALANCING
 int migrate_misplaced_folio_prepare(struct folio *folio,
 		struct vm_area_struct *vma, int node);
-int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma,
-			   int node);
+int migrate_misplaced_folio(struct folio *folio, int node);
 #else
 static inline int migrate_misplaced_folio_prepare(struct folio *folio,
 		struct vm_area_struct *vma, int node)
 {
 	return -EAGAIN; /* can't migrate now */
 }
-static inline int migrate_misplaced_folio(struct folio *folio,
-					 struct vm_area_struct *vma, int node)
+static inline int migrate_misplaced_folio(struct folio *folio, int node)
 {
 	return -EAGAIN; /* can't migrate now */
 }
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f4be468e06a4..f79c42e36d37 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1725,7 +1725,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
 	spin_unlock(vmf->ptl);
 	writable = false;
 
-	if (!migrate_misplaced_folio(folio, vma, target_nid)) {
+	if (!migrate_misplaced_folio(folio, target_nid)) {
 		flags |= TNF_MIGRATED;
 		nid = target_nid;
 	} else {
diff --git a/mm/memory.c b/mm/memory.c
index 34f8402d2046..1d97bdfd0ed6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5355,7 +5355,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
 	ignore_writable = true;
 
 	/* Migrate to the requested node */
-	if (!migrate_misplaced_folio(folio, vma, target_nid)) {
+	if (!migrate_misplaced_folio(folio, target_nid)) {
 		nid = target_nid;
 		flags |= TNF_MIGRATED;
 	} else {
diff --git a/mm/migrate.c b/mm/migrate.c
index e7296c0fb5d5..c648dc08758b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2546,7 +2546,7 @@ static struct folio *alloc_misplaced_dst_folio(struct folio *src,
 
 /*
  * Prepare for calling migrate_misplaced_folio() by isolating the folio if
- * permitted. Must be called with the PTL still held.
+ * permitted. If VMA is not NULL, Must be called with the PTL still held.
  */
 int migrate_misplaced_folio_prepare(struct folio *folio,
 		struct vm_area_struct *vma, int node)
@@ -2563,7 +2563,7 @@ int migrate_misplaced_folio_prepare(struct folio *folio,
 		 * See folio_likely_mapped_shared() on possible imprecision
 		 * when we cannot easily detect if a folio is shared.
 		 */
-		if ((vma->vm_flags & VM_EXEC) &&
+		if (vma && (vma->vm_flags & VM_EXEC) &&
 		    folio_likely_mapped_shared(folio))
 			return -EACCES;
 
@@ -2614,8 +2614,7 @@ int migrate_misplaced_folio_prepare(struct folio *folio,
  * elevated reference count on the folio. This function will un-isolate the
  * folio, dereferencing the folio before returning.
  */
-int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma,
-			    int node)
+int migrate_misplaced_folio(struct folio *folio, int node)
 {
 	pg_data_t *pgdat = NODE_DATA(node);
 	int nr_remaining;
-- 
2.43.0


  reply	other threads:[~2024-08-07 22:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-03  9:47 [PATCH 0/3] mm,TPP: Enable promotion of unmapped pagecache Gregory Price
2024-08-03  9:47 ` Gregory Price [this message]
2024-08-03  9:47 ` [PATCH 2/3] memory: allow non-fault migration in numa_migrate_prep path Gregory Price
2024-08-03  9:47 ` [PATCH 3/3] swap: enable promotion for unmapped pagecache on access Gregory Price
2024-08-08 23:20 ` [PATCH 0/3] mm,TPP: Enable promotion of unmapped pagecache Andrew Morton
2024-08-13 15:04   ` Gregory Price
2024-08-14 16:09     ` Gregory Price
2024-08-19  7:46 ` Huang, Ying
2024-08-19 15:15   ` Gregory Price
2024-09-02  6:53     ` Huang, Ying
2024-09-03 13:36       ` Gregory Price
2024-11-04 18:12       ` Gregory Price
2024-11-05  2:00         ` Huang, Ying
2024-11-05 15:16           ` Gregory Price
2024-11-08 18:00           ` Gregory Price
2024-11-11  1:35             ` Huang, Ying
2024-11-11 14:25               ` Gregory Price
2024-11-12  0:33                 ` Huang, Ying

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=20240803094715.23900-2-gourry@gourry.net \
    --to=gourry@gourry.net \
    --cc=abhishekd@meta.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nehagholkar@meta.com \
    --cc=nphamcs@gmail.com \
    --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

all inboxes | Powered by JetHome®