Message ID | CAJwJo6ZGatGFWaYmnk8TyBqBGVPdqVLS1MO3xX4i_x1o4ZjpWw@mail.gmail.com |
---|---|
State | New |
Series | "zdtm/static/fd failure on aarch64" |
Headers | show |
From d8f77e9731c0ab36f32c31016e2856991950b64d Mon Sep 17 00:00:00 2001 From: Dmitry Safonov <dima@arista.com> Date: Mon, 11 Jun 2018 15:44:07 +0100 Subject: [PATCH] zdtm/lib: Check EWOULDBLOCK in errno instead of -EWOULDBLOCK Syscalls do return negative value in case of an error. But errno contains the error code itself. Add uint32_t to sys_futex() definition. sizeof(unsigned int) might be not 4 bytes. Signed-off-by: Dmitry Safonov <dima@arista.com> --- test/zdtm/lib/lock.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/zdtm/lib/lock.h b/test/zdtm/lib/lock.h index 972ed5769a9f..9c0831d461c1 100644 --- a/test/zdtm/lib/lock.h +++ b/test/zdtm/lib/lock.h @@ -23,8 +23,8 @@ typedef struct { #define FUTEX_ABORT_FLAG (0x80000000) #define FUTEX_ABORT_RAW (-1U) -static inline int sys_futex(unsigned int *uaddr, int op, unsigned int val, const struct timespec *timeout, - int *uaddr2, unsigned int val3) +static inline int sys_futex(uint32_t *uaddr, int op, uint32_t val, const struct timespec *timeout, + uint32_t *uaddr2, uint32_t val3) { return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3); } @@ -142,11 +142,11 @@ static void inline mutex_lock(mutex_t *m) uint32_t c; int ret; - while ((c = atomic_inc(&m->raw))) { + while ((c = atomic_inc(&m->raw)) != 0) { ret = sys_futex(&m->raw, FUTEX_WAIT, c + 1, NULL, NULL, 0); if (ret < 0) pr_perror("futex"); - BUG_ON(ret < 0 && errno != -EWOULDBLOCK); + BUG_ON(ret < 0 && errno != EWOULDBLOCK); } } -- 2.13.6
On Mon, Jun 11, 2018 at 09:19:21PM +0100, Dmitry Safonov wrote: > I'm awfully sorry about asking you so many times.. > Maybe the thing is in sizeof(unsigned int) != 4 on arm64? > > Returning back to the first version + correcting definition for syscall. This was also something I was suspecting, that the syscall is not done correctly, but your patch does not help. Same result: 5085 dup3(4, 0, 0) = 0 5085 close(4) = 0 5085 mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, 0, 0) = 0xffff97050000 5085 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xffff970b2dd0) = 5086 5085 futex(0xffff97050000, FUTEX_WAIT, 0, NULL <unfinished ...> 5086 setsid() = 5086 5086 rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTART}, NULL, 8) = 0 5086 mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0xffff96eb0000 5086 futex(0xffff96eb0000, FUTEX_WAIT, 2531983361, NULL) = -1 EAGAIN (Resource temporarily unavailable) 5086 brk(NULL) = 0x2e920000 5086 brk(0x2e950000) = 0x2e950000 5086 brk(NULL) = 0x2e950000 5086 openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC) = 4 5086 fstat(4, {st_mode=S_IFREG|0644, st_size=3519, ...}) = 0 5086 fstat(4, {st_mode=S_IFREG|0644, st_size=3519, ...}) = 0 5086 mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff96ea0000 5086 read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0\0\0\0"..., 8192) = 3519 5086 lseek(4, -2252, SEEK_CUR) = 1267 5086 read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\0\5\0\0\0\0"..., 8192) = 2252 5086 close(4) = 0 5086 munmap(0xffff96ea0000, 65536) = 0 5086 write(2, "16:31:33.969: 5086: ERR: ../lib"..., 99) = 99 5086 futex(0xffff96eb0000, FUTEX_WAIT, 2531983361, NULL) = -1 EAGAIN (Resource temporarily unavailable) 5086 newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0644, st_size=3519, ...}, 0) = 0 5086 write(2, "16:31:33.971: 5086: ERR: ../lib"..., 99) = 99 5086 futex(0xffff96eb0000, FUTEX_WAIT, 2531983361, NULL) = -1 EAGAIN (Resource temporarily unavailable) 5086 newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0644, st_size=3519, ...}, 0) = 0 5086 write(2, "16:31:33.971: 5086: ERR: ../lib"..., 99) = 99 Adrian