From patchwork Fri Jan 24 23:54:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Yznaga X-Patchwork-Id: 13950036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12056C0218B for ; Fri, 24 Jan 2025 23:56:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D5BE2800BC; Fri, 24 Jan 2025 18:56:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 085862800B0; Fri, 24 Jan 2025 18:56:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E403A2800BC; Fri, 24 Jan 2025 18:56:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BF6E42800B0 for ; Fri, 24 Jan 2025 18:56:10 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8677FB22B1 for ; Fri, 24 Jan 2025 23:56:10 +0000 (UTC) X-FDA: 83044006500.28.17AAA6A Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 97A4F120003 for ; Fri, 24 Jan 2025 23:56:08 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=QXXOQ6N2; spf=pass (imf29.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737762968; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=W2H0ctTufvhNvnXZJs2k6LGmiWdy4rqMSHVr4raXjx0=; b=Go1r7VpjqBVfLdqCp64Xv9BJg59x3SSLLAfYppDqF5ciE7VDoBhTS2LuI7CcJk4eTlAmG2 AjLJVK3WM9+YELA7L52UM2iXLA57mreZKZA3k2XU9GUZh6vKpqIJgVeaVdijulKqp1/0UR FGjNK+E6SaZD3PeBCcxGIXcUdeDhp94= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=QXXOQ6N2; spf=pass (imf29.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737762968; a=rsa-sha256; cv=none; b=B9dmi2FvcguA3OePpRm/bhidOl5T/xNhtvooq08/i03R9Deus7Ri5kqELwgYYoSJx3dmED MpZL2PQLYKgNO0gXPcIJazWUzSCzhxF+rhP6kUXl1v4BWhYXAuFQ0+0uSYYCZljOFG6eOI iheQSRItPL7sPweOX46vTW42NpYB8zM= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50OIioeL018166; Fri, 24 Jan 2025 23:55:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=W2H0c tTufvhNvnXZJs2k6LGmiWdy4rqMSHVr4raXjx0=; b=QXXOQ6N23uk7G9VbZbPAF f/QqSAc5iOsT9xCDTdmT6oyWhAgniQUG3Z7HmFAfZ0bDBwKBIvV+YT7Vjcn2YUsw 4BXCgx2yNsC2NOEOkIHJOoc4cywTGNGprHkX2qJmp3Xx+WG/52Czo16Ed3Ov5QhM 7/Iq8gqTqAgrLzC/67EBmTQU8e0ckWYvZEkC9eoZSGIttbuEitMyfH3mwJVOB5cq nCTIcpd5kRDYGcIOT0w0nMvOGTNdnhFcaiRQEsEqsDLWzbY7hJ3r5tDcUZkZM2sm w/OjPwtIAYWhM4xN3xfWaR0SlPwYAKwlvDlxi/32YuE+r3YbcTLRLr2NJor30AJL g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44b96am96t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:55:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50ONC16b036516; Fri, 24 Jan 2025 23:55:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44917u4akt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:55:56 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 50ONsxQC018051; Fri, 24 Jan 2025 23:55:55 GMT Received: from localhost.us.oracle.com (dhcp-10-65-130-174.vpn.oracle.com [10.65.130.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 44917u49ww-16; Fri, 24 Jan 2025 23:55:55 +0000 From: Anthony Yznaga To: akpm@linux-foundation.org, willy@infradead.org, markhemm@googlemail.com, viro@zeniv.linux.org.uk, david@redhat.com, khalid@kernel.org Cc: anthony.yznaga@oracle.com, jthoughton@google.com, corbet@lwn.net, dave.hansen@intel.com, kirill@shutemov.name, luto@kernel.org, brauner@kernel.org, arnd@arndb.de, ebiederm@xmission.com, catalin.marinas@arm.com, mingo@redhat.com, peterz@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, jannh@google.com, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, tglx@linutronix.de, cgroups@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhiramat@kernel.org, rostedt@goodmis.org, vasily.averin@linux.dev, xhao@linux.alibaba.com, pcc@google.com, neilb@suse.de, maz@kernel.org Subject: [PATCH 15/20] mm: pass the mm in vma_munmap_struct Date: Fri, 24 Jan 2025 15:54:49 -0800 Message-ID: <20250124235454.84587-16-anthony.yznaga@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250124235454.84587-1-anthony.yznaga@oracle.com> References: <20250124235454.84587-1-anthony.yznaga@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-24_10,2025-01-23_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501240162 X-Proofpoint-GUID: 3Bsi0dEb_NSrsadh2i7dfRhctL6iq62g X-Proofpoint-ORIG-GUID: 3Bsi0dEb_NSrsadh2i7dfRhctL6iq62g X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 97A4F120003 X-Stat-Signature: kf3wj4gjdqgj95t1oj18wc9t41natn8y X-Rspam-User: X-HE-Tag: 1737762968-742861 X-HE-Meta: U2FsdGVkX1+TE2g89M9i/whtRiNHAAwxT75ltOUrkc7NbB1azRu/29RYdPT91Izw8WFE7MGMu0RHm8z28VfCfT3xIw4fFsON6NQO+n7ez06tFL18bCbb0IqtlD7YaPtQmXStlqwf1RQbROScsw/amdyBrxsQ8H9MN0dLQng+ITzvqqkXKPEFolW1Rdp9R+x1z0ZrQxDv5XVP+NDcyQEHR7dzqq8VTRKcveLmna9wy2nCRbqATVI9f3spjlPqo95ScUMsktS05nzm8h7nHERBMcxkPZqG5C7XZ79N9ct2OsWDEbDPLRsmzT16h0UlJe9DopJDvdZOtK2EmFbZC6eMY2UE2z/5AAUgp//VUxFj+7G8OVIUf0uSlJPDIAIUip3O4ACX1QpFkVGhAZyMcasYR6yGBZFmbQ9NoRIwptAeD6Y1/jnQz0ACSHkH9UtnV3AiTW++2kbRDgYspxoNMucTAxj6IHbUdU7uNcFUm6ZvdKRp7WfGzeAgg9hvrCA0Q+Inzw2KUCC5twTiuqK7lS3oO/F7VEs0ItMkiKlasEMBjKHRDojXKb3QnY8cXbTezhSTvgt/3RiDhxE+XHo6FRFkclhXcpwFsDARBjxiOgekpFEvg6DnPSgo2LD7yUR7SxOuX8jDc2PSGa9VuQpOm86VVbDNH8e6IvXlUdm9mem6HMDAzxSzcjaEe3iobQnOV4fBJT8pLUc/NW5N+68HhSwmswbjtBlHbtPDso/n5QL+ud/0NUjs68/vN9Kc9cxsk71No33C+7yxiJExMeTqqwqf4+On5Np6HzBmeQDlI43qamCUAdu8V/ElnoCJda9aP7BD/ZG572jVwo0ItwpnoTN7WbWAnYSw0nPmhdcuFqL+Y96jfQj7N/x393xLtHz+19kRufk6DvF890wSg3k6ceD5gkpbKf9SsMxH3WuWxQvv9mc6OO7lSM6agSO+nugBs13gEB8Agpj+uBQUMxB8Cge QFECfQ6m EgZsVUbv6WAk/0kh3oxsGl4IiL08abJ5zMQO363BzblAjQJ3X3Gghn/Zf4AJYTHZudqjdxBDL6ka0ZO4gQv9aJkzqprqbDEDp0mlhO1pElKPoawkL6U29vZBLMuRnBKWYPInfZRxKotpJXyOJUvkOASU/ocSl3YrzB8sZ5le3xGqx9HZTaO/vfqnfDTnm+wSc8v+tRUBJ8I0EXYORIrHx7hH7kIEzoqbUwgEqBJYDDAJ3N7bJ5taR8gwIRO+sUgwL/wFl0EKkuArZC6eZMhGJv7LXVA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Allow unmap to work with an mshare host mm. Signed-off-by: Anthony Yznaga --- 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 {