From patchwork Fri Jun 28 14:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13716243 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 DD16CC2BD09 for ; Fri, 28 Jun 2024 14:35:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 177F96B0095; Fri, 28 Jun 2024 10:35:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12A446B0096; Fri, 28 Jun 2024 10:35:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E48656B0098; Fri, 28 Jun 2024 10:35:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C0E7C6B0095 for ; Fri, 28 Jun 2024 10:35:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 362BB1C0C75 for ; Fri, 28 Jun 2024 14:35:43 +0000 (UTC) X-FDA: 82280546166.29.D8DB988 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf08.hostedemail.com (Postfix) with ESMTP id 321C5160020 for ; Fri, 28 Jun 2024 14:35:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cq6r4v+3; spf=pass (imf08.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719585327; 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=Z4tIycn76980srpS0Qx+f5aSwAYnJlMpkjRvY7J5k/M=; b=PDCZrwnqWu8F22xfAECldaTnb+NED0tIXbdHiVGHVaZZasEyuRqlCR0TOeC3DS7L5bOeVp +8BXlTPmjUbXpbI/qY7Ooy6z42Betn4a9GJnzUnlMmjW7/MS90kUivZdMBEi7DJDuYK1y2 JUYQy/F1WvvhxrNH5jcVtigDasUAkEE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cq6r4v+3; spf=pass (imf08.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719585327; a=rsa-sha256; cv=none; b=flXiCLI6nBt70xIGEFBGwstzCzFubHsn+CVJN+sJ38xQr+0y3LAe9AQrQRUdJf3Bl0uBSJ WgHt0Z1yy61ZQt6uTHypMLzjasmg7MGVV/7j/Z59pKWosTaIbGEGZX+D/i1KGG1cOHsX4g 26QLqETt45A5yvMJF11wXWcn1nk+4pw= Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4256eec963eso4480245e9.1 for ; Fri, 28 Jun 2024 07:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719585340; x=1720190140; 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=Z4tIycn76980srpS0Qx+f5aSwAYnJlMpkjRvY7J5k/M=; b=Cq6r4v+31hwQmziUz6bUr6OUEdhdJfvVGMSPLocAePDSfe5VQeSPl/zASECk1c204F hXoEA9I42y0MWaUrRD6L6keJsnNsom1uPzlfTvwp1Qx3Sa2h/FHWG47MNtLkPkl0pNsv 7oWtJj47WChxhUgpN3BzIWX2rKTff93SDXTgp3ppYiWKBzhng2+EzyX2IXSmK7U9ZrYb 0ih3AMk8YYmLgUQPy91iWD3GtUokocJv1MrCnuisvFTVi+07zKuG7ZKsqO+lLhhXT6IY xcphVXgkhqHCDyZ/4k9Bw0fqswmdIasiLeP5ZoNBVO1ulcolTlY0FKOv4PxawL6fbK5Y OABQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719585340; x=1720190140; 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=Z4tIycn76980srpS0Qx+f5aSwAYnJlMpkjRvY7J5k/M=; b=D7JTr1pXpoBwtHCynfzcAHEP8v+y8ro89vzifBv+UW39fE3xfhC8CkONtiacpa3zAU ++gE5No6nEV3gQjfjSOv+LocLoMjjzAHdIPb5T8nhgfv2FK+7ps1KkpnhlReuCyI9qQm SDBidperjEAdfNZzMqST18cC7fNUm3ww4UfQ9TR+Oyi/qRfGDDb38rIEDkuo3/bJgByr rJuvSlvGjvQObEenjpltPlAft8W/RZH3RVVMvg4baw+SCoXIrYzNXk/JOEoV9O2Z7N9O CDEjx1IUxEfZ1nFXxuCPFPHXyKAEMLrLTlL7GHGyUIZqgyee86QBRaEM+RO0Laf9EBA2 gc4g== X-Forwarded-Encrypted: i=1; AJvYcCU6Q/cfTuNBat43hhLDQ1F/S2d5wR22yr6Z203FzTbrD67czfEvimt2N8PpIC2/nm/XCJGJGf6v1iLSFENt6vPHIl4= X-Gm-Message-State: AOJu0Yyr2lNnP84tNaYBxz1NsaEMIuV+ZYZ/bJdBbESc4KOC8UWl24VC y3Sjflmg2mUSQRyegL2Ia5L0JUyLJ7qXwRfyQH0wPyW9Hll8MQSS X-Google-Smtp-Source: AGHT+IFhBGe8jyb5W7chS9Spyqsf3A8ZCwGCMKmUS7z29i0piJQ3aiKvCg0rr0Q6ubvs+Umxr5BHGQ== X-Received: by 2002:a05:600c:1608:b0:425:6498:3b6c with SMTP id 5b1f17b1804b1-42564983cd8mr40449895e9.26.1719585339378; Fri, 28 Jun 2024 07:35:39 -0700 (PDT) Received: from lucifer.home ([2a00:23cc:d20f:ba01:bb66:f8b2:a0e8:6447]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4256af37828sm38985485e9.9.2024.06.28.07.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 07:35:38 -0700 (PDT) From: Lorenzo Stoakes To: Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Liam R . Howlett" , Vlastimil Babka , Matthew Wilcox , Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , Suren Baghdasaryan , Lorenzo Stoakes Subject: [RFC PATCH v2 2/7] mm: move vma_modify() and helpers to internal header Date: Fri, 28 Jun 2024 15:35:23 +0100 Message-ID: <0e048500da5cfd51647699c244b1575229856bd1.1719584707.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: hy9gco1k4xjd4rb7his3orwa9hpqbadk X-Rspam-User: X-Rspamd-Queue-Id: 321C5160020 X-Rspamd-Server: rspam02 X-HE-Tag: 1719585340-514425 X-HE-Meta: U2FsdGVkX1/F9OFKVkOMg6rZ5FeHru9po+SkKH7R1+0Ffj+4e6/bcWQi95615u8MmDKaVCjWL4Tsd+Z0626TAkc3uMRFBKW2grpIUQjC/jQPynzVV6wNeQkPKmdWvg8zdk79W7+ScMCVtIV+apcmLCshlw6UBh0CKUw8SbVYVCAkUOhPhE1SbZ9pRqaMf7W/szNV9gz4xkbTwoyC2VYX8M7bhf6SFdGGByCFQ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F2m4T4w1n0/ifS+fybRZ+myhtPFtsXc0xO+/487H+ik+aMM5cHsUfp6Xa3IFrzV5mocL7CuJaIxt 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: List-Subscribe: List-Unsubscribe: These are core VMA manipulation functions which invoke VMA splitting and merging and should not be directly accessed from outside of mm/. Signed-off-by: Lorenzo Stoakes --- include/linux/mm.h | 60 --------------------------------------------- mm/internal.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5f1075d19600..4d2b5538925b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3285,66 +3285,6 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **, unsigned long addr, unsigned long len, pgoff_t pgoff, bool *need_rmap_locks); extern void exit_mmap(struct mm_struct *); -struct vm_area_struct *vma_modify(struct vma_iterator *vmi, - struct vm_area_struct *prev, - struct vm_area_struct *vma, - unsigned long start, unsigned long end, - unsigned long vm_flags, - struct mempolicy *policy, - struct vm_userfaultfd_ctx uffd_ctx, - struct anon_vma_name *anon_name); - -/* We are about to modify the VMA's flags. */ -static inline struct vm_area_struct -*vma_modify_flags(struct vma_iterator *vmi, - struct vm_area_struct *prev, - struct vm_area_struct *vma, - unsigned long start, unsigned long end, - unsigned long new_flags) -{ - return vma_modify(vmi, prev, vma, start, end, new_flags, - vma_policy(vma), vma->vm_userfaultfd_ctx, - anon_vma_name(vma)); -} - -/* We are about to modify the VMA's flags and/or anon_name. */ -static inline struct vm_area_struct -*vma_modify_flags_name(struct vma_iterator *vmi, - struct vm_area_struct *prev, - struct vm_area_struct *vma, - unsigned long start, - unsigned long end, - unsigned long new_flags, - struct anon_vma_name *new_name) -{ - return vma_modify(vmi, prev, vma, start, end, new_flags, - vma_policy(vma), vma->vm_userfaultfd_ctx, new_name); -} - -/* We are about to modify the VMA's memory policy. */ -static inline struct vm_area_struct -*vma_modify_policy(struct vma_iterator *vmi, - struct vm_area_struct *prev, - struct vm_area_struct *vma, - unsigned long start, unsigned long end, - struct mempolicy *new_pol) -{ - return vma_modify(vmi, prev, vma, start, end, vma->vm_flags, - new_pol, vma->vm_userfaultfd_ctx, anon_vma_name(vma)); -} - -/* We are about to modify the VMA's flags and/or uffd context. */ -static inline struct vm_area_struct -*vma_modify_flags_uffd(struct vma_iterator *vmi, - struct vm_area_struct *prev, - struct vm_area_struct *vma, - unsigned long start, unsigned long end, - unsigned long new_flags, - struct vm_userfaultfd_ctx new_ctx) -{ - return vma_modify(vmi, prev, vma, start, end, new_flags, - vma_policy(vma), new_ctx, anon_vma_name(vma)); -} static inline int check_data_rlimit(unsigned long rlim, unsigned long new, diff --git a/mm/internal.h b/mm/internal.h index b264a7dabefe..164f03c6bce2 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1243,6 +1243,67 @@ struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long delta); +struct vm_area_struct *vma_modify(struct vma_iterator *vmi, + struct vm_area_struct *prev, + struct vm_area_struct *vma, + unsigned long start, unsigned long end, + unsigned long vm_flags, + struct mempolicy *policy, + struct vm_userfaultfd_ctx uffd_ctx, + struct anon_vma_name *anon_name); + +/* We are about to modify the VMA's flags. */ +static inline struct vm_area_struct +*vma_modify_flags(struct vma_iterator *vmi, + struct vm_area_struct *prev, + struct vm_area_struct *vma, + unsigned long start, unsigned long end, + unsigned long new_flags) +{ + return vma_modify(vmi, prev, vma, start, end, new_flags, + vma_policy(vma), vma->vm_userfaultfd_ctx, + anon_vma_name(vma)); +} + +/* We are about to modify the VMA's flags and/or anon_name. */ +static inline struct vm_area_struct +*vma_modify_flags_name(struct vma_iterator *vmi, + struct vm_area_struct *prev, + struct vm_area_struct *vma, + unsigned long start, + unsigned long end, + unsigned long new_flags, + struct anon_vma_name *new_name) +{ + return vma_modify(vmi, prev, vma, start, end, new_flags, + vma_policy(vma), vma->vm_userfaultfd_ctx, new_name); +} + +/* We are about to modify the VMA's memory policy. */ +static inline struct vm_area_struct +*vma_modify_policy(struct vma_iterator *vmi, + struct vm_area_struct *prev, + struct vm_area_struct *vma, + unsigned long start, unsigned long end, + struct mempolicy *new_pol) +{ + return vma_modify(vmi, prev, vma, start, end, vma->vm_flags, + new_pol, vma->vm_userfaultfd_ctx, anon_vma_name(vma)); +} + +/* We are about to modify the VMA's flags and/or uffd context. */ +static inline struct vm_area_struct +*vma_modify_flags_uffd(struct vma_iterator *vmi, + struct vm_area_struct *prev, + struct vm_area_struct *vma, + unsigned long start, unsigned long end, + unsigned long new_flags, + struct vm_userfaultfd_ctx new_ctx) +{ + return vma_modify(vmi, prev, vma, start, end, new_flags, + vma_policy(vma), new_ctx, anon_vma_name(vma)); +} + enum { /* mark page accessed */ FOLL_TOUCH = 1 << 16,