public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] pidns32: fix PID namespace nesting depth off-by-one
@ 2026-04-02 20:55 Petr Vorel
  2026-04-02 20:55 ` [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add() Petr Vorel
  2026-04-02 20:55 ` [LTP] [PATCH v2 2/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2026-04-02 20:55 UTC (permalink / raw)
  To: ltp; +Cc: Vasileios Almpanis

Hi,

I dared to speed up this effort.

Kind regards,
Petr

Petr Vorel (1):
  tst_atomic: Add tst_atomic_return_add()

Vasileios Almpanis (1):
  pidns32: fix PID namespace nesting depth off-by-one

 include/tst_atomic.h                        | 10 ++++++++++
 testcases/kernel/containers/pidns/pidns32.c |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

-- 
2.53.0


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

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

* [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add()
  2026-04-02 20:55 [LTP] [PATCH v2 0/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
@ 2026-04-02 20:55 ` Petr Vorel
  2026-04-03  1:58   ` Li Wang via ltp
  2026-04-07 11:54   ` Cyril Hrubis
  2026-04-02 20:55 ` [LTP] [PATCH v2 2/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
  1 sibling, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2026-04-02 20:55 UTC (permalink / raw)
  To: ltp; +Cc: Vasileios Almpanis

Combine atomic loading and adding.

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
https://lore.kernel.org/ltp/acqLzcXEo0uU0aSD@yuki.lan/

 include/tst_atomic.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/tst_atomic.h b/include/tst_atomic.h
index 9d255bc448..196399db31 100644
--- a/include/tst_atomic.h
+++ b/include/tst_atomic.h
@@ -30,6 +30,11 @@ static inline void tst_atomic_store(int32_t i, tst_atomic_t *v)
 	__atomic_store_n(v, i, __ATOMIC_SEQ_CST);
 }
 
+static inline int tst_atomic_return_add(int32_t i, tst_atomic_t *v)
+{
+	return __atomic_fetch_add(v, i, __ATOMIC_SEQ_CST);
+}
+
 #elif HAVE_SYNC_ADD_AND_FETCH == 1
 
 /* Use __sync built-ins (GCC >= 4.1), with explicit memory barriers. */
@@ -56,6 +61,11 @@ static inline void tst_atomic_store(int32_t i, tst_atomic_t *v)
 	__sync_synchronize();
 }
 
+static inline int tst_atomic_return_add(int32_t i, tst_atomic_t *v)
+{
+	return __sync_fetch_and_add(v, i);
+}
+
 #else
 # error "Your compiler does not support atomic operations (__atomic or __sync)"
 #endif
-- 
2.53.0


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

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

* [LTP] [PATCH v2 2/2] pidns32: fix PID namespace nesting depth off-by-one
  2026-04-02 20:55 [LTP] [PATCH v2 0/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
  2026-04-02 20:55 ` [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add() Petr Vorel
@ 2026-04-02 20:55 ` Petr Vorel
  2026-04-03  1:58   ` Li Wang via ltp
  1 sibling, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2026-04-02 20:55 UTC (permalink / raw)
  To: ltp; +Cc: Vasileios Almpanis

From: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>

The 2023 refactor used tst_atomic_inc() before clone with a zero-initial
counter, which only performed 31 CLONE_NEWPID nests while still expecting
MAXNEST (32). Use tst_atomic_return_add() so the shared counter runs
0..32 and the chain reaches 32 nested namespaces again.

Fixes: 647cfd468c3b ("Refactor pidns32 test using new LTP API")
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
[ pvorel: use tst_atomic_return_add() ]
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
v1: https://lore.kernel.org/ltp/20260330100750.858390-1-vasileios.almpanis@virtuozzo.com/

 testcases/kernel/containers/pidns/pidns32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/containers/pidns/pidns32.c b/testcases/kernel/containers/pidns/pidns32.c
index fc9bf0aaa0..2a9e2827fc 100644
--- a/testcases/kernel/containers/pidns/pidns32.c
+++ b/testcases/kernel/containers/pidns/pidns32.c
@@ -27,7 +27,7 @@ static pid_t child_func(void)
 {
 	pid_t cpid = 0;
 
-	if (tst_atomic_inc(level) == MAXNEST)
+	if (tst_atomic_return_add(1, level) == MAXNEST)
 		return cpid;
 
 	cpid = SAFE_CLONE(&args);
@@ -58,7 +58,7 @@ static void run(void)
 	if (!child_func())
 		return;
 
-	TST_EXP_EQ_LI(*level, MAXNEST);
+	TST_EXP_EQ_LI(*level-1, MAXNEST);
 }
 
 static struct tst_test test = {
-- 
2.53.0


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

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

* Re: [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add()
  2026-04-02 20:55 ` [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add() Petr Vorel
@ 2026-04-03  1:58   ` Li Wang via ltp
  2026-04-07 11:54   ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Li Wang via ltp @ 2026-04-03  1:58 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Vasileios Almpanis, ltp

On Thu, Apr 02, 2026 at 10:55:33PM +0200, Petr Vorel wrote:
> Combine atomic loading and adding.
> 
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>

Reviewed-by: Li Wang <liwang@redhat.com>

-- 
Regards,
Li Wang


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

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

* Re: [LTP] [PATCH v2 2/2] pidns32: fix PID namespace nesting depth off-by-one
  2026-04-02 20:55 ` [LTP] [PATCH v2 2/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
@ 2026-04-03  1:58   ` Li Wang via ltp
  0 siblings, 0 replies; 6+ messages in thread
From: Li Wang via ltp @ 2026-04-03  1:58 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Vasileios Almpanis, ltp

On Thu, Apr 02, 2026 at 10:55:34PM +0200, Petr Vorel wrote:
> From: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
> 
> The 2023 refactor used tst_atomic_inc() before clone with a zero-initial
> counter, which only performed 31 CLONE_NEWPID nests while still expecting
> MAXNEST (32). Use tst_atomic_return_add() so the shared counter runs
> 0..32 and the chain reaches 32 nested namespaces again.
> 
> Fixes: 647cfd468c3b ("Refactor pidns32 test using new LTP API")
> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
> [ pvorel: use tst_atomic_return_add() ]
> Signed-off-by: Petr Vorel <pvorel@suse.cz>

Reviewed-by: Li Wang <liwang@redhat.com>

-- 
Regards,
Li Wang


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

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

* Re: [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add()
  2026-04-02 20:55 ` [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add() Petr Vorel
  2026-04-03  1:58   ` Li Wang via ltp
@ 2026-04-07 11:54   ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2026-04-07 11:54 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Vasileios Almpanis, ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2026-04-07 11:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 20:55 [LTP] [PATCH v2 0/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
2026-04-02 20:55 ` [LTP] [PATCH v2 1/2] tst_atomic: Add tst_atomic_return_add() Petr Vorel
2026-04-03  1:58   ` Li Wang via ltp
2026-04-07 11:54   ` Cyril Hrubis
2026-04-02 20:55 ` [LTP] [PATCH v2 2/2] pidns32: fix PID namespace nesting depth off-by-one Petr Vorel
2026-04-03  1:58   ` Li Wang via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox