* [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
@ 2023-02-01 0:01 ` Suren Baghdasaryan
0 siblings, 0 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2023-02-01 0:01 UTC (permalink / raw)
To: akpm
Cc: michel, jglisse, mhocko, vbabka, hannes, mgorman, dave, willy,
liam.howlett, peterz, ldufour, paulmck, mingo, will, luto,
songliubraving, peterx, david, dhowells, hughd, bigeasy,
kent.overstreet, punit.agrawal, lstoakes, peterjung1337,
rientjes, axelrasmussen, joelaf, minchan, rppt, 42.hyeyoo, jannh,
shakeelb, tatashin, edumazet, gthelen, gurua, arjunroy, soheil,
leewalsh, posk, linux-mm, linux-arm-kernel, linuxppc-dev, x86,
linux-kernel, kernel-team, surenb
Provide vm_flags_reset_once() and replace the vm_flags updates which used
WRITE_ONCE() to prevent compiler optimizations.
Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
Notes:
- The patch applies cleanly over mm-unstable
- The SHA in Fixes: line is from mm-unstable, so is... unstable
include/linux/mm.h | 7 +++++++
mm/mlock.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5bf0ad48faaa..23ce04f6e91e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
vm_flags_init(vma, flags);
}
+static inline void vm_flags_reset_once(struct vm_area_struct *vma,
+ vm_flags_t flags)
+{
+ mmap_assert_write_locked(vma->vm_mm);
+ WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
+}
+
static inline void vm_flags_set(struct vm_area_struct *vma,
vm_flags_t flags)
{
diff --git a/mm/mlock.c b/mm/mlock.c
index ed49459e343e..617469fce96d 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
*/
if (newflags & VM_LOCKED)
newflags |= VM_IO;
- vm_flags_reset(vma, newflags);
+ vm_flags_reset_once(vma, newflags);
lru_add_drain();
walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
@@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
if (newflags & VM_IO) {
newflags &= ~VM_IO;
- vm_flags_reset(vma, newflags);
+ vm_flags_reset_once(vma, newflags);
}
}
--
2.39.1.456.gfc5497dd1b-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
@ 2023-02-01 0:01 ` Suren Baghdasaryan
0 siblings, 0 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2023-02-01 0:01 UTC (permalink / raw)
To: akpm
Cc: michel, joelaf, songliubraving, mhocko, leewalsh, david, peterz,
bigeasy, peterx, dhowells, linux-mm, edumazet, jglisse,
punit.agrawal, 42.hyeyoo, will, arjunroy, dave, minchan, x86,
hughd, willy, gurua, mingo, linux-arm-kernel, rientjes,
axelrasmussen, kernel-team, soheil, paulmck, jannh, liam.howlett,
shakeelb, luto, gthelen, ldufour, surenb, vbabka, posk, lstoakes,
peterjung1337, linuxppc-dev, kent.overstreet, linux-kernel,
hannes, tatashin, mgorman
Provide vm_flags_reset_once() and replace the vm_flags updates which used
WRITE_ONCE() to prevent compiler optimizations.
Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
Notes:
- The patch applies cleanly over mm-unstable
- The SHA in Fixes: line is from mm-unstable, so is... unstable
include/linux/mm.h | 7 +++++++
mm/mlock.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5bf0ad48faaa..23ce04f6e91e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
vm_flags_init(vma, flags);
}
+static inline void vm_flags_reset_once(struct vm_area_struct *vma,
+ vm_flags_t flags)
+{
+ mmap_assert_write_locked(vma->vm_mm);
+ WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
+}
+
static inline void vm_flags_set(struct vm_area_struct *vma,
vm_flags_t flags)
{
diff --git a/mm/mlock.c b/mm/mlock.c
index ed49459e343e..617469fce96d 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
*/
if (newflags & VM_LOCKED)
newflags |= VM_IO;
- vm_flags_reset(vma, newflags);
+ vm_flags_reset_once(vma, newflags);
lru_add_drain();
walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
@@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
if (newflags & VM_IO) {
newflags &= ~VM_IO;
- vm_flags_reset(vma, newflags);
+ vm_flags_reset_once(vma, newflags);
}
}
--
2.39.1.456.gfc5497dd1b-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
@ 2023-02-01 0:01 ` Suren Baghdasaryan
0 siblings, 0 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2023-02-01 0:01 UTC (permalink / raw)
To: akpm
Cc: michel, jglisse, mhocko, vbabka, hannes, mgorman, dave, willy,
liam.howlett, peterz, ldufour, paulmck, mingo, will, luto,
songliubraving, peterx, david, dhowells, hughd, bigeasy,
kent.overstreet, punit.agrawal, lstoakes, peterjung1337,
rientjes, axelrasmussen, joelaf, minchan, rppt, 42.hyeyoo, jannh,
shakeelb, tatashin, edumazet, gthelen, gurua, arjunroy, soheil,
leewalsh, posk, linux-mm, linux-arm-kernel, linuxppc-dev, x86,
linux-kernel, kernel-team, surenb
Provide vm_flags_reset_once() and replace the vm_flags updates which used
WRITE_ONCE() to prevent compiler optimizations.
Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
Notes:
- The patch applies cleanly over mm-unstable
- The SHA in Fixes: line is from mm-unstable, so is... unstable
include/linux/mm.h | 7 +++++++
mm/mlock.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5bf0ad48faaa..23ce04f6e91e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
vm_flags_init(vma, flags);
}
+static inline void vm_flags_reset_once(struct vm_area_struct *vma,
+ vm_flags_t flags)
+{
+ mmap_assert_write_locked(vma->vm_mm);
+ WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
+}
+
static inline void vm_flags_set(struct vm_area_struct *vma,
vm_flags_t flags)
{
diff --git a/mm/mlock.c b/mm/mlock.c
index ed49459e343e..617469fce96d 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
*/
if (newflags & VM_LOCKED)
newflags |= VM_IO;
- vm_flags_reset(vma, newflags);
+ vm_flags_reset_once(vma, newflags);
lru_add_drain();
walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
@@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
if (newflags & VM_IO) {
newflags &= ~VM_IO;
- vm_flags_reset(vma, newflags);
+ vm_flags_reset_once(vma, newflags);
}
}
--
2.39.1.456.gfc5497dd1b-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
2023-02-01 0:01 ` Suren Baghdasaryan
(?)
@ 2023-02-01 7:43 ` Michal Hocko
-1 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2023-02-01 7:43 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, michel, jglisse, vbabka, hannes, mgorman, dave, willy,
liam.howlett, peterz, ldufour, paulmck, mingo, will, luto,
songliubraving, peterx, david, dhowells, hughd, bigeasy,
kent.overstreet, punit.agrawal, lstoakes, peterjung1337,
rientjes, axelrasmussen, joelaf, minchan, rppt, 42.hyeyoo, jannh,
shakeelb, tatashin, edumazet, gthelen, gurua, arjunroy, soheil,
leewalsh, posk, linux-mm, linux-arm-kernel, linuxppc-dev, x86,
linux-kernel, kernel-team
On Tue 31-01-23 16:01:16, Suren Baghdasaryan wrote:
> Provide vm_flags_reset_once() and replace the vm_flags updates which used
> WRITE_ONCE() to prevent compiler optimizations.
>
> Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
> Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This would have been better folded into the vm_flags modification patch
because it would be more obvious change. Hugh has provided a very nice
comment in mlock_vma_pages_range but the git blame would be more visible
when the conversion is from WRITE_ONCE.
One way or the other
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> Notes:
> - The patch applies cleanly over mm-unstable
> - The SHA in Fixes: line is from mm-unstable, so is... unstable
>
> include/linux/mm.h | 7 +++++++
> mm/mlock.c | 4 ++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5bf0ad48faaa..23ce04f6e91e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
> vm_flags_init(vma, flags);
> }
>
> +static inline void vm_flags_reset_once(struct vm_area_struct *vma,
> + vm_flags_t flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
> +}
> +
> static inline void vm_flags_set(struct vm_area_struct *vma,
> vm_flags_t flags)
> {
> diff --git a/mm/mlock.c b/mm/mlock.c
> index ed49459e343e..617469fce96d 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> */
> if (newflags & VM_LOCKED)
> newflags |= VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
>
> lru_add_drain();
> walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
> @@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
>
> if (newflags & VM_IO) {
> newflags &= ~VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
> }
> }
>
> --
> 2.39.1.456.gfc5497dd1b-goog
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
@ 2023-02-01 7:43 ` Michal Hocko
0 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2023-02-01 7:43 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: michel, joelaf, songliubraving, leewalsh, david, peterz, bigeasy,
peterx, dhowells, linux-mm, edumazet, jglisse, punit.agrawal,
42.hyeyoo, will, arjunroy, dave, minchan, x86, hughd, willy,
gurua, mingo, linux-arm-kernel, rientjes, axelrasmussen,
kernel-team, soheil, paulmck, jannh, liam.howlett, shakeelb,
luto, gthelen, ldufour, vbabka, posk, lstoakes, peterjung1337,
linuxppc-dev, kent.overstreet, linux-kernel, hannes, akpm,
tatashin, mgorman
On Tue 31-01-23 16:01:16, Suren Baghdasaryan wrote:
> Provide vm_flags_reset_once() and replace the vm_flags updates which used
> WRITE_ONCE() to prevent compiler optimizations.
>
> Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
> Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This would have been better folded into the vm_flags modification patch
because it would be more obvious change. Hugh has provided a very nice
comment in mlock_vma_pages_range but the git blame would be more visible
when the conversion is from WRITE_ONCE.
One way or the other
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> Notes:
> - The patch applies cleanly over mm-unstable
> - The SHA in Fixes: line is from mm-unstable, so is... unstable
>
> include/linux/mm.h | 7 +++++++
> mm/mlock.c | 4 ++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5bf0ad48faaa..23ce04f6e91e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
> vm_flags_init(vma, flags);
> }
>
> +static inline void vm_flags_reset_once(struct vm_area_struct *vma,
> + vm_flags_t flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
> +}
> +
> static inline void vm_flags_set(struct vm_area_struct *vma,
> vm_flags_t flags)
> {
> diff --git a/mm/mlock.c b/mm/mlock.c
> index ed49459e343e..617469fce96d 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> */
> if (newflags & VM_LOCKED)
> newflags |= VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
>
> lru_add_drain();
> walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
> @@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
>
> if (newflags & VM_IO) {
> newflags &= ~VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
> }
> }
>
> --
> 2.39.1.456.gfc5497dd1b-goog
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
@ 2023-02-01 7:43 ` Michal Hocko
0 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2023-02-01 7:43 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, michel, jglisse, vbabka, hannes, mgorman, dave, willy,
liam.howlett, peterz, ldufour, paulmck, mingo, will, luto,
songliubraving, peterx, david, dhowells, hughd, bigeasy,
kent.overstreet, punit.agrawal, lstoakes, peterjung1337,
rientjes, axelrasmussen, joelaf, minchan, rppt, 42.hyeyoo, jannh,
shakeelb, tatashin, edumazet, gthelen, gurua, arjunroy, soheil,
leewalsh, posk, linux-mm, linux-arm-kernel, linuxppc-dev, x86,
linux-kernel, kernel-team
On Tue 31-01-23 16:01:16, Suren Baghdasaryan wrote:
> Provide vm_flags_reset_once() and replace the vm_flags updates which used
> WRITE_ONCE() to prevent compiler optimizations.
>
> Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
> Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This would have been better folded into the vm_flags modification patch
because it would be more obvious change. Hugh has provided a very nice
comment in mlock_vma_pages_range but the git blame would be more visible
when the conversion is from WRITE_ONCE.
One way or the other
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> Notes:
> - The patch applies cleanly over mm-unstable
> - The SHA in Fixes: line is from mm-unstable, so is... unstable
>
> include/linux/mm.h | 7 +++++++
> mm/mlock.c | 4 ++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5bf0ad48faaa..23ce04f6e91e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
> vm_flags_init(vma, flags);
> }
>
> +static inline void vm_flags_reset_once(struct vm_area_struct *vma,
> + vm_flags_t flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
> +}
> +
> static inline void vm_flags_set(struct vm_area_struct *vma,
> vm_flags_t flags)
> {
> diff --git a/mm/mlock.c b/mm/mlock.c
> index ed49459e343e..617469fce96d 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> */
> if (newflags & VM_LOCKED)
> newflags |= VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
>
> lru_add_drain();
> walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
> @@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
>
> if (newflags & VM_IO) {
> newflags &= ~VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
> }
> }
>
> --
> 2.39.1.456.gfc5497dd1b-goog
--
Michal Hocko
SUSE Labs
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
2023-02-01 0:01 ` Suren Baghdasaryan
@ 2023-02-08 1:46 ` Hyeonggon Yoo
-1 siblings, 0 replies; 8+ messages in thread
From: Hyeonggon Yoo @ 2023-02-08 1:46 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, michel, jglisse, mhocko, vbabka, hannes, mgorman, dave,
willy, liam.howlett, peterz, ldufour, paulmck, mingo, will, luto,
songliubraving, peterx, david, dhowells, hughd, bigeasy,
kent.overstreet, punit.agrawal, lstoakes, peterjung1337,
rientjes, axelrasmussen, joelaf, minchan, rppt, jannh, shakeelb,
tatashin, edumazet, gthelen, gurua, arjunroy, soheil, leewalsh,
posk, linux-mm, linux-arm-kernel, linuxppc-dev, x86,
linux-kernel, kernel-team
On Tue, Jan 31, 2023 at 04:01:16PM -0800, Suren Baghdasaryan wrote:
> Provide vm_flags_reset_once() and replace the vm_flags updates which used
> WRITE_ONCE() to prevent compiler optimizations.
>
> Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
> Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> Notes:
> - The patch applies cleanly over mm-unstable
> - The SHA in Fixes: line is from mm-unstable, so is... unstable
>
> include/linux/mm.h | 7 +++++++
> mm/mlock.c | 4 ++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5bf0ad48faaa..23ce04f6e91e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
> vm_flags_init(vma, flags);
> }
>
> +static inline void vm_flags_reset_once(struct vm_area_struct *vma,
> + vm_flags_t flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
> +}
> +
> static inline void vm_flags_set(struct vm_area_struct *vma,
> vm_flags_t flags)
> {
> diff --git a/mm/mlock.c b/mm/mlock.c
> index ed49459e343e..617469fce96d 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> */
> if (newflags & VM_LOCKED)
> newflags |= VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
>
> lru_add_drain();
> walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
> @@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
>
> if (newflags & VM_IO) {
> newflags &= ~VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
> }
> }
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
>
> --
> 2.39.1.456.gfc5497dd1b-goog
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates
@ 2023-02-08 1:46 ` Hyeonggon Yoo
0 siblings, 0 replies; 8+ messages in thread
From: Hyeonggon Yoo @ 2023-02-08 1:46 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: michel, joelaf, songliubraving, mhocko, leewalsh, david, peterz,
bigeasy, peterx, dhowells, linux-mm, edumazet, jglisse,
punit.agrawal, will, arjunroy, dave, minchan, x86, hughd, willy,
gurua, mingo, linux-arm-kernel, rientjes, axelrasmussen,
kernel-team, soheil, paulmck, jannh, liam.howlett, shakeelb,
luto, gthelen, ldufour, vbabka, posk, lstoakes, peterjung1337,
linuxppc-dev, kent.overstreet, linux-kernel, hannes, akpm,
tatashin, mgorman, rppt
On Tue, Jan 31, 2023 at 04:01:16PM -0800, Suren Baghdasaryan wrote:
> Provide vm_flags_reset_once() and replace the vm_flags updates which used
> WRITE_ONCE() to prevent compiler optimizations.
>
> Fixes: 0cce31a0aa0e ("mm: replace vma->vm_flags direct modifications with modifier calls")
> Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> Notes:
> - The patch applies cleanly over mm-unstable
> - The SHA in Fixes: line is from mm-unstable, so is... unstable
>
> include/linux/mm.h | 7 +++++++
> mm/mlock.c | 4 ++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5bf0ad48faaa..23ce04f6e91e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -648,6 +648,13 @@ static inline void vm_flags_reset(struct vm_area_struct *vma,
> vm_flags_init(vma, flags);
> }
>
> +static inline void vm_flags_reset_once(struct vm_area_struct *vma,
> + vm_flags_t flags)
> +{
> + mmap_assert_write_locked(vma->vm_mm);
> + WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
> +}
> +
> static inline void vm_flags_set(struct vm_area_struct *vma,
> vm_flags_t flags)
> {
> diff --git a/mm/mlock.c b/mm/mlock.c
> index ed49459e343e..617469fce96d 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -380,7 +380,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> */
> if (newflags & VM_LOCKED)
> newflags |= VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
>
> lru_add_drain();
> walk_page_range(vma->vm_mm, start, end, &mlock_walk_ops, NULL);
> @@ -388,7 +388,7 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
>
> if (newflags & VM_IO) {
> newflags &= ~VM_IO;
> - vm_flags_reset(vma, newflags);
> + vm_flags_reset_once(vma, newflags);
> }
> }
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
>
> --
> 2.39.1.456.gfc5497dd1b-goog
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-02-08 1:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 0:01 [PATCH 1/1] mm: introduce vm_flags_reset_once to replace WRITE_ONCE vm_flags updates Suren Baghdasaryan
2023-02-01 0:01 ` Suren Baghdasaryan
2023-02-01 0:01 ` Suren Baghdasaryan
2023-02-01 7:43 ` Michal Hocko
2023-02-01 7:43 ` Michal Hocko
2023-02-01 7:43 ` Michal Hocko
2023-02-08 1:46 ` Hyeonggon Yoo
2023-02-08 1:46 ` Hyeonggon Yoo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.