From patchwork Thu Jun 27 10:39:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13714163 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 11518C2BD09 for ; Thu, 27 Jun 2024 10:39:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E38346B0095; Thu, 27 Jun 2024 06:39:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBE0F6B0096; Thu, 27 Jun 2024 06:39:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B28816B0098; Thu, 27 Jun 2024 06:39:46 -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 8F4456B0095 for ; Thu, 27 Jun 2024 06:39:46 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 44E0A1C27D9 for ; Thu, 27 Jun 2024 10:39:46 +0000 (UTC) X-FDA: 82276322772.18.57B5A18 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by imf29.hostedemail.com (Postfix) with ESMTP id 6BC4712000C for ; Thu, 27 Jun 2024 10:39:44 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aqWOtPU0; spf=pass (imf29.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.52 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=1719484768; 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=dBerhuPUPnvHMMtpXidwo0lqOY9yjptwKl42PSVTWQ8=; b=m8FppGCAkQ1IMnD3Jeg+HxQOnOnwj/T0LbXfHDo2lXFiR+f0Bx9ew83cSAkqNqh8i7+4rD cvtXnSZh3tqoCnjQY3Tp1zfNvue0NB9WCJoPCazLJ6BypJyN6Jpso5mrxHrWI7NUBqOsAf pLXY1aVVAFdm9+JsvsTgr6NOs0voUXI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719484768; a=rsa-sha256; cv=none; b=B1vhygbZzYRlbBl5fD45aOrLb9BB9mTD+x/bLn2Q3+5UD3Shpbl5MrXfYRTUYEIn6ajjEs A1I0OkjTlBlZeTY0WtKTG8Xehvk/utTJhcItIuDYfTqJHEZC+OldNxptdWbAxcwwAdCFGk jsMxo6E3l75erB8yLQ2qbraPDNUWPPM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aqWOtPU0; spf=pass (imf29.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.52 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4248e28de9eso39724825e9.2 for ; Thu, 27 Jun 2024 03:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719484783; x=1720089583; 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=dBerhuPUPnvHMMtpXidwo0lqOY9yjptwKl42PSVTWQ8=; b=aqWOtPU0EwOhrM6hxaJYnI8G0xWf9/xzseV6ibzkEc42J3RQBRksB1iSbmWUATZk5d MQVd3YCDMa+2qF4d3zl4VQnVFtkKFv6/ene8YLQh0vjkAbe/oL2hGPgaSpqDK3jrHQEL +v7m1nGrY+k7eR7OdiaBwqJ/hASxM8fhjWJ1IZnyc/M0feHcEuUAEs2Zi2zFaw0H2Xuf m6CXlJHhLJHm4eAasyX0OnSsGUURkJ7F1f6kS3fBxg+snw46sHg76sI7fxGM7ex5XQC6 ydJeHfXt3MLwbKGzSlqVlt94ftcIyW4SIJuTkPBDUUy8KTuEG6Io58xRB/un5ZLK23rk CHoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719484783; x=1720089583; 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=dBerhuPUPnvHMMtpXidwo0lqOY9yjptwKl42PSVTWQ8=; b=XktwiuU/w4o0p+Jv1CMyFjZ3Ew91RO6rWYtw2EXDBYaT7v77psjwJqC12N8QwqIaz3 JsxXX4YXFchs5NoVEurV2SxFdWFZhUIYNCZ51OaTHSMaHyRblDPJz9sWu9bnYxTiTalk HUcJvP0UTLPmmwTeVUAl5kJTtYt+VPXHS1ZaWGro9HRDhv9SJQthBwq+ilQd77powuxY gXtDuTfmGBwrqsGqJLdW40vNnZ6lwAANtnYOIfpz5qI7Vnf214lPxld5CXs17TkzfpF9 b9hw0aFojKdxw6VidhINjyoVBKgIvdswgHfrRn4qT2wYG/3tVMn5hiGxhAkIpiqA62yp x1Zw== X-Forwarded-Encrypted: i=1; AJvYcCV2TkmFdpIIJxdxvDoJRNDqev3aQB9t+ShyfNokhDoO5Hq0XV6fp9x6sn4XntDtJoSGiJL7jcwa6HIZGiSUcMj2XtE= X-Gm-Message-State: AOJu0YzFREWDpYAdBENlQgX2xEbMH6J7K+7J8Makjk2RC35gSikENp20 6sADaOkMKrwAnACCZRwyYfu6xZ+PxqTt7VT5Ria9n+eeaW06Alp8 X-Google-Smtp-Source: AGHT+IFLaWGlswrMxHfEGA/17kTRmUCtefJU4lJQNLERDl5+0gdtRbOe050inXgngVsX1KD0xjlNvQ== X-Received: by 2002:a05:600c:3414:b0:424:a4f1:8c3e with SMTP id 5b1f17b1804b1-424a4f18d79mr45881255e9.34.1719484782675; Thu, 27 Jun 2024 03:39:42 -0700 (PDT) Received: from lucifer.home ([2a00:23cc:d20f:ba01:bb66:f8b2:a0e8:6447]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42564bb6caasm19957195e9.33.2024.06.27.03.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:39:41 -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 2/7] mm: move vma_modify() and helpers to internal header Date: Thu, 27 Jun 2024 11:39:27 +0100 Message-ID: <2fb403aba2b847bfbc0bcf7e61cb830813b0853a.1719481836.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 6BC4712000C X-Stat-Signature: adyxoci87tg574eqzikztmzsctpq7kzu X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719484784-294318 X-HE-Meta: U2FsdGVkX1/tbPtydT4harsvJQH8dOkq520mkoY4tXzQUTdzqtQ0Pg0gABgy9cIWO6mOCIeET6sjzkoNYBSb6YggYgM3On3OTmVD3wdkajMI5tZKU/Un46cdML1GlTnp+aCM5c5qhJCCRj/IddpDfb8m+8Og77UIPmJMAiGDqw5AmP7oIoberrx2F1QGujnmS4a0YGFRgicayNCgVt1TZ7sxh3zbmhqB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NfmXHqaKBLu4eT7XS8V3CHpYyZE51oWXF3dCZCpc5NGqOnfKYr8z13iIpS16PLxyBjRSRbeJT 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 ultimately invoke VMA splitting and merging and should not be directly accessed from outside of mm/ functionality. We ultimately intend to ultimately move these to a VMA-specific internal header. 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 2ea9a88dcb95..c8177200c943 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1244,6 +1244,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,