diff mbox series

mm: Pair atomic_read_release() with _acquire()

Message ID 20241021-atomic-read-acquire-v1-1-4dee71191c06@linaro.org (mailing list archive)
State New, archived
Headers show
Series mm: Pair atomic_read_release() with _acquire() | expand

Commit Message

Linus Walleij Oct. 21, 2024, 8:53 a.m. UTC
The code for syncing vmalloc memory PGD pointers is using
atomic_read() in pair with atomic_read_release() but the
proper pairing is atomic_read_acquire() paired with
atomic_read_release().

Fixes: d31e23aff011 ("ARM: mm: make vmalloc_seq handling SMP safe")
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
This patch was done on top of Melon Liu's patch:
https://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=9427/1
---
 arch/arm/mm/ioremap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: d530f55d9fde0aae4ac90e072b288da13f6aae81
change-id: 20241021-atomic-read-acquire-52a667991cfc

Best regards,

Comments

Ard Biesheuvel Oct. 21, 2024, 9:16 a.m. UTC | #1
Hi Linus,

On Mon, 21 Oct 2024 at 10:53, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> The code for syncing vmalloc memory PGD pointers is using
> atomic_read() in pair with atomic_read_release() but the
> proper pairing is atomic_read_acquire() paired with
> atomic_read_release().
>

atomic_read_release() does not exist.

Maybe explain here that the read_acquire() prevents
sync_vmalloc_pgds() from observing stale init_mm contents?



> Fixes: d31e23aff011 ("ARM: mm: make vmalloc_seq handling SMP safe")
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> This patch was done on top of Melon Liu's patch:
> https://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=9427/1
> ---
>  arch/arm/mm/ioremap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
> index f952b0b0f8a5..257ed86f3474 100644
> --- a/arch/arm/mm/ioremap.c
> +++ b/arch/arm/mm/ioremap.c
> @@ -138,7 +138,7 @@ void __check_vmalloc_seq(struct mm_struct *mm)
>         int seq;
>
>         do {
> -               seq = atomic_read(&init_mm.context.vmalloc_seq);
> +               seq = atomic_read_acquire(&init_mm.context.vmalloc_seq);
>                 sync_vmalloc_pgds(mm);
>                 /*
>                  * Use a store-release so that other CPUs that observe the
>
> ---
> base-commit: d530f55d9fde0aae4ac90e072b288da13f6aae81
> change-id: 20241021-atomic-read-acquire-52a667991cfc
>
> Best regards,
> --
> Linus Walleij <linus.walleij@linaro.org>
>
diff mbox series

Patch

diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index f952b0b0f8a5..257ed86f3474 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -138,7 +138,7 @@  void __check_vmalloc_seq(struct mm_struct *mm)
 	int seq;
 
 	do {
-		seq = atomic_read(&init_mm.context.vmalloc_seq);
+		seq = atomic_read_acquire(&init_mm.context.vmalloc_seq);
 		sync_vmalloc_pgds(mm);
 		/*
 		 * Use a store-release so that other CPUs that observe the