From: Mike Rapoport <rppt@kernel•org>
To: Suren Baghdasaryan <surenb@google•com>
Cc: akpm@linux-foundation•org, michel@lespinasse•org,
jglisse@google•com, mhocko@suse•com, vbabka@suse•cz,
hannes@cmpxchg•org, mgorman@techsingularity•net,
dave@stgolabs•net, willy@infradead•org, liam.howlett@oracle•com,
peterz@infradead•org, ldufour@linux•ibm.com, paulmck@kernel•org,
luto@kernel•org, songliubraving@fb•com, peterx@redhat•com,
david@redhat•com, dhowells@redhat•com, hughd@google•com,
bigeasy@linutronix•de, kent.overstreet@linux•dev,
punit.agrawal@bytedance•com, lstoakes@gmail•com,
peterjung1337@gmail•com, rientjes@google•com,
axelrasmussen@google•com, joelaf@google•com, minchan@google•com,
jannh@google•com, shakeelb@google•com, tatashin@google•com,
edumazet@google•com, gthelen@google•com, gurua@google•com,
arjunroy@google•com, soheil@google•com, hughlynch@google•com,
leewalsh@google•com, posk@google•com, will@kernel•org,
aneesh.kumar@linux•ibm.com, npiggin@gmail•com,
chenhuacai@kernel•org, tglx@linutronix•de, mingo@redhat•com,
bp@alien8•de, dave.hansen@linux•intel.com, richard@nod•at,
anton.ivanov@cambridgegreys•com, johannes@sipsolutions•net,
qianweili@huawei•com, wangzhou1@hisilicon•com,
herbert@gondor•apana.org.au, davem@davemloft•net,
vkoul@kernel•org, airlied@gmail•com, daniel@ffwll•ch,
maarten.lankhorst@linux•intel.com, mripard@kernel•org,
tzimmermann@suse•de, l.stach@pengutronix•de,
krzysztof.kozlowski@linaro•org, patrik.r.jakobsson@gmail•com,
matthias.bgg@gmail•com, robdclark@gmail•com,
quic_abhinavk@quicinc•com, dmitry.baryshkov@linaro•org,
tomba@kernel•org, hjc@rock-chips•com, heiko@sntech•de,
ray.huang@amd•com, kraxel@redhat•com, sre@kernel•org,
mcoquelin.stm32@gmail•com, alexandre.torgue@foss•st.com,
tfiga@chromium•org, m.szyprowski@samsung•com, mchehab@kernel•org,
dimitri.sivanich@hpe•com, zhangfei.gao@linaro•org,
jejb@linux•ibm.com, martin.petersen@oracle•com,
dgilbert@interlog•com, hdegoede@redhat•com, mst@redhat•com,
jasowang@redhat•com, alex.williamson@redhat•com, deller@gmx•de,
jayalk@intworks•biz, viro@zeniv•linux.org.uk, nico@fluxnic•net,
xiang@kernel•org, chao@kernel•org, tytso@mit•edu,
adilger.kernel@dilger•ca, miklos@szeredi•hu,
mike.kravetz@oracle•com, muchun.song@linux•dev, bhe@redhat•com,
andrii@kernel•org, yoshfuji@linux-ipv6•org, dsahern@kernel•org,
kuba@kernel•org, pabeni@redhat•com, perex@perex•cz,
tiwai@suse•com, haojian.zhuang@gmail•com, robert.jarzmik@free•fr,
linux-mm@kvack•org, linux-arm-kernel@lists•infradead.org,
linuxppc-dev@lists•ozlabs.org, x86@kernel•org,
linux-kernel@vger•kernel.org,
linux-graphics-maintainer@vmware•com, linux-ia64@vger•kernel.org,
linux-arch@vger•kernel.org, loongarch@lists•linux.dev,
kvm@vger•kernel.org, linux-s390@vger•kernel.org,
linux-sgx@vger•kernel.org, linux-um@lists•infradead.org,
linux-acpi@vger•kernel.org, linux-crypto@vger•kernel.org,
nvdimm@lists•linux.dev, dmaengine@vger•kernel.org,
amd-gfx@lists•freedesktop.org, dri-devel@lists•freedesktop.org,
etnaviv@lists•freedesktop.org, linux-samsung-soc@vger•kernel.org,
intel-gfx@lists•freedesktop.org,
linux-mediatek@lists•infradead.org,
linux-arm-msm@vger•kernel.org, freedreno@lists•freedesktop.org,
linux-rockchip@lists•infradead.org, linux-tegra@vger•kernel.org,
virtualization@lists•linux-foundation.org,
xen-devel@lists•xenproject.org,
linux-stm32@st-md-mailman•stormreply.com,
linux-rdma@vger•kernel.org, linux-media@vger•kernel.org,
linux-accelerators@lists•ozlabs.org, sparclinux@vger•kernel.org,
linux-scsi@vger•kernel.org, linux-staging@lists•linux.dev,
target-devel@vger•kernel.org, linux-usb@vger•kernel.org,
netdev@vger•kernel.org, linux-fbdev@vger•kernel.org,
linux-aio@kvack•org, linux-fsdevel@vger•kernel.org,
linux-erofs@lists•ozlabs.org, linux-ext4@vger•kernel.org,
devel@lists•orangefs.org, kexec@lists•infradead.org,
linux-xfs@vger•kernel.org, bpf@vger•kernel.org,
linux-perf-users@vger•kernel.org, kasan-dev@googlegroups•com,
selinux@vger•kernel.org, alsa-devel@alsa-project•org,
kernel-team@android•com
Subject: Re: [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions
Date: Thu, 26 Jan 2023 11:17:09 +0200 [thread overview]
Message-ID: <Y9JFFYjfJf9uDijE@kernel.org> (raw)
In-Reply-To: <20230125083851.27759-2-surenb@google.com>
On Wed, Jan 25, 2023 at 12:38:46AM -0800, Suren Baghdasaryan wrote:
> vm_flags are among VMA attributes which affect decisions like VMA merging
> and splitting. Therefore all vm_flags modifications are performed after
> taking exclusive mmap_lock to prevent vm_flags updates racing with such
> operations. Introduce modifier functions for vm_flags to be used whenever
> flags are updated. This way we can better check and control correct
> locking behavior during these updates.
>
> Signed-off-by: Suren Baghdasaryan <surenb@google•com>
> ---
> include/linux/mm.h | 37 +++++++++++++++++++++++++++++++++++++
> include/linux/mm_types.h | 8 +++++++-
> 2 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index c2f62bdce134..b71f2809caac 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -627,6 +627,43 @@ static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)
> INIT_LIST_HEAD(&vma->anon_vma_chain);
> }
>
> +/* Use when VMA is not part of the VMA tree and needs no locking */
> +static inline void init_vm_flags(struct vm_area_struct *vma,
> + unsigned long flags)
I'd suggest to make it vm_flags_init() etc.
Except that
Acked-by: Mike Rapoport (IBM) <rppt@kernel•org>
> +{
> + vma->vm_flags = flags;
> +}
> +
> +/* Use when VMA is part of the VMA tree and modifications need coordination */
> +static inline void reset_vm_flags(struct vm_area_struct *vma,
> + unsigned long flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + init_vm_flags(vma, flags);
> +}
> +
> +static inline void set_vm_flags(struct vm_area_struct *vma,
> + unsigned long flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + vma->vm_flags |= flags;
> +}
> +
> +static inline void clear_vm_flags(struct vm_area_struct *vma,
> + unsigned long flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + vma->vm_flags &= ~flags;
> +}
> +
> +static inline void mod_vm_flags(struct vm_area_struct *vma,
> + unsigned long set, unsigned long clear)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + vma->vm_flags |= set;
> + vma->vm_flags &= ~clear;
> +}
> +
> static inline void vma_set_anonymous(struct vm_area_struct *vma)
> {
> vma->vm_ops = NULL;
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 2d6d790d9bed..6c7c70bf50dd 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -491,7 +491,13 @@ struct vm_area_struct {
> * See vmf_insert_mixed_prot() for discussion.
> */
> pgprot_t vm_page_prot;
> - unsigned long vm_flags; /* Flags, see mm.h. */
> +
> + /*
> + * Flags, see mm.h.
> + * WARNING! Do not modify directly.
> + * Use {init|reset|set|clear|mod}_vm_flags() functions instead.
> + */
> + unsigned long vm_flags;
>
> /*
> * For areas with an address space and backing store,
> --
> 2.39.1
>
>
next prev parent reply other threads:[~2023-01-26 9:18 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 8:38 [PATCH v2 0/6] introduce vm_flags modifier functions Suren Baghdasaryan
2023-01-25 8:38 ` [PATCH v2 1/6] mm: introduce vma->vm_flags " Suren Baghdasaryan
2023-01-25 8:56 ` Michal Hocko
2023-01-25 9:09 ` Peter Zijlstra
2023-01-25 16:49 ` Suren Baghdasaryan
2023-01-25 18:37 ` Matthew Wilcox
2023-01-25 19:21 ` Suren Baghdasaryan
2023-01-25 18:33 ` Matthew Wilcox
2023-01-25 19:22 ` Suren Baghdasaryan
2023-01-26 9:17 ` Mike Rapoport [this message]
2023-01-26 14:50 ` Mike Rapoport
2023-01-26 15:09 ` Matthew Wilcox
2023-01-26 16:25 ` Suren Baghdasaryan
2023-01-25 8:38 ` [PATCH v2 2/6] mm: replace VM_LOCKED_CLEAR_MASK with VM_LOCKED_MASK Suren Baghdasaryan
2023-01-25 9:02 ` Michal Hocko
2023-01-26 9:19 ` Mike Rapoport
2023-01-25 8:38 ` [PATCH v2 3/6] mm: replace vma->vm_flags direct modifications with modifier calls Suren Baghdasaryan
2023-01-25 9:30 ` Michal Hocko
2023-01-25 16:55 ` Suren Baghdasaryan
2023-01-26 9:21 ` Mike Rapoport
2023-01-26 17:07 ` Sebastian Reichel
2023-01-25 8:38 ` [PATCH v2 4/6] mm: replace vma->vm_flags indirect modification in ksm_madvise Suren Baghdasaryan
2023-01-25 9:38 ` Michal Hocko
2023-01-25 16:57 ` Suren Baghdasaryan
2023-01-25 17:08 ` Michal Hocko
2023-01-25 17:22 ` Suren Baghdasaryan
2023-01-26 9:26 ` Mike Rapoport
2023-01-25 8:38 ` [PATCH v2 5/6] mm: introduce mod_vm_flags_nolock and use it in untrack_pfn Suren Baghdasaryan
2023-01-25 9:42 ` Michal Hocko
2023-01-25 17:00 ` Suren Baghdasaryan
2023-01-26 9:34 ` Mike Rapoport
2023-01-25 8:38 ` [PATCH v2 6/6] mm: export dump_mm() Suren Baghdasaryan
2023-01-25 9:43 ` Michal Hocko
2023-01-26 14:48 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9JFFYjfJf9uDijE@kernel.org \
--to=rppt@kernel$(echo .)org \
--cc=adilger.kernel@dilger$(echo .)ca \
--cc=airlied@gmail$(echo .)com \
--cc=akpm@linux-foundation$(echo .)org \
--cc=alex.williamson@redhat$(echo .)com \
--cc=alexandre.torgue@foss$(echo .)st.com \
--cc=alsa-devel@alsa-project$(echo .)org \
--cc=amd-gfx@lists$(echo .)freedesktop.org \
--cc=andrii@kernel$(echo .)org \
--cc=aneesh.kumar@linux$(echo .)ibm.com \
--cc=anton.ivanov@cambridgegreys$(echo .)com \
--cc=arjunroy@google$(echo .)com \
--cc=axelrasmussen@google$(echo .)com \
--cc=bhe@redhat$(echo .)com \
--cc=bigeasy@linutronix$(echo .)de \
--cc=bp@alien8$(echo .)de \
--cc=bpf@vger$(echo .)kernel.org \
--cc=chao@kernel$(echo .)org \
--cc=chenhuacai@kernel$(echo .)org \
--cc=daniel@ffwll$(echo .)ch \
--cc=dave.hansen@linux$(echo .)intel.com \
--cc=dave@stgolabs$(echo .)net \
--cc=davem@davemloft$(echo .)net \
--cc=david@redhat$(echo .)com \
--cc=deller@gmx$(echo .)de \
--cc=devel@lists$(echo .)orangefs.org \
--cc=dgilbert@interlog$(echo .)com \
--cc=dhowells@redhat$(echo .)com \
--cc=dimitri.sivanich@hpe$(echo .)com \
--cc=dmaengine@vger$(echo .)kernel.org \
--cc=dmitry.baryshkov@linaro$(echo .)org \
--cc=dri-devel@lists$(echo .)freedesktop.org \
--cc=dsahern@kernel$(echo .)org \
--cc=edumazet@google$(echo .)com \
--cc=etnaviv@lists$(echo .)freedesktop.org \
--cc=freedreno@lists$(echo .)freedesktop.org \
--cc=gthelen@google$(echo .)com \
--cc=gurua@google$(echo .)com \
--cc=hannes@cmpxchg$(echo .)org \
--cc=haojian.zhuang@gmail$(echo .)com \
--cc=hdegoede@redhat$(echo .)com \
--cc=heiko@sntech$(echo .)de \
--cc=herbert@gondor$(echo .)apana.org.au \
--cc=hjc@rock-chips$(echo .)com \
--cc=hughd@google$(echo .)com \
--cc=hughlynch@google$(echo .)com \
--cc=intel-gfx@lists$(echo .)freedesktop.org \
--cc=jannh@google$(echo .)com \
--cc=jasowang@redhat$(echo .)com \
--cc=jayalk@intworks$(echo .)biz \
--cc=jejb@linux$(echo .)ibm.com \
--cc=jglisse@google$(echo .)com \
--cc=joelaf@google$(echo .)com \
--cc=johannes@sipsolutions$(echo .)net \
--cc=kasan-dev@googlegroups$(echo .)com \
--cc=kent.overstreet@linux$(echo .)dev \
--cc=kernel-team@android$(echo .)com \
--cc=kexec@lists$(echo .)infradead.org \
--cc=kraxel@redhat$(echo .)com \
--cc=krzysztof.kozlowski@linaro$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=kvm@vger$(echo .)kernel.org \
--cc=l.stach@pengutronix$(echo .)de \
--cc=ldufour@linux$(echo .)ibm.com \
--cc=leewalsh@google$(echo .)com \
--cc=liam.howlett@oracle$(echo .)com \
--cc=linux-accelerators@lists$(echo .)ozlabs.org \
--cc=linux-acpi@vger$(echo .)kernel.org \
--cc=linux-aio@kvack$(echo .)org \
--cc=linux-arch@vger$(echo .)kernel.org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-arm-msm@vger$(echo .)kernel.org \
--cc=linux-crypto@vger$(echo .)kernel.org \
--cc=linux-erofs@lists$(echo .)ozlabs.org \
--cc=linux-ext4@vger$(echo .)kernel.org \
--cc=linux-fbdev@vger$(echo .)kernel.org \
--cc=linux-fsdevel@vger$(echo .)kernel.org \
--cc=linux-graphics-maintainer@vmware$(echo .)com \
--cc=linux-ia64@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-media@vger$(echo .)kernel.org \
--cc=linux-mediatek@lists$(echo .)infradead.org \
--cc=linux-mm@kvack$(echo .)org \
--cc=linux-perf-users@vger$(echo .)kernel.org \
--cc=linux-rdma@vger$(echo .)kernel.org \
--cc=linux-rockchip@lists$(echo .)infradead.org \
--cc=linux-s390@vger$(echo .)kernel.org \
--cc=linux-samsung-soc@vger$(echo .)kernel.org \
--cc=linux-scsi@vger$(echo .)kernel.org \
--cc=linux-sgx@vger$(echo .)kernel.org \
--cc=linux-staging@lists$(echo .)linux.dev \
--cc=linux-stm32@st-md-mailman$(echo .)stormreply.com \
--cc=linux-tegra@vger$(echo .)kernel.org \
--cc=linux-um@lists$(echo .)infradead.org \
--cc=linux-usb@vger$(echo .)kernel.org \
--cc=linux-xfs@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=loongarch@lists$(echo .)linux.dev \
--cc=lstoakes@gmail$(echo .)com \
--cc=luto@kernel$(echo .)org \
--cc=m.szyprowski@samsung$(echo .)com \
--cc=maarten.lankhorst@linux$(echo .)intel.com \
--cc=martin.petersen@oracle$(echo .)com \
--cc=matthias.bgg@gmail$(echo .)com \
--cc=mchehab@kernel$(echo .)org \
--cc=mcoquelin.stm32@gmail$(echo .)com \
--cc=mgorman@techsingularity$(echo .)net \
--cc=mhocko@suse$(echo .)com \
--cc=michel@lespinasse$(echo .)org \
--cc=mike.kravetz@oracle$(echo .)com \
--cc=miklos@szeredi$(echo .)hu \
--cc=minchan@google$(echo .)com \
--cc=mingo@redhat$(echo .)com \
--cc=mripard@kernel$(echo .)org \
--cc=mst@redhat$(echo .)com \
--cc=muchun.song@linux$(echo .)dev \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nico@fluxnic$(echo .)net \
--cc=npiggin@gmail$(echo .)com \
--cc=nvdimm@lists$(echo .)linux.dev \
--cc=pabeni@redhat$(echo .)com \
--cc=patrik.r.jakobsson@gmail$(echo .)com \
--cc=paulmck@kernel$(echo .)org \
--cc=perex@perex$(echo .)cz \
--cc=peterjung1337@gmail$(echo .)com \
--cc=peterx@redhat$(echo .)com \
--cc=peterz@infradead$(echo .)org \
--cc=posk@google$(echo .)com \
--cc=punit.agrawal@bytedance$(echo .)com \
--cc=qianweili@huawei$(echo .)com \
--cc=quic_abhinavk@quicinc$(echo .)com \
--cc=ray.huang@amd$(echo .)com \
--cc=richard@nod$(echo .)at \
--cc=rientjes@google$(echo .)com \
--cc=robdclark@gmail$(echo .)com \
--cc=robert.jarzmik@free$(echo .)fr \
--cc=selinux@vger$(echo .)kernel.org \
--cc=shakeelb@google$(echo .)com \
--cc=soheil@google$(echo .)com \
--cc=songliubraving@fb$(echo .)com \
--cc=sparclinux@vger$(echo .)kernel.org \
--cc=sre@kernel$(echo .)org \
--cc=surenb@google$(echo .)com \
--cc=target-devel@vger$(echo .)kernel.org \
--cc=tatashin@google$(echo .)com \
--cc=tfiga@chromium$(echo .)org \
--cc=tglx@linutronix$(echo .)de \
--cc=tiwai@suse$(echo .)com \
--cc=tomba@kernel$(echo .)org \
--cc=tytso@mit$(echo .)edu \
--cc=tzimmermann@suse$(echo .)de \
--cc=vbabka@suse$(echo .)cz \
--cc=viro@zeniv$(echo .)linux.org.uk \
--cc=virtualization@lists$(echo .)linux-foundation.org \
--cc=vkoul@kernel$(echo .)org \
--cc=wangzhou1@hisilicon$(echo .)com \
--cc=will@kernel$(echo .)org \
--cc=willy@infradead$(echo .)org \
--cc=x86@kernel$(echo .)org \
--cc=xen-devel@lists$(echo .)xenproject.org \
--cc=xiang@kernel$(echo .)org \
--cc=yoshfuji@linux-ipv6$(echo .)org \
--cc=zhangfei.gao@linaro$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox