From patchwork Wed Oct 11 17:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13417646 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 4E4F9CDB46B for ; Wed, 11 Oct 2023 17:04:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAF328D00CF; Wed, 11 Oct 2023 13:04:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5E918D0050; Wed, 11 Oct 2023 13:04:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFED08D00CF; Wed, 11 Oct 2023 13:04:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BDA628D0050 for ; Wed, 11 Oct 2023 13:04:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 94839160363 for ; Wed, 11 Oct 2023 17:04:42 +0000 (UTC) X-FDA: 81333804804.02.0EFB5C0 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf27.hostedemail.com (Postfix) with ESMTP id 92AE340018 for ; Wed, 11 Oct 2023 17:04:40 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XVgdC9aK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697043880; 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=xYZtGWQnk+qTSD3PTRtexwtcvMKng8mprQW/gWAvlII=; b=GAU93HqsYIpLiVpwaSK+T31e5O/ZS8cTQUfXlQjVJrl5p7UyLOYsz+Otw3OHGiuRbtegLx EU+erBEzATCscEjsWO5CvrZf+WHjXnWJeJEMr/D+j06UWwGOsMpsTOyHergkjYc9VDTBvA OSo6Zj9n64qeVLpQ3yuoCQtRa+MJs4E= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XVgdC9aK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697043880; a=rsa-sha256; cv=none; b=xJw/rf7DMTGmuaO5+afNtK0K4y/m8yY7splaATVTJ2HTMVezZ5wO4ymhW0yTM3HPvm3Zrz /04D/cEGjfKR1yWcAiHv+qBziCcBNOvHTMMVgGtYuMU7+dTMSX3N1BY373UUPdWq45Sysv Rijaox3I2bo/NKDnhL4tsL/N1dZzKlM= Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-405505b07dfso7908215e9.0 for ; Wed, 11 Oct 2023 10:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697043879; x=1697648679; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xYZtGWQnk+qTSD3PTRtexwtcvMKng8mprQW/gWAvlII=; b=XVgdC9aKEnHVJRi5hM+KV37DwrQDajYrSMtyAacK7Ai0AZ5WIGVXQKjAhej9tPp6To H5yJ/hI7lPHhJrthp7K9c0uYR8d3z0vOVPA/hnDf+1+eHJHk548m1yeVekmu3S9TTchI Uq0q6nOkMkB1TwsmvDb3sfKIO9ov5qqH6gixcIg2gdMehFoCM88aqOAVALXFwfeHnR// +ETS1PVgdP90eJjkR0po+ImrhRWSikbP/j6L1pJbHGSxtJ/L7Z16Yv3J4DWPGkBexM8F LWW648CflF7NRh8+rtnHspEU9tPN+VAWChUjGPSc8Yv9Hulzbj7E0Cb+DS7m32L3XH8M ZerA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697043879; x=1697648679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xYZtGWQnk+qTSD3PTRtexwtcvMKng8mprQW/gWAvlII=; b=MY3tZrgnHgnr6eRxFTFubp5FZIJhMxaNkJWIEOM6M37B2AHTSXSIxCTea/LLuCE7EY 8Urke+aejaDYQBxJFUDvXzMoPGJIIhbSSWYY+Wgf87xA2Wt9tRh6Pn4BKHDkRwmIBBOk x8d4diekOtKtAjdreObhiwIndT3kUnCyf8uBvXIuQuOc8F74QIsxUKyvNQcbOqMtXsaT 0ss6fc6QP/VQboSKTPYM4OSwwrez1Ms95nEnNVVq2bqXgktOYXIsLbzWQal/GMfUbKcD SIZjth1h2rzykF4rhSSFdoJhIlBsgu+TXis8YFus9jvZyCbEaFUhgwKISrDekkVPEUuI TtZA== X-Gm-Message-State: AOJu0Yx1wmqfYYgUddqL/Hlpevw7fYZKek8xaOSano2Hw1sKp4x1edxv FPtHKyxKJh9D5T2XVxOYHAyOg82VdRM= X-Google-Smtp-Source: AGHT+IEaxDcfzdWylWTP/iaHYGj0U8wM+RJx9S2LL73muVEhfzeVRfiR500cRLgmK2tkV/LbvoV7OQ== X-Received: by 2002:a05:600c:205a:b0:405:784a:d53e with SMTP id p26-20020a05600c205a00b00405784ad53emr14090015wmg.20.1697043878737; Wed, 11 Oct 2023 10:04:38 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id y19-20020a05600c20d300b004075b3ce03asm3834495wmm.6.2023.10.11.10.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 10:04:37 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Alexander Viro , Christian Brauner Cc: "=Liam R . Howlett" , Vlastimil Babka , linux-fsdevel@vger.kernel.org, Lorenzo Stoakes Subject: [PATCH v4 3/5] mm: make vma_merge() and split_vma() internal Date: Wed, 11 Oct 2023 18:04:29 +0100 Message-ID: <405f2be10e20c4e9fbcc9fe6b2dfea105f6642e0.1697043508.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 92AE340018 X-Stat-Signature: a9ccx6xr9p916abcte6xms5qqjzq4y7z X-Rspam-User: X-HE-Tag: 1697043880-698466 X-HE-Meta: U2FsdGVkX19/xzTCC6iXWm05yZhYhTwlZb/lIIHx0XMwZONqNyn/ivoJdunuzUwheyQsR1S95epdVsrUAYEG52qadpbX5hEkUF2ldv0BlrlfptIzspAMbWl9/2ARE8wnKiHBhEAgdiauugin94gyL6E61Jl86UtBPaXbtBKrTayfLT+V0syS8hE+078bBT/0vDjGk1gpZrA3/MAVXFO4Tcq8NPZet5cMFZePF9ythK3MxraCOSLbrfQLY17K10eMSX3oTfuS2rnROrcnH9OTnP9TgLXP5S8E+UPCn5jDkJefFHN83gQaudRNlRk+7KO6h5iVMMu/iU0u35+nR7Pfv8kZPh6NiX8AuRsllT7bS8cYufo4rhZrUsmZ7dNahkryJkanbDNFOxrOmLTZ0Rq76zLbGufKanNZFKYBPF5aZbP9haU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h/Tw11Ss6ZnziTz93G6iEGBbJ9puSK3Qj2GMUJXM9pGC8GOC+XGHVZ/BCTNI+mhPcUJzb4VhjOgZRZsMi8u/Q+tqc065SB86/YY7/Y+tsqJJ 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: Now the common pattern of - attempting a merge via vma_merge() and should this fail splitting VMAs via split_vma() - has been abstracted, the former can be placed into mm/internal.h and the latter made static. In addition, the split_vma() nommu variant also need not be exported. Reviewed-by: Vlastimil Babka Signed-off-by: Lorenzo Stoakes --- include/linux/mm.h | 9 --------- mm/internal.h | 9 +++++++++ mm/mmap.c | 8 ++++---- mm/nommu.c | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 83ee1f35febe..74d7547ffb70 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3237,16 +3237,7 @@ extern int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, struct vm_area_struct *next); extern int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff); -extern struct vm_area_struct *vma_merge(struct vma_iterator *vmi, - struct mm_struct *, struct vm_area_struct *prev, unsigned long addr, - unsigned long end, unsigned long vm_flags, struct anon_vma *, - struct file *, pgoff_t, struct mempolicy *, struct vm_userfaultfd_ctx, - struct anon_vma_name *); extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *); -extern int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *, - unsigned long addr, int new_below); -extern int split_vma(struct vma_iterator *vmi, struct vm_area_struct *, - unsigned long addr, int new_below); extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *); extern void unlink_file_vma(struct vm_area_struct *); extern struct vm_area_struct *copy_vma(struct vm_area_struct **, diff --git a/mm/internal.h b/mm/internal.h index 3a72975425bb..ddaeb9f2d9d7 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1011,6 +1011,15 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, unsigned int flags); +/* + * mm/mmap.c + */ +struct vm_area_struct *vma_merge(struct vma_iterator *vmi, + struct mm_struct *, struct vm_area_struct *prev, unsigned long addr, + unsigned long end, unsigned long vm_flags, struct anon_vma *, + struct file *, pgoff_t, struct mempolicy *, struct vm_userfaultfd_ctx, + struct anon_vma_name *); + enum { /* mark page accessed */ FOLL_TOUCH = 1 << 16, diff --git a/mm/mmap.c b/mm/mmap.c index bca685820763..a516f2412f79 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2346,8 +2346,8 @@ static void unmap_region(struct mm_struct *mm, struct ma_state *mas, * has already been checked or doesn't make sense to fail. * VMA Iterator will point to the end VMA. */ -int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long addr, int new_below) +static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, + unsigned long addr, int new_below) { struct vma_prepare vp; struct vm_area_struct *new; @@ -2428,8 +2428,8 @@ int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, * Split a vma into two pieces at address 'addr', a new vma is allocated * either for the first part or the tail. */ -int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long addr, int new_below) +static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, + unsigned long addr, int new_below) { if (vma->vm_mm->map_count >= sysctl_max_map_count) return -ENOMEM; diff --git a/mm/nommu.c b/mm/nommu.c index f9553579389b..fc4afe924ad5 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1305,8 +1305,8 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg) * split a vma into two pieces at address 'addr', a new vma is allocated either * for the first part or the tail. */ -int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long addr, int new_below) +static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, + unsigned long addr, int new_below) { struct vm_area_struct *new; struct vm_region *region;