zdtm/static/fd failure on aarch64

Submitted by Dmitry Safonov on June 11, 2018, 3:22 p.m.

Details

Message ID CAJwJo6ZQd5U9cdO7WGp6oTf5LT-oVvAWHHMvfqEZBuBjpRsSmw@mail.gmail.com
State New
Series "zdtm/static/fd failure on aarch64"
Headers show

Commit Message

Dmitry Safonov June 11, 2018, 3:22 p.m.
2018-06-11 15:52 GMT+01:00 Adrian Reber <adrian@lisas.de>:
[...]
>> -             BUG_ON(ret < 0 && errno != -EWOULDBLOCK);
>> +             BUG_ON(ret < 0 && errno != EWOULDBLOCK);
>
> Now it goes into an endless loop writing
>
>  10:50:30.462:  3980: ERR: ../lib/lock.h:148: futex (errno = 11 (Resource temporarily unavailable))
>
> to the output file.

Probably, with the updated patch?

Patch hide | download patch | download mbox

From 2cfb81ca995d2f55453416e1255fdaf001b72977 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.

Also check that result of atomic_inc() is not 1, which
would mean that we've just acquired the mutex.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 test/zdtm/lib/lock.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/zdtm/lib/lock.h b/test/zdtm/lib/lock.h
index 972ed5769a9f..0a8c10771e49 100644
--- a/test/zdtm/lib/lock.h
+++ b/test/zdtm/lib/lock.h
@@ -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)) != 1) {
 		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


Comments

Adrian Reber June 11, 2018, 3:34 p.m.
On Mon, Jun 11, 2018 at 04:22:29PM +0100, Dmitry Safonov wrote:
> 2018-06-11 15:52 GMT+01:00 Adrian Reber <adrian@lisas.de>:
> [...]
> >> -             BUG_ON(ret < 0 && errno != -EWOULDBLOCK);
> >> +             BUG_ON(ret < 0 && errno != EWOULDBLOCK);
> >
> > Now it goes into an endless loop writing
> >
> >  10:50:30.462:  3980: ERR: ../lib/lock.h:148: futex (errno = 11 (Resource temporarily unavailable))
> >
> > to the output file.
> 
> Probably, with the updated patch?

No, still endless loop:

11:32:31.668:  4109: ERR: ../lib/lock.h:148: futex (errno = 11 (Resource temporarily unavailable))

[pid  4109] futex(0xffff87000000, FUTEX_WAIT, 2264924161, NULL) = -1 EAGAIN (Resource temporarily unavailable)
[pid  4109] newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0644, st_size=3519, ...}, 0) = 0
[pid  4109] write(2, "11:32:32.516:  4109: ERR: ../lib"..., 99) = 99

		Adrian