All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS
@ 2022-03-25 18:44 Petr Vorel
  2022-03-28 14:53 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2022-03-25 18:44 UTC (permalink / raw)
  To: ltp

In some tests we are creating the namespaces faster than they are being
asynchronously cleaned up in the kernel. Thus retrying the clone() on
ENOSPC (or EUSERS for kernel < 4.9).

Before:
$ sudo ./userns08 -i 10
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:36: TBROK: clone3 failed: ENOSPC (28)

With fix:
$ sudo ./userns08 -i 10
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:38: TINFO: clone3() failed => retrying: ENOSPC (28)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_test.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 384c73e163..527d265d0a 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -446,6 +446,14 @@ pid_t safe_clone(const char *file, const int lineno,
 
 	pid = tst_clone(args);
 
+	/* too fast creating namespaces => retrying */
+	if (pid < 0 && (errno == ENOSPC || errno == EUSERS)) {
+		tst_res_(file, lineno, TINFO | TERRNO, "%s() failed => retrying",
+				 pid == -2 ? "clone" : "clone3");
+		usleep(100000);
+		pid = tst_clone(args);
+	}
+
 	switch (pid) {
 	case -1:
 		tst_brk_(file, lineno, TBROK | TERRNO, "clone3 failed");
-- 
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS
  2022-03-25 18:44 [LTP] [PATCH 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS Petr Vorel
@ 2022-03-28 14:53 ` Cyril Hrubis
  2022-03-28 19:48   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2022-03-28 14:53 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> +	/* too fast creating namespaces => retrying */
> +	if (pid < 0 && (errno == ENOSPC || errno == EUSERS)) {
> +		tst_res_(file, lineno, TINFO | TERRNO, "%s() failed => retrying",
> +				 pid == -2 ? "clone" : "clone3");
> +		usleep(100000);
> +		pid = tst_clone(args);

Wouldn't it make sense to use the exponential backof macro we have in
tst_common.h?

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS
  2022-03-28 14:53 ` Cyril Hrubis
@ 2022-03-28 19:48   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2022-03-28 19:48 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

> Hi!
> > +	/* too fast creating namespaces => retrying */
> > +	if (pid < 0 && (errno == ENOSPC || errno == EUSERS)) {
> > +		tst_res_(file, lineno, TINFO | TERRNO, "%s() failed => retrying",
> > +				 pid == -2 ? "clone" : "clone3");
> > +		usleep(100000);
> > +		pid = tst_clone(args);

> Wouldn't it make sense to use the exponential backof macro we have in
> tst_common.h?
+1 => I'll send v2.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-28 19:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 18:44 [LTP] [PATCH 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS Petr Vorel
2022-03-28 14:53 ` Cyril Hrubis
2022-03-28 19:48   ` Petr Vorel

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.