Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2133908rdb; Mon, 9 Oct 2023 13:54:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMze7drVtrh0yMiwkwVCiTPyGNuJjdC/9Ov2CaweJ/TOxVtJAIieqrewB5NzR/bQowpnL9 X-Received: by 2002:a05:6830:1e28:b0:6bb:1c30:6f3c with SMTP id t8-20020a0568301e2800b006bb1c306f3cmr15922099otr.0.1696884875363; Mon, 09 Oct 2023 13:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696884875; cv=none; d=google.com; s=arc-20160816; b=Ojq5/Ni6lHLzTv6AeWFdLZqZUD7qmGTGv5DJRAqsQhh/0s5prPG/ooojBh5PQzJYI0 2yXAV/j7i+Hbf/kfPd9Le3yGFBIeCRThUuHFwnPqgztNgMKFhkeJNQyLe2sIrz6pDz/m CsWCWDlRteQ2cSUzrdAnL/oUPui6IxvQHivs0CYndFYoKdEysDDEplUN3MR4gFkSuq36 wQB3hcrYknBOSZV7tEAOxoINIKZbrfTY9Hleu/egskie1KV38xCNAbz4/BCARC0YGPFu 0GZnk8d1478GbzwkPTX0ANbXnFH4wcjapRbOPJZIJ5gmmy3kOP1tdze2PcOEiwShyfHp CYCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TNmdoeRWtzhEBIdrRfXv8hL/K0SAgSJWqJyZUiMnE00=; fh=t0e8hB1yztay3y0yczBzLM0YwGerH6s+dnvwo2ZuqJs=; b=ZO9JBTgIShpfTg9KiSxkPnqXTLG7kbEJbRtf+C4oum03d9nAnul22OK+MVeF+7PBSe P+0909SNkAv378vD989c46fHz+jC6tF090wuBtlAbiNpmVywM56DVy9BIMy8rrrJNLNC t2xUaXzSTuOYhpomWU3Nna8tHJEFlv36T+FT1nSHRXKtQI+Q9KZojtYrzEwod657xoOQ V/fMtqvonUBeDuaoC8ohamK520Pkl4hs7GcEYE09zYdz96K+Iz2ihxj1R+zuojn8K2Tq mEYKzsPQlpT7jnfJGGw9Lxb8iOPLOGxZX6N92zVFJkdDrBKqE/6P3SDcoDEKZROXIxHM 3+Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EpqjRpfy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y24-20020a63fa18000000b005787a30e1b7si10065476pgh.369.2023.10.09.13.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:54:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EpqjRpfy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 031968116E4A; Mon, 9 Oct 2023 13:54:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378089AbjJIUyD (ORCPT + 99 others); Mon, 9 Oct 2023 16:54:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378102AbjJIUxm (ORCPT ); Mon, 9 Oct 2023 16:53:42 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D67BCF; Mon, 9 Oct 2023 13:53:39 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3232be274a0so3649600f8f.1; Mon, 09 Oct 2023 13:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696884817; x=1697489617; darn=vger.kernel.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=EpqjRpfyiiX7wHKgfKsbcl2biJq1/1RXqVPajYmQau6r/EuHInFB2i4eqyIbY2kF1N S+DJCpIpDjZtVfhoi0SLXY30mR6a7cL/1dmNRbyOcuusxeZ5eEUkM5E1HwhpksOMdZQ0 Q3pwjAUuFOaqbfaGkmEkfb7wvndJ7EHAshyDuF8HKUyfS6jp+MerjJfbln1FH6iNz/88 tqt9QB0NnQRNpNsdxOOcd+BupfRUdBiO1QqkaRoMciMBGMqGpBSneTeaH+5mQEvrCn4b LvVsplgV3DzNZu0zyC6dNcZ8tYDYBm9mMDEIqY5OpgVJBrZI9tFcrpWS2MI5MSLcS5SH RW/Q== 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=Jgw59/3+K5Qvx7s722bcTnNMs6cB8aY8x7sbPnbtSRSaqPiDu80JGxc2MkudIEveZa 7UPZtRXpw/mU2tCvb7kYfR1qsLG18TY8yPN237Ej+1+jqED4b4QTSPXHZFQsbFbBAVkY UYU44RBl38gF70BIOcPHXF5VKgC6LWlNs/zImGlEbV+atfDdyay44GpnuFrO+yN5+yw5 9PAURAxdceL4gxsRJwNiiy72qa4JMwsXog/zVDYtYuhtH2V1qHWPxTBn+O4YMls50/EF t+dnAd+MESglg5UZiOYwxMLwUHatI3TNXYqzSDmKzaB8NsqWjabejXJlbL+2DgaOHDfL krMA== X-Gm-Message-State: AOJu0Yw5gN47PLJgl+0qdnoZOd1S+w6ARGi02QV59bEzk0+/UCKX9dtL 05Hq8nwJRE48JLt9hpp5l6E= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:54:32 -0700 (PDT) X-Spam-Level: ** 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; -- 2.42.0