From patchwork Tue Oct 10 18:23:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13415852 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 83472CD8CAF for ; Tue, 10 Oct 2023 18:23:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 183148D00DA; Tue, 10 Oct 2023 14:23:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 096C18D0002; Tue, 10 Oct 2023 14:23:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDBF88D00DA; Tue, 10 Oct 2023 14:23:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CCCE38D0002 for ; Tue, 10 Oct 2023 14:23:25 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9D115B4C4F for ; Tue, 10 Oct 2023 18:23:25 +0000 (UTC) X-FDA: 81330374370.10.C1C1C5E Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by imf01.hostedemail.com (Postfix) with ESMTP id AA6EC40014 for ; Tue, 10 Oct 2023 18:23:23 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OO5aATj6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.48 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=1696962203; 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=pOEQ2CcJObzteNK/bC5f61eGPVhK0ZHEGgkVkSmHHteiADORJAkJeXiXtGlp+zo4MZE1b8 yGbqKqMJM0xHhhyYn19L4TmHV8bFm93ImOw3OqGYbQNwt+4T878+CQP9/mXOFM22SsoULl NAvM6igpspCwwBRM1iNxE3Gd/sNQvEU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OO5aATj6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.48 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696962203; a=rsa-sha256; cv=none; b=lBoG0J5bFtCguJFCTE4SJVf29mfyMQG3RyS7q+BTgON6d7mMnuvfI1AdwgnBHCjSnYAsZp oOWTGf4DzgG3sumTl0S6VjZq7cB1WC7hi/hvWNjzrnGC2gc1ens1qN0ZIjGyZLoQsF2ar0 NMWu/9TsJ0i0htnU1Uow7Z3Gho7Ge+0= Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-406619b53caso55636925e9.1 for ; Tue, 10 Oct 2023 11:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696962202; x=1697567002; 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=OO5aATj6ljK8XZf3lNXKL4gC6MN1BrmBo4bFr/d5hc+ByUjANMquaQmuq/yGR3u+Gj 2/wBIw912OT3QKDTVlrG2PmwifJsxU4YZO1CFym+kRWe/EDos9/HXPjgYEWXRRipRVee /RTxoZimmCsinbpM5U1+iKgDQ6Cft2N8ADLFCgLaHDmb3yiH71Y0GfKBkc3YxcScySkN 7YrxcunskoDn2Q2VMt6OqL+mu0QKkYMS+krYcqlP03DHV9iGwRZ86AzEJx5vrLU2UY4K 9I55E6NVUNooIsoJeQ6Oa2z2kLb1NB5qgkwFKKpzf2F/9eH1JeQdPYfDZhEr6P71PlrD cYnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696962202; x=1697567002; 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=gTOubGnlNFfZmTW3uHN+n9/gjg92XKtpHq/TljWqEyRpK/aJy6Mixxxb/Zc/A1gmRK wp97dQWUahbEyj7Ny7ydZ63mW/7lRgtt49R+ot9nXS52VSv2vSN5pYxFsrFQNiFQypvM z3vSAmcQwJ5AJHkfnp1zru/GuTNW2TR4746ifmJkUQia3NtSbosO8QOL6WJTmqZTdG3C BC0L6kTRehpDzTGD4eZ4A+PvIEZcFiXyuG5Q5cP6lWBeuNndoM2ycUcGFu4wyk7LaeSO lvZ9hm2Y57JzPX+LI0asrnV243034TTFUwA3ng/PpACoqsvrpp0Dt4mrhogtSjcFav5O kZWQ== X-Gm-Message-State: AOJu0YxspWMrVkgIokagoLqv5LcWfQ90FAi4WZGwSjLGSzS/i4oIuJHJ 0dAv2WlWehOKNu5+7a8cg3xmZmNaaMQ= X-Google-Smtp-Source: AGHT+IFeSuY+leWpp9QNGQShZwfaneWw9EVs9ggK3b4usECxkab1t01uZ2nxvXac8yGuffFvBzg59A== X-Received: by 2002:a05:600c:2298:b0:406:513d:7373 with SMTP id 24-20020a05600c229800b00406513d7373mr17049867wmf.11.1696962201906; Tue, 10 Oct 2023 11:23:21 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id j16-20020a5d6190000000b003217cbab88bsm13225312wru.16.2023.10.10.11.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 11:23:20 -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 v3 3/5] mm: make vma_merge() and split_vma() internal Date: Tue, 10 Oct 2023 19:23:06 +0100 Message-ID: <188659ab3a8efc58a26fbd64b735ebbb88a65aa0.1696929425.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: AA6EC40014 X-Stat-Signature: xjwtzsfu7dc9wzdgiu6t4ohpbt8pdtkr X-Rspam-User: X-HE-Tag: 1696962203-648503 X-HE-Meta: U2FsdGVkX1+tEU7tOnBZ0B8rLdHQYONTI+nwq392+LMR75+qX+AJBGLh69yG0QQcKcbSGs6XFqvc5QvA3BvKxtfhxjupqUhslT7SyQ/rbnC7FNWUnswl7nqXghSq2Vg0b9bJ2+Rp73gdIMOgq1iJw3n+/3KUEJCiTtTB7+YkyCZo9Cup8Ww4HaKkU8DD2RiZEW/w4+b6Um4mPmnS7Cdhl3g7ULZGT3pbOGPNMCe/3fS05g7oqvZYLxSHhna4iI4Mv/EGL+Fi2Kv4FUv80S3EpYdsA1YurXKUiYv+DSAv28KWZNBa8wkbyyzQySBL7z6cmcBjWUkAQT2wIsMAlJW9CDBZVNL2qQa+ztjTj/zjMrt+5fhYrcTABf0+RpisvwXGFCC7nXZ5j1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s6YrOkzYtpmSn/7fX1qY475q5GKtze2zRAmNs5Ky8NvoIkNA34A= 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;