From patchwork Wed Oct 11 17:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 151482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp686073vqb; Wed, 11 Oct 2023 10:05:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqCnBxRH7Kl6PoLH9E9ib2iK935lIpmp3iqiDcDWdrUGMwMNiv9SVgFfuzNZwbtN0PcGvw X-Received: by 2002:a17:90b:3b50:b0:27d:1593:2b0b with SMTP id ot16-20020a17090b3b5000b0027d15932b0bmr776840pjb.0.1697043956561; Wed, 11 Oct 2023 10:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697043956; cv=none; d=google.com; s=arc-20160816; b=bXEGfvXg6nqyUoKSVdPtZR56NVXPPyCqy9aAgJTGOpFcy8DAoLvwtHyMZqXjFv1ytu 69TAHUhsy/cglOIX0ct7UToOmr+guhlePLAdTSIkk5j9MCgcXZqL/doAM+SibLC2UW8k 2DOyP1kqbuomgkGf33sNQ61eeqmT9EL61ipWDOMdUpcLFbwMKxBqUVLAnPl2PcGIA+05 sZ55Y8mY8MBzzNOeKPQLw/jLq9F6eHn8dW+nZQFOsXlPxdNd9PaZiuxJGmlgU3WtYEhF VgR47XYpv/j4iLy8mhVq7DXlxLJzdYkhC/YgYm1/BqHTVC5bCyDSLu7Vna4qayVuDajb 4lpw== 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=alWMiTm37/Nq5mm+iSvacSBCvEbi6ZmFenXDfmLTyK28vMMV9f7umfKuCiOCDp7P06 JGi7DnhdzmjsKfCCGwST6BYDmlTBSI/5PLyxwUiHY3wN+Cluf2DIZqifr3BQCAA+S5iK coXhaFPaJKBFbn/xK5uFxwX+qi57hg3kew3APk8DmYiRxi3QD/N1/1mPouDtBBX3N+rU fUa8bcLUOY69wCmpc5rCk1nMhzFvLZ0v+lg23BBwLhJL5OOPzQYRVN2JMYaSi8SK+ORZ SHg30bXLaTeccGzfGSPU1+Lmc9nf0NJCuS7+re+UoQlfjBXDY0RqnjxCaTBUGzmqp7t0 gF3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=I1WhaD4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id r14-20020a17090a454e00b0027b4d1ee2c6si226263pjm.144.2023.10.11.10.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 10:05:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=I1WhaD4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 C8BF58135E1C; Wed, 11 Oct 2023 10:05:12 -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 S1376305AbjJKREy (ORCPT + 18 others); Wed, 11 Oct 2023 13:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232080AbjJKREm (ORCPT ); Wed, 11 Oct 2023 13:04:42 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 677B8CF; Wed, 11 Oct 2023 10:04:40 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40675f06f1fso7771745e9.1; Wed, 11 Oct 2023 10:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697043879; x=1697648679; 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=I1WhaD4s3NJDNYSqJmiPIm+YQs67lFI6euBQl9HhI3eN0CxnWQPBNQ7TmcNMzRom2s CZD7uJHzFRqYoiCl1iBZncP4Fkbw9DatOa14SUGspBwHaLfuNlrluvj6qHbmXHYQSrJW bwo+2jR1lvcajSNX4r6VaW/ME9ykYMQvF1bT/9gWTPeukleOA/Vf7I751MUYDPDEXL+U EZtT8ODg7Si+X84duPZGnWr8Nl/e2ZND5zbL4s1KTZdiMpn58J1ZOutBO7A5eat7FNhp /UyfroZgFVUGEDuat1F7vJyc6+qDHLzVwAE7WUd9tbcSYyz3EsqpBOl23g811N+f/LNM sMNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697043879; x=1697648679; 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=dJ0cmQEK1ynK5wuDD9P4v2omQLP2+5Ysae7nqhTuh2AFcUsKscZ6gJXQSJcpS1P71i 0ugOhEhuTOzzyme+2HUgHAtzyaQ7hKhYW4r1joB8HhXZ9XZOu+iUErLlyaRPCxxVzEI5 Rrw2Ce6jQ17kImm00t9PsImtYRHxUZj6rCDbGx6tx7BOB3qlh/goqdE5UXmqPV1ic/vV J+mf9v0Ye3SmhRqWpZfAUASgxAg16FEDOdJx5vCGGXQ+GtAYav1mCYXxAe6kapk6Y6t5 jbVDwZM6zWHbEHOtE7BYEI+eztbDfxaAKn6bZjMQIxp5D4W4meLJteQ0f4OHdsG+yWuW 5pRQ== X-Gm-Message-State: AOJu0Yz7KjyfMM3ngl6OzUPWrSVgRx1oRkjgNvsOYGCz8yPAlKHDYjCa aB13wFH5cVre8bFFNsE9BsM= X-Received: by 2002:a05:600c:205a:b0:405:784a:d53e with SMTP id p26-20020a05600c205a00b00405784ad53emr14090015wmg.20.1697043878737; Wed, 11 Oct 2023 10:04:38 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id y19-20020a05600c20d300b004075b3ce03asm3834495wmm.6.2023.10.11.10.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 10:04:37 -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 v4 3/5] mm: make vma_merge() and split_vma() internal Date: Wed, 11 Oct 2023 18:04:29 +0100 Message-ID: <405f2be10e20c4e9fbcc9fe6b2dfea105f6642e0.1697043508.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]); Wed, 11 Oct 2023 10:05:12 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779479563574149345 X-GMAIL-MSGID: 1779479563574149345 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;