linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yajun Deng <yajun.deng@linux.dev>
To: akpm@linux-foundation.org
Cc: Liam.Howlett@Oracle.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev>
Subject: [PATCH] mm/mmap: remove the mm parameter in vma_complete()
Date: Mon, 29 Jan 2024 15:53:05 +0800	[thread overview]
Message-ID: <20240129075305.3512138-1-yajun.deng@linux.dev> (raw)

There are vma_merge() and do_brk_flags() pass mm to vma_complete(), others
would pass the vma->vm_mm. The following explains that the mm is the
vma->vm_mm in vma_merge() and do_brk_flags().

All vma will point to the same mm struct if the vma_merge() is successful.
So the mm and the vma->mm are the same.

vm_brk_flags() and brk syscall will initialize vmi with current->mm,
so the vma->vm_mm and the current->mm are the same if vma exists in
do_brk_flags().

Remove the mm parameter in vma_complete() and get mm from the vma in vp.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 mm/mmap.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index e97b9144c61a..9b968d1edf55 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -509,11 +509,11 @@ static inline void vma_prepare(struct vma_prepare *vp)
  *
  * @vp: The vma_prepare struct
  * @vmi: The vma iterator
- * @mm: The mm_struct
  */
-static inline void vma_complete(struct vma_prepare *vp,
-				struct vma_iterator *vmi, struct mm_struct *mm)
+static inline void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi)
 {
+	struct mm_struct *mm = vp->vma->vm_mm;
+
 	if (vp->file) {
 		if (vp->adj_next)
 			vma_interval_tree_insert(vp->adj_next,
@@ -666,7 +666,7 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma,
 	vma_set_range(vma, start, end, pgoff);
 	vma_iter_store(vmi, vma);
 
-	vma_complete(&vp, vmi, vma->vm_mm);
+	vma_complete(&vp, vmi);
 	return 0;
 
 nomem:
@@ -707,7 +707,7 @@ int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma,
 
 	vma_iter_clear(vmi);
 	vma_set_range(vma, start, end, pgoff);
-	vma_complete(&vp, vmi, vma->vm_mm);
+	vma_complete(&vp, vmi);
 	return 0;
 }
 
@@ -1030,7 +1030,7 @@ static struct vm_area_struct
 		}
 	}
 
-	vma_complete(&vp, vmi, mm);
+	vma_complete(&vp, vmi);
 	khugepaged_enter_vma(res, vm_flags);
 	return res;
 
@@ -2377,7 +2377,7 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma,
 	}
 
 	/* vma_complete stores the new vma */
-	vma_complete(&vp, vmi, vma->vm_mm);
+	vma_complete(&vp, vmi);
 
 	/* Success. */
 	if (new_below)
@@ -3145,7 +3145,7 @@ static int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *vma,
 		vm_flags_set(vma, VM_SOFTDIRTY);
 		vma_iter_store(vmi, vma);
 
-		vma_complete(&vp, vmi, mm);
+		vma_complete(&vp, vmi);
 		khugepaged_enter_vma(vma, flags);
 		goto out;
 	}
-- 
2.25.1


             reply	other threads:[~2024-01-29  7:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29  7:53 Yajun Deng [this message]
2024-01-29 15:04 ` [PATCH] mm/mmap: remove the mm parameter in vma_complete() Liam R. Howlett
2024-02-22 10:26   ` Yajun Deng
2024-02-22 16:22     ` Liam R. Howlett
2024-02-23  2:36       ` Yajun Deng

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=20240129075305.3512138-1-yajun.deng@linux.dev \
    --to=yajun.deng@linux.dev \
    --cc=Liam.Howlett@Oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).