[CRIU] [PATCH] arm: fix atomic_{add,sub}_return

Dmitry Safonov 0x7f454c46 at gmail.com
Tue Apr 23 17:28:53 MSK 2019


On Sun, 21 Apr 2019 at 09:33, Andrei Vagin <avagin at gmail.com> wrote:
>
> Now, this code doesn't pass this simple test:
>
>         atomic_t a;;
>         int c = 0;
>         atomic_set(&a, c);
>         c = atomic_inc(&a);
>         if (c != 0) {
>                 pr_err("c = %x &a = %p\n", c, &a);
>                 return 1;
>         }
>
> 08:28:51.771: 26187: ERR: fd.c:36: c = 7ef47a60 &a = 0x7ef47a60
>
> Reported-by: Mr Jenkins
> Signed-off-by: Andrei Vagin <avagin at gmail.com>

Reviewed-by: Dmitry Safonov <0x7f454c46 at gmail.com>

P.S.
Oops, I should have noted this at that time:
https://lists.openvz.org/pipermail/criu/2018-June/041611.html
(commit 19de949023af)

> ---
>  test/zdtm/lib/arch/arm/include/asm/atomic.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/test/zdtm/lib/arch/arm/include/asm/atomic.h b/test/zdtm/lib/arch/arm/include/asm/atomic.h
> index bcf3fe31b..0ff76408d 100644
> --- a/test/zdtm/lib/arch/arm/include/asm/atomic.h
> +++ b/test/zdtm/lib/arch/arm/include/asm/atomic.h
> @@ -25,8 +25,8 @@ static inline unsigned int atomic_add_return(int i, atomic_t *v)
>  "      strex   %1, %0, [%3]\n"
>  "      teq     %1, #0\n"
>  "      bne     1b\n"
> -       : "=&r" (result), "=&r" (tmp), "+Qo" (v)
> -        : "r" (&v), "Ir" (i)
> +       : "=&r" (result), "=&r" (tmp), "+Qo" (*v)
> +        : "r" (v), "Ir" (i)
>         : "cc");
>
>         smp_mb();
> @@ -47,8 +47,8 @@ static inline unsigned int atomic_sub_return(int i, atomic_t *v)
>  "      strex   %1, %0, [%3]\n"
>  "      teq     %1, #0\n"
>  "      bne     1b\n"
> -       : "=&r" (result), "=&r" (tmp), "+Qo" (v)
> -       : "r" (&v), "Ir" (i)
> +       : "=&r" (result), "=&r" (tmp), "+Qo" (*v)
> +       : "r" (v), "Ir" (i)
>         : "cc");
>
>         smp_mb();
> --
> 2.20.1
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu



-- 
             Dmitry


More information about the CRIU mailing list