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: 150905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp57737vqb; Tue, 10 Oct 2023 11:24:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoJhh6vz9WRX2E8DHpzepNnsyA04ffsQPalcuoSUTf5LdGpg7toLpLXh1kRNl835Zr1PiU X-Received: by 2002:a92:dacc:0:b0:34f:b824:5844 with SMTP id o12-20020a92dacc000000b0034fb8245844mr18419875ilq.3.1696962264748; Tue, 10 Oct 2023 11:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696962264; cv=none; d=google.com; s=arc-20160816; b=Q2N2JJ84KRXzBojv38cYiKgf72WoE9GFIDVdVMxa5jpqpHVe8QEE4vY0JdBzJCxd5X syeLUTbOje4g4gb/lO/nrK2+Ac851eqa25SYgF0OpVgy43EnEU+PSh9yOjzHNEiDEBWf uB1DNWmg09pjWpb25HS3oRVUOZhAWHQGoWPZVnCoNmihMfpxEEoI8rF146h3DI5bR+qY gmXLhyolR1AEkzQvXker+WeJCHmNKQQq6JzpqF3ViANhf1J8WXIpQPyJEw3wHpw22kBG r94HC6fCoYZ96C4brFvnbxqOTAybEOLIkYqFlo7xrQuRBaSHBMxQofNhXBpRUu/l5I9+ FUhw== 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=xYZtGWQnk+qTSD3PTRtexwtcvMKng8mprQW/gWAvlII=; fh=t0e8hB1yztay3y0yczBzLM0YwGerH6s+dnvwo2ZuqJs=; b=fCs5/GMzoIfPJKqucnGvp4ZMRnL6KTDvXpu+5O8dMcO5oabjfO9j1cKqlAtcHDBt4h z/Q1TZAJB/9dKMXMRQ2YkMHS55lAEQ4syq6GSdqD5PEXxX8KjVFNcsHl/7zvQYvnX5ox rUe94SWa/Mmm8Rd2mTCFBZCv/qgkQd7fpwOhCUY2bTs6ggZt3xstP89JfeCQauN34AP5 DRrMRiqCiKhQLCuze0J4MGtutTK4DmLwPTt3DrnRnPDbsU+lfs22MhKi6SbctL3a7sQP CqPcFChAseIr7y2PAqYl5/Tn6teeNc9oWO6gsnA66hAEwQiUxTdXyP0YM3X1TM1mvtpD g9Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Do005hS3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r20-20020a6560d4000000b0055391572218si11912523pgv.26.2023.10.10.11.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 11:24:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Do005hS3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id F110F8041FC8; Tue, 10 Oct 2023 11:24:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343588AbjJJSXj (ORCPT + 19 others); Tue, 10 Oct 2023 14:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232771AbjJJSXZ (ORCPT ); Tue, 10 Oct 2023 14:23:25 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3E8B4; Tue, 10 Oct 2023 11:23:23 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-406619b53caso55636875e9.1; 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=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=xYZtGWQnk+qTSD3PTRtexwtcvMKng8mprQW/gWAvlII=; b=Do005hS3MBtjlRP/eePtZYM2fbI8oEUW8eCM2L5plqHtFOAExM8jV+oKRZrqUREm9d n+PZoZSVoiELbAEpS+t1Dw/OdxMX/c1r/A+usd7GEJY0KWy7dtPTBK9ZDWNhdUK7Qyi/ dP4PjWpi7iM+Z1i/jDHLcpqxQ6f2zqK10uDCB6AaKckLlZw4w6rGskOPoE2d9dXpZlss S+hajuSXmL/h4m335de8iB/Tpv4Emj8Qi/dEb3qiMySf7hHcx+TAH5ZkWET8jtlJFPxc D/zKdFRk/OvBp2lTooE6094QvFGfi0lbO2zCkrtZ+c6yPahEWq5J9iNqsWFrDfi+6Seo O+sw== 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=iv8p8ehGTJOdz8L8TGmcGr9+BVfVCdDnYs9Wt1tzOLdiwjQF+7gpya+IcP++qg0LB7 07XE5SEMN3FpoWAwQN/gOzq7lYZqHc7gWXGAdrD66+3rtQFmK0yfgMZbqMlyaQgkfits z00Xuyc5PRHB5XtfjFGUtwvlMWIEjKL/ElKfTjXIGrRRm4ddYp792iROTmmPC6UQ2IY6 NcKX2MAoDQbXGyMPuncSC8ZrvjiPeC0c73u9mO6b4Z1vVvuySi5VPYOFgY/CU9hegAZ5 0z4I/COmNJjF85F3TG1mVCugFy9mL2iLlGhmbCn/EcLF4u7vEU5d8u+K3e4ZTCqQTQ6B Zwjw== X-Gm-Message-State: AOJu0YyMwzyRm6mE3w1rsN15VMIal6RuxGuRKLVbJvgX70fVj0IQhsDl OK7EyJ+jOndhWuXNxxhvK5U= 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-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 11:24:18 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779393903795022611 X-GMAIL-MSGID: 1779393903795022611 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;