From patchwork Mon Oct 9 20:53:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13414431 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 AC7B7CD613A for ; Mon, 9 Oct 2023 20:53:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 786178D0090; Mon, 9 Oct 2023 16:53:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 732AB8D0089; Mon, 9 Oct 2023 16:53:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AC6D8D0090; Mon, 9 Oct 2023 16:53:41 -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 4866E8D0089 for ; Mon, 9 Oct 2023 16:53:41 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1AF241402FE for ; Mon, 9 Oct 2023 20:53:41 +0000 (UTC) X-FDA: 81327124242.03.95C4146 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf05.hostedemail.com (Postfix) with ESMTP id 43582100018 for ; Mon, 9 Oct 2023 20:53:38 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Am52EhsE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.221.42 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=1696884819; 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=TNmdoeRWtzhEBIdrRfXv8hL/K0SAgSJWqJyZUiMnE00=; b=U70YFR1Z87fErOemcSyKIWvgm6fn+4nsejE4dY166h0vDOsUwp81ajnVfF46bQq4rS8/w3 5SBrzqPK+QWpmLQ/sTd3hQ/SX0gZQ38sdW9DCO1OunZgp1SCw2b3GDTZAZ44Q4+paJ76Io mY7z+q28I27veGMRhHQTKHIfbLZZszA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Am52EhsE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696884819; a=rsa-sha256; cv=none; b=uQ/vIwgdujAL+mpSFqs0EZ2ttXyROqogCswghB9/jwmzrKrYMx7uaNf0cl/g0CtXnyQxYE TP6n4nY55VfzZmrVnaJ6OaeTCP4fnps7fSWuearzOWw8Y/uiwt/lnDo8sa2YDdHABeSSWy x3eZzIOZyazSOIUy7vQwQVFJNEnq9uo= Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-32003aae100so3661800f8f.0 for ; Mon, 09 Oct 2023 13:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696884817; x=1697489617; 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=TNmdoeRWtzhEBIdrRfXv8hL/K0SAgSJWqJyZUiMnE00=; b=Am52EhsEjr/GrcQMMkJNf/pYEzi5thVH8hrUpyPTGD5geSEq0Qi5cQZPVJamwyRkZ1 W8ZwtRY9pFMTYCJ8z1VViJUI0LdCc2FpEbM7cqkkMbpnvFM2vUVrppAf6fX8mMd1qhE5 0ptSk4z2oWG4/wtcMDMj1BOGsXimGBkBOBs+P9XzN8tc8VadEJCRs6jvLI/Rl2VSZ2pF h9NmoOlh0cf6t2JyNMDi7TAKJgRiy1bpX0pl34qmBcLlIC/HiKPyeTgPxNJlZaBt69I3 QSofNHo0jDUb73XN0BH8XjX6ZBI7S8u6hXkXCP99+i6Vv7p4XFsaLO4i3yLPZ3aAd6Ye Sikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696884817; x=1697489617; 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=TNmdoeRWtzhEBIdrRfXv8hL/K0SAgSJWqJyZUiMnE00=; b=eAidOqR5U2QXzqERQfVZT1MaYSWuiU9bSdf1pDCdBIECSA2bxj+u7q1OpW+tokrIAB M2RC2vh/bq5CZ/FMMHOKWQNM6GJGo+/gUVJ+3QOj8koncJAWtExN34Td/qjajJGc2Wwe 34SPXV2HyNWV2Xzq+MfLQG46WFjywgMwuQVDjqB2D8gHt9v6vnqaxlnuKoT8MYQ7KoL3 bYWQMfiy5salp4CDNZA1FXAG51JTOCKjpBIm6x8QLTDGeqFtVNfT0RA5LcYo3IryUZHR UsW+Qo4oceNQ6E4Xw2aCFr4FOUOP3LFmQ74mKe7RKD/i5hImSLkkt1p7u64wwdNbJ6bA yLVA== X-Gm-Message-State: AOJu0YxxbHHkU0QPHQN0VZbIQlFn8/Ao486qGGuzAQ6MjtvECjKfHvCD byAH9ZA6VBcdJ1muzL8fKFT0yYsqbKM= X-Google-Smtp-Source: AGHT+IGxaxbfOsmbWfYeIketHcaygFp0L6cqjHa1Rm6inszqpIbIyR7FdF/1P3t2wIMfyeWkX0LuMQ== X-Received: by 2002:a05:6000:3c3:b0:32c:d29c:2f77 with SMTP id b3-20020a05600003c300b0032cd29c2f77mr40326wrg.1.1696884817261; Mon, 09 Oct 2023 13:53:37 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id l2-20020a5d4802000000b0031fe0576460sm10578130wrq.11.2023.10.09.13.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:53:36 -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 v2 3/5] mm: make vma_merge() and split_vma() internal Date: Mon, 9 Oct 2023 21:53:18 +0100 Message-ID: <31d2c79f7a3bca03d4a4c95e98d9a27cb1f99bf1.1696884493.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hok9s47pfjzd84xnyd5z57443b5ygamj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 43582100018 X-HE-Tag: 1696884818-567262 X-HE-Meta: U2FsdGVkX19SlmEVeXDjsBje2sv8qAJdydQ5xse0ns6lch9hNM1QPpZJL+NF1Bt/p45dzq/NROuPX95z9xYrzarGVij80AKVzeTbfzbfR3MbEjs974g4I3GRgE2YcpWBhfjBby3SzAZ5DPy9VTNWDPgLV4md1RAiutWRH+ufA6UzXyiukMiHca1AKRdmomqFeuoRqLPce+0RrSj3u8uBh67gk5oSlKdsvMd8p0pq9aoRDp6Am2oGr0Hc82JTkefU3eVGqa7o8EjwqXr+uA4we259EPokArJ3VrlWt6ZltQGIWw5e4YHCREkQEEEfSiumhQp2CUMT3P5fc/2xYKUue9UgRUvXKnfBaGN2H+DEn+M22clpzc3duhsOVO+/pb1xAjteey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tMcqK1IvEIEEZ6aRgyLTWQaI4lBw3NSbE6Q= 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 22d968affc07..17c0dcfb1527 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;