linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Suren Baghdasaryan <surenb@google.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>
Subject: [PATCH v3 09/15] mm: Use vma_iter_clear_gfp() in nommu
Date: Mon, 24 Jul 2023 14:31:51 -0400	[thread overview]
Message-ID: <20230724183157.3939892-10-Liam.Howlett@oracle.com> (raw)
In-Reply-To: <20230724183157.3939892-1-Liam.Howlett@oracle.com>

Move the definition of vma_iter_clear_gfp() from mmap.c to internal.h so
it can be used in the nommu code.  This will reduce node preallocations
in nommu.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 mm/internal.h | 12 ++++++++++++
 mm/mmap.c     | 12 ------------
 mm/nommu.c    | 12 ++++--------
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/mm/internal.h b/mm/internal.h
index 65f646c2ccf3..2f35c0ef7b7f 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1064,6 +1064,18 @@ static inline void vma_iter_clear(struct vma_iterator *vmi,
 	mas_store_prealloc(&vmi->mas, NULL);
 }
 
+static inline int vma_iter_clear_gfp(struct vma_iterator *vmi,
+			unsigned long start, unsigned long end, gfp_t gfp)
+{
+	vmi->mas.index = start;
+	vmi->mas.last = end - 1;
+	mas_store_gfp(&vmi->mas, NULL, gfp);
+	if (unlikely(mas_is_err(&vmi->mas)))
+		return -ENOMEM;
+
+	return 0;
+}
+
 static inline struct vm_area_struct *vma_iter_load(struct vma_iterator *vmi)
 {
 	return mas_walk(&vmi->mas);
diff --git a/mm/mmap.c b/mm/mmap.c
index 625d7411d5a0..d09f11a9ad85 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -154,18 +154,6 @@ static inline struct vm_area_struct *vma_prev_limit(struct vma_iterator *vmi,
 	return mas_prev(&vmi->mas, min);
 }
 
-static inline int vma_iter_clear_gfp(struct vma_iterator *vmi,
-			unsigned long start, unsigned long end, gfp_t gfp)
-{
-	vmi->mas.index = start;
-	vmi->mas.last = end - 1;
-	mas_store_gfp(&vmi->mas, NULL, gfp);
-	if (unlikely(mas_is_err(&vmi->mas)))
-		return -ENOMEM;
-
-	return 0;
-}
-
 /*
  * check_brk_limits() - Use platform specific check of range & verify mlock
  * limits.
diff --git a/mm/nommu.c b/mm/nommu.c
index 9826f6101a05..418cc0669c1f 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1396,17 +1396,13 @@ static int vmi_shrink_vma(struct vma_iterator *vmi,
 
 	/* adjust the VMA's pointers, which may reposition it in the MM's tree
 	 * and list */
-	if (vma_iter_prealloc(vmi)) {
-		pr_warn("Allocation of vma tree for process %d failed\n",
-		       current->pid);
-		return -ENOMEM;
-	}
-
 	if (from > vma->vm_start) {
-		vma_iter_clear(vmi, from, vma->vm_end);
+		if (vma_iter_clear_gfp(vmi, from, vma->vm_end, GFP_KERNEL))
+			return -ENOMEM;
 		vma->vm_end = from;
 	} else {
-		vma_iter_clear(vmi, vma->vm_start, to);
+		if (vma_iter_clear_gfp(vmi, vma->vm_start, to, GFP_KERNEL))
+			return -ENOMEM;
 		vma->vm_start = to;
 	}
 
-- 
2.39.2



  parent reply	other threads:[~2023-07-24 18:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 18:31 [PATCH v3 00/15] Reduce preallocations for maple tree Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 01/15] maple_tree: Add benchmarking for mas_for_each Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 02/15] maple_tree: Add benchmarking for mas_prev() Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 03/15] mm: Change do_vmi_align_munmap() tracking of VMAs to remove Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 04/15] mm: Remove prev check from do_vmi_align_munmap() Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 05/15] maple_tree: Introduce __mas_set_range() Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 06/15] mm: Remove re-walk from mmap_region() Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 07/15] maple_tree: Re-introduce entry to mas_preallocate() arguments Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 08/15] maple_tree: Adjust node allocation on mas_rebalance() Liam R. Howlett
2023-07-24 18:31 ` Liam R. Howlett [this message]
2023-07-24 18:31 ` [PATCH v3 10/15] mm: Set up vma iterator for vma_iter_prealloc() calls Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 11/15] maple_tree: Move mas_wr_end_piv() below mas_wr_extend_null() Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 12/15] maple_tree: Update mas_preallocate() testing Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 13/15] maple_tree: Refine mas_preallocate() node calculations Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 14/15] maple_tree: Reduce resets during store setup Liam R. Howlett
2023-07-24 18:31 ` [PATCH v3 15/15] mm/mmap: Change vma iteration order in do_vmi_align_munmap() Liam R. Howlett
2023-08-14 15:43   ` Jann Horn
2023-08-14 19:10     ` Andrew Morton
2023-08-14 19:18     ` Liam R. Howlett
2023-08-14 21:22       ` Jann Horn
2023-08-15  7:29         ` Liam R. Howlett
2023-08-15 14:19           ` Jann Horn

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=20230724183157.3939892-10-Liam.Howlett@oracle.com \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=surenb@google.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