[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250124235454.84587-16-anthony.yznaga@oracle.com>
Date: Fri, 24 Jan 2025 15:54:49 -0800
From: Anthony Yznaga <anthony.yznaga@...cle.com>
To: akpm@...ux-foundation.org, willy@...radead.org, markhemm@...glemail.com,
viro@...iv.linux.org.uk, david@...hat.com, khalid@...nel.org
Cc: anthony.yznaga@...cle.com, jthoughton@...gle.com, corbet@....net,
dave.hansen@...el.com, kirill@...temov.name, luto@...nel.org,
brauner@...nel.org, arnd@...db.de, ebiederm@...ssion.com,
catalin.marinas@....com, mingo@...hat.com, peterz@...radead.org,
liam.howlett@...cle.com, lorenzo.stoakes@...cle.com, vbabka@...e.cz,
jannh@...gle.com, hannes@...xchg.org, mhocko@...nel.org,
roman.gushchin@...ux.dev, shakeel.butt@...ux.dev,
muchun.song@...ux.dev, tglx@...utronix.de, cgroups@...r.kernel.org,
x86@...nel.org, linux-doc@...r.kernel.org, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org, mhiramat@...nel.org,
rostedt@...dmis.org, vasily.averin@...ux.dev, xhao@...ux.alibaba.com,
pcc@...gle.com, neilb@...e.de, maz@...nel.org
Subject: [PATCH 15/20] mm: pass the mm in vma_munmap_struct
Allow unmap to work with an mshare host mm.
Signed-off-by: Anthony Yznaga <anthony.yznaga@...cle.com>
---
mm/vma.c | 10 ++++++----
mm/vma.h | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/mm/vma.c b/mm/vma.c
index 28942701e301..60a37a9eb15e 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -1174,7 +1174,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms,
struct vm_area_struct *vma;
struct mm_struct *mm;
- mm = current->mm;
+ mm = vms->mm;
mm->map_count -= vms->vma_count;
mm->locked_vm -= vms->locked_vm;
if (vms->unlock)
@@ -1382,13 +1382,15 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms,
* @start: The aligned start address to munmap
* @end: The aligned end address to munmap
* @uf: The userfaultfd list_head
+ * @mm: The mm struct
* @unlock: Unlock after the operation. Only unlocked on success
*/
static void init_vma_munmap(struct vma_munmap_struct *vms,
struct vma_iterator *vmi, struct vm_area_struct *vma,
unsigned long start, unsigned long end, struct list_head *uf,
- bool unlock)
+ struct mm_struct *mm, bool unlock)
{
+ vms->mm = mm;
vms->vmi = vmi;
vms->vma = vma;
if (vma) {
@@ -1432,7 +1434,7 @@ int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
struct vma_munmap_struct vms;
int error;
- init_vma_munmap(&vms, vmi, vma, start, end, uf, unlock);
+ init_vma_munmap(&vms, vmi, vma, start, end, uf, mm, unlock);
error = vms_gather_munmap_vmas(&vms, &mas_detach);
if (error)
goto gather_failed;
@@ -2229,7 +2231,7 @@ static int __mmap_prepare(struct mmap_state *map, struct list_head *uf)
/* Find the first overlapping VMA and initialise unmap state. */
vms->vma = vma_find(vmi, map->end);
- init_vma_munmap(vms, vmi, vms->vma, map->addr, map->end, uf,
+ init_vma_munmap(vms, vmi, vms->vma, map->addr, map->end, uf, map->mm,
/* unlock = */ false);
/* OK, we have overlapping VMAs - prepare to unmap them. */
diff --git a/mm/vma.h b/mm/vma.h
index e704f56577f3..03d69321312d 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -49,6 +49,7 @@ struct vma_munmap_struct {
unsigned long exec_vm;
unsigned long stack_vm;
unsigned long data_vm;
+ struct mm_struct *mm;
};
enum vma_merge_state {
--
2.43.5
Powered by blists - more mailing lists