From patchwork Sun Oct 8 20:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13412796 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 CB76EE95A67 for ; Sun, 8 Oct 2023 20:23:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 471186B0165; Sun, 8 Oct 2023 16:23:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 421F36B0168; Sun, 8 Oct 2023 16:23:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24C366B016B; Sun, 8 Oct 2023 16:23:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 133DC6B0165 for ; Sun, 8 Oct 2023 16:23:27 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E59111A01E6 for ; Sun, 8 Oct 2023 20:23:26 +0000 (UTC) X-FDA: 81323419212.02.87B5AD8 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf01.hostedemail.com (Postfix) with ESMTP id 230AE4000B for ; Sun, 8 Oct 2023 20:23:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HijVL4sI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.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=1696796605; 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=xj76wJ9Zoom8wv+//ugduIlfQcCX14rBwnZA3eUs6cY=; b=Dr68HurjR3tWi1iCcSRsK2DdwCVbXHQyeaMM4SGZlDi3AqWu+gimy04POAv/tJRsptswzb lxbeq8bZUDfu+YCuE4dFBuji5Kw2AF8UAtgBIavfCteE1WBPbwUN7gBxprJGSEpN4TgU0p MdHtB0G9ZD4oPY+EjVHuSJsAUurv86A= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HijVL4sI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.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=1696796605; a=rsa-sha256; cv=none; b=4OGkY8ly7aMm/ICWJ1zOQ3O06KjxX71Mh/yWWGBmZk9mej8KyHmzvqa9+n7T1eu+KyfPTq Jx1LAqfq46BaHnInayraMFKQjgw+Bl+9YuBcE8Z+iO3HKkxwlVlOJwePIVMb4KlZgV3e31 aoh+iQO6HiJlE0ZW55wFw/uObtMKgcM= Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-406618d0992so37875535e9.0 for ; Sun, 08 Oct 2023 13:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696796603; x=1697401403; 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=xj76wJ9Zoom8wv+//ugduIlfQcCX14rBwnZA3eUs6cY=; b=HijVL4sIN9WRs5aBfv8NqC8y/ZflsVc7lnge+caI2Gy1mjtZielkYm2k69fLCpQHnl JKkdgQjl/JXxPF178YdKE8qc4oNgZ5wPN7WO/tLd5tz4vpQbvO/wCWy/rZG1gr1e4MZE ehAPF8YH2IN8OjZdFjEoaJwZ2QKSUxJ2zboMZxjTvpQu67T1ee1DhzxWKZzaYJ79vfMU CIye/Dod3ZGTopBQKuIHVM5tYY25TaxBfoRGvUbKiNxcMFfIMNVE9JZASI4IWtkGt7xS ksQLnpWYc5qBD62HHcf4N44GBTMPA1JGuG3JgbeaX8pXNrEMLG+tTAEcx6EJ6JH4tk5Y geNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696796603; x=1697401403; 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=xj76wJ9Zoom8wv+//ugduIlfQcCX14rBwnZA3eUs6cY=; b=sdvvYDMPFB0DhM8G8sWeKW1pfpDiTgc/Xe8p8UxwDA3XE5y34MXJWig8Gf7dUFBgDZ BHeY50GVL4SlA4QdHKW+kXaWlT4b/tTCXjTS1yL/0n6LpXflqA29IvjTplV+9K4gIzrb OMfHyztTVVTHPUsYYwttZZ7pp+qt51krrDggFd2OMd3wn4N5Rx5w/LhPiYvI2wgaAG9X HuLdb6IP3NlH70TGos4E3MFch+28zqezcSr7da85jnEDN57d/7pbBd1GYhcXwLZtoFwg 0nlEdXU33qII+MW73Yk+UMQPkv/Ny+H5B9vHzJ1/19Iw7WdIyfCp0Eon22FPD5pU7OIL Lr8A== X-Gm-Message-State: AOJu0Ywq8uwjFXAPQI0cb4h1mdkpLxzYNi9GxO4qCZ/mmP14sRivR1X8 tfjv5gP+TcCnm8xVO+TlJZQBwTfv8g0= X-Google-Smtp-Source: AGHT+IG4F9Wkca1FesebOtAogwJp1fVsExkOmC7if9rq1cZTVc9/EQiXNYXRnEH6/EOgRmTVDlQ1tw== X-Received: by 2002:a05:600c:2b0e:b0:406:848f:8711 with SMTP id y14-20020a05600c2b0e00b00406848f8711mr11974165wme.21.1696796602890; Sun, 08 Oct 2023 13:23:22 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id c5-20020a05600c0ac500b0040586360a36sm11474879wmr.17.2023.10.08.13.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 13:23:21 -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 2/4] mm: make vma_merge() and split_vma() internal Date: Sun, 8 Oct 2023 21:23:14 +0100 Message-ID: <6237f46d751d5dca385242a92c09169ad4d277ee.1696795837.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 230AE4000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ppfucuqiz884cz63o59r7xhzmex5mdgd X-HE-Tag: 1696796604-499379 X-HE-Meta: U2FsdGVkX18KIzT1DbmNRVHz+y7b0+F9137j69l+SiVSwwq5H4blV3XwS7WuEXAOV4nDZ+ol7NzHL7GQn8I9POXEuDpIE9T4sce3ZW26DBEDs6Yof7RpMlo9qNTGYlhVTrdcf3Li07pVOKfwC3eP1swrI0loL69BRfqi6TLLrRcZR6D7JNLMa0Of8r4CAqInjETyvchQ4ICDG6ODZOwMzGI4FaYbnYwZXyWXKf1jp84C+kSu4ybld1iWVDNTu/C0yuZ39pbyJmCay7Ktkw4joWkMM3Wa/u/9XuXHvHSnblop/qC3DHJF2Tl5/VYuW5c8JYA9sJI9e49OIVQRqMyEMeMiPdhZrFfugGhFcCmZsrvLWsNXPG3K/Ns/Z6P70mpNXUG1Sf6yFT2nZtmrX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iR1rVcEicDSW+cpGPnLkNQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now the vma_merge()/split_vma() pattern has been abstracted, we use it entirely internally within mm/mmap.c, so make the function static. We also no longer need vma_merge() anywhere else except mm/mremap.c, so make it internal. In addition, the split_vma() nommu variant also need not be exported. Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka --- 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 c069813f215f..6aa532682094 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 8c21171b431f..58d71f84e917 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;