* Re: [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions
[not found] ` <20230125083851.27759-2-surenb@google.com>
@ 2023-01-25 9:09 ` Peter Zijlstra
[not found] ` <CAJuCfpEcVCZaCGzc-Wim25eaV5e6YG1YJAAdKwZ6JHViB0z8aw@mail.gmail.com>
2023-01-25 18:33 ` Matthew Wilcox
[not found] ` <Y9JFFYjfJf9uDijE@kernel.org>
2 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2023-01-25 9:09 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: michel, nvdimm, heiko, leewalsh, dri-devel, perex, jglisse,
arjunroy, m.szyprowski, linux-arch, qianweili, linux-samsung-soc,
aneesh.kumar, chenhuacai, kasan-dev, linux-acpi, rientjes,
xen-devel, devel, robdclark, minchan, robert.jarzmik, linux-um,
etnaviv, npiggin, viro, luto, gthelen, tglx, ldufour, linux-sgx,
martin.petersen, linux-usb, linux-kernel, linux-perf-users,
linux-crypto, linux-fsdevel, akpm, linux-media, freedreno, joelaf,
linux-aio, linux-fbdev, linux-ia64, dave.hansen, virtualization,
edumazet, target-devel, punit.agrawal, linux-s390, dave, deller,
hughd, andrii, patrik.r.jakobsson, linux-stm32, linux-rockchip,
linux-graphics-maintainer, kernel-team, jayalk, soheil, selinux,
linux-arm-msm, mripard, shakeelb, haojian.zhuang, loongarch,
linux-arm-kernel, tytso, nico, muchun.song, hjc, mcoquelin.stm32,
tatashin, mike.kravetz, songliubraving, alsa-devel, linux-tegra,
will, dmaengine, bhe, miklos, linux-rdma, linux-staging, willy,
dgilbert, xiang, pabeni, jejb, quic_abhinavk, bp, mchehab,
linux-ext4, tomba, hughlynch, sre, tfiga, linux-xfs, zhangfei.gao,
wangzhou1, netdev, bpf, linux-erofs, davem, mhocko, kvm, mst,
gurua, bigeasy, alexandre.torgue, dhowells, linux-mm, ray.huang,
adilger.kernel, kuba, sparclinux, airlied, anton.ivanov, herbert,
linux-scsi, richard, x86, vkoul, mingo, axelrasmussen, intel-gfx,
daniel, paulmck, jannh, chao, maarten.lankhorst, liam.howlett,
hdegoede, linux-mediatek, matthias.bgg, vbabka, dimitri.sivanich,
amd-gfx, posk, lstoakes, peterjung1337, yoshfuji, linuxppc-dev,
dsahern, kent.overstreet, kexec, tiwai, krzysztof.kozlowski,
tzimmermann, hannes, dmitry.baryshkov, johannes, mgorman,
linux-accelerators, l.stach
On Wed, Jan 25, 2023 at 12:38:46AM -0800, Suren Baghdasaryan wrote:
> 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;
We have __private and ACCESS_PRIVATE() to help with enforcing this.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions
[not found] ` <20230125083851.27759-2-surenb@google.com>
2023-01-25 9:09 ` [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions Peter Zijlstra
@ 2023-01-25 18:33 ` Matthew Wilcox
[not found] ` <Y9JFFYjfJf9uDijE@kernel.org>
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2023-01-25 18:33 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: michel, nvdimm, heiko, leewalsh, dri-devel, perex, jglisse,
arjunroy, m.szyprowski, linux-arch, qianweili, linux-samsung-soc,
aneesh.kumar, chenhuacai, kasan-dev, linux-acpi, rientjes,
xen-devel, devel, robdclark, minchan, robert.jarzmik, linux-um,
etnaviv, npiggin, viro, luto, gthelen, tglx, ldufour, linux-sgx,
martin.petersen, linux-usb, linux-kernel, linux-perf-users,
linux-crypto, linux-fsdevel, akpm, linux-media, freedreno, joelaf,
linux-aio, linux-fbdev, linux-ia64, dave.hansen, virtualization,
edumazet, target-devel, punit.agrawal, linux-s390, dave, deller,
hughd, andrii, patrik.r.jakobsson, linux-stm32, linux-rockchip,
linux-graphics-maintainer, kernel-team, jayalk, soheil, selinux,
linux-arm-msm, mripard, shakeelb, haojian.zhuang, loongarch,
linux-arm-kernel, tytso, nico, muchun.song, hjc, mcoquelin.stm32,
tatashin, mike.kravetz, songliubraving, alsa-devel, linux-tegra,
will, dmaengine, bhe, miklos, linux-rdma, linux-staging, amd-gfx,
gurua, dgilbert, xiang, pabeni, jejb, quic_abhinavk, bp, mchehab,
linux-ext4, tomba, hughlynch, sre, tfiga, linux-xfs, zhangfei.gao,
wangzhou1, netdev, bpf, linux-erofs, davem, mhocko, kvm, mst,
peterz, bigeasy, alexandre.torgue, dhowells, linux-mm, ray.huang,
adilger.kernel, kuba, sparclinux, airlied, anton.ivanov, herbert,
linux-scsi, richard, x86, vkoul, mingo, axelrasmussen, intel-gfx,
daniel, paulmck, jannh, chao, maarten.lankhorst, liam.howlett,
hdegoede, linux-mediatek, matthias.bgg, vbabka, dimitri.sivanich,
posk, lstoakes, peterjung1337, yoshfuji, linuxppc-dev, dsahern,
kent.overstreet, kexec, tiwai, krzysztof.kozlowski, tzimmermann,
hannes, dmitry.baryshkov, johannes, mgorman, linux-accelerators,
l.stach
On Wed, Jan 25, 2023 at 12:38:46AM -0800, Suren Baghdasaryan wrote:
> +/* 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)
> +{
> + vma->vm_flags = flags;
vm_flags are supposed to have type vm_flags_t. That's not been
fully realised yet, but perhaps we could avoid making it worse?
> 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;
Including changing this line to vm_flags_t
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions
[not found] ` <CAJuCfpEcVCZaCGzc-Wim25eaV5e6YG1YJAAdKwZ6JHViB0z8aw@mail.gmail.com>
@ 2023-01-25 18:37 ` Matthew Wilcox
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2023-01-25 18:37 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: michel, nvdimm, heiko, leewalsh, dri-devel, perex, jglisse,
arjunroy, m.szyprowski, linux-arch, qianweili, linux-samsung-soc,
aneesh.kumar, chenhuacai, kasan-dev, linux-acpi, rientjes,
xen-devel, devel, robdclark, minchan, robert.jarzmik, linux-um,
etnaviv, npiggin, viro, luto, gthelen, tglx, ldufour, linux-sgx,
martin.petersen, linux-usb, linux-kernel, linux-perf-users,
linux-crypto, linux-fsdevel, akpm, linux-media, freedreno, joelaf,
linux-aio, linux-fbdev, linux-ia64, dave.hansen, virtualization,
edumazet, target-devel, punit.agrawal, linux-s390, dave, deller,
hughd, andrii, patrik.r.jakobsson, linux-stm32, linux-rockchip,
linux-graphics-maintainer, kernel-team, jayalk, soheil, selinux,
linux-arm-msm, mripard, shakeelb, haojian.zhuang, loongarch,
linux-arm-kernel, tytso, nico, muchun.song, hjc, mcoquelin.stm32,
tatashin, mike.kravetz, songliubraving, alsa-devel, linux-tegra,
will, dmaengine, bhe, miklos, linux-rdma, linux-staging, amd-gfx,
gurua, dgilbert, xiang, pabeni, jejb, quic_abhinavk, bp, mchehab,
linux-ext4, tomba, hughlynch, sre, tfiga, linux-xfs, zhangfei.gao,
wangzhou1, netdev, bpf, linux-erofs, davem, mhocko, kvm, mst,
Peter Zijlstra, bigeasy, alexandre.torgue, dhowells, linux-mm,
ray.huang, adilger.kernel, kuba, sparclinux, airlied,
anton.ivanov, herbert, linux-scsi, richard, x86, vkoul, mingo,
axelrasmussen, intel-gfx, daniel, paulmck, jannh, chao,
maarten.lankhorst, liam.howlett, hdegoede, linux-mediatek,
matthias.bgg, vbabka, dimitri.sivanich, posk, lstoakes,
peterjung1337, yoshfuji, linuxppc-dev, dsahern, kent.overstreet,
kexec, tiwai, krzysztof.kozlowski, tzimmermann, hannes,
dmitry.baryshkov, johannes, mgorman, linux-accelerators, l.stach
On Wed, Jan 25, 2023 at 08:49:50AM -0800, Suren Baghdasaryan wrote:
> On Wed, Jan 25, 2023 at 1:10 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > > + /*
> > > + * Flags, see mm.h.
> > > + * WARNING! Do not modify directly.
> > > + * Use {init|reset|set|clear|mod}_vm_flags() functions instead.
> > > + */
> > > + unsigned long vm_flags;
> >
> > We have __private and ACCESS_PRIVATE() to help with enforcing this.
>
> Thanks for pointing this out, Peter! I guess for that I'll need to
> convert all read accesses and provide get_vm_flags() too? That will
> cause some additional churt (a quick search shows 801 hits over 248
> files) but maybe it's worth it? I think Michal suggested that too in
> another patch. Should I do that while we are at it?
Here's a trick I saw somewhere in the VFS:
union {
const vm_flags_t vm_flags;
vm_flags_t __private __vm_flags;
};
Now it can be read by anybody but written only by those using
ACCESS_PRIVATE.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions
[not found] ` <Y9KTUw/04FmBVplw@kernel.org>
@ 2023-01-26 15:09 ` Matthew Wilcox
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2023-01-26 15:09 UTC (permalink / raw)
To: Mike Rapoport
Cc: michel, nvdimm, heiko, leewalsh, dri-devel, perex, jglisse,
arjunroy, m.szyprowski, linux-arch, qianweili, linux-samsung-soc,
aneesh.kumar, chenhuacai, kasan-dev, linux-acpi, rientjes,
xen-devel, devel, robdclark, minchan, robert.jarzmik, linux-um,
etnaviv, npiggin, viro, luto, gthelen, tglx, ldufour,
Suren Baghdasaryan, linux-sgx, martin.petersen, linux-usb,
linux-kernel, linux-perf-users, linux-crypto, linux-fsdevel, akpm,
linux-media, freedreno, joelaf, linux-aio, linux-fbdev,
linux-ia64, dave.hansen, virtualization, edumazet, target-devel,
punit.agrawal, linux-s390, dave, deller, hughd, andrii,
patrik.r.jakobsson, linux-stm32, linux-rockchip,
linux-graphics-maintainer, kernel-team, jayalk, soheil, selinux,
linux-arm-msm, mripard, shakeelb, haojian.zhuang, loongarch,
linux-arm-kernel, tytso, nico, muchun.song, hjc, mcoquelin.stm32,
tatashin, mike.kravetz, songliubraving, alsa-devel, linux-tegra,
will, dmaengine, bhe, miklos, linux-rdma, linux-staging, amd-gfx,
gurua, dgilbert, xiang, pabeni, jejb, quic_abhinavk, bp, mchehab,
linux-ext4, tomba, hughlynch, sre, tfiga, linux-xfs, zhangfei.gao,
wangzhou1, netdev, bpf, linux-erofs, davem, mhocko, kvm, mst,
peterz, bigeasy, alexandre.torgue, dhowells, linux-mm, ray.huang,
adilger.kernel, kuba, sparclinux, airlied, anton.ivanov, herbert,
linux-scsi, richard, x86, vkoul, mingo, axelrasmussen, intel-gfx,
daniel, paulmck, jannh, chao, maarten.lankhorst, liam.howlett,
hdegoede, linux-mediatek, matthias.bgg, vbabka, dimitri.sivanich,
posk, lstoakes, peterjung1337, yoshfuji, linuxppc-dev, dsahern,
kent.overstreet, kexec, tiwai, krzysztof.kozlowski, tzimmermann,
hannes, dmitry.baryshkov, johannes, mgorman, linux-accelerators,
l.stach
On Thu, Jan 26, 2023 at 04:50:59PM +0200, Mike Rapoport wrote:
> On Thu, Jan 26, 2023 at 11:17:09AM +0200, Mike Rapoport wrote:
> > On Wed, Jan 25, 2023 at 12:38:46AM -0800, Suren Baghdasaryan wrote:
> > > +/* 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.
>
> Thinking more about it, it will be even clearer to name these vma_flags_xyz()
Perhaps vma_VERB_flags()?
vma_init_flags()
vma_reset_flags()
vma_set_flags()
vma_clear_flags()
vma_mod_flags()
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-26 15:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230125083851.27759-1-surenb@google.com>
[not found] ` <20230125083851.27759-2-surenb@google.com>
2023-01-25 9:09 ` [PATCH v2 1/6] mm: introduce vma->vm_flags modifier functions Peter Zijlstra
[not found] ` <CAJuCfpEcVCZaCGzc-Wim25eaV5e6YG1YJAAdKwZ6JHViB0z8aw@mail.gmail.com>
2023-01-25 18:37 ` Matthew Wilcox
2023-01-25 18:33 ` Matthew Wilcox
[not found] ` <Y9JFFYjfJf9uDijE@kernel.org>
[not found] ` <Y9KTUw/04FmBVplw@kernel.org>
2023-01-26 15:09 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).