public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro
@ 2023-11-13 15:06 Martin Doucha
  2023-11-13 15:06 ` [LTP] [PATCH v2 2/2] keyctl02: Add delay between main loop iterations for RT kernels Martin Doucha
  2023-11-13 15:14 ` [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro Petr Vorel
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Doucha @ 2023-11-13 15:06 UTC (permalink / raw)
  To: Petr Vorel, ltp

Add helper macro for initializing the tst_kconfig_var structure
to simplify kernel config checks during test runtime.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1: New patch

 include/tst_kconfig.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
index cc0908ea8..8b24a8380 100644
--- a/include/tst_kconfig.h
+++ b/include/tst_kconfig.h
@@ -6,6 +6,14 @@
 #ifndef TST_KCONFIG_H__
 #define TST_KCONFIG_H__
 
+/**
+ * Initialization helper macro for struct tst_kconfig_var. Requires <string.h>
+ */
+#define TST_KCONFIG_INIT(confname) { \
+	.id = confname, \
+	.id_len = strlen(confname) \
+}
+
 struct tst_kconfig_var {
 	char id[64];
 	unsigned int id_len;
-- 
2.42.0


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

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

* [LTP] [PATCH v2 2/2] keyctl02: Add delay between main loop iterations for RT kernels
  2023-11-13 15:06 [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro Martin Doucha
@ 2023-11-13 15:06 ` Martin Doucha
  2023-11-13 15:14 ` [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro Petr Vorel
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Doucha @ 2023-11-13 15:06 UTC (permalink / raw)
  To: Petr Vorel, ltp

Realtime kernels have deferred thread cleanup which means that
exited and joined threads can still pile up and trigger cgroup
thread limits. Add 100us delay on RT kernels to limit the maximum
number of stale threads.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1:
- Moved KCONFIG_INIT() macro to include/tst_kconfig.h (see patch 1)
- Changed variable type to unsigned to prevent compiler warning in setup()

 testcases/kernel/syscalls/keyctl/keyctl02.c | 22 +++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/testcases/kernel/syscalls/keyctl/keyctl02.c b/testcases/kernel/syscalls/keyctl/keyctl02.c
index 35cc2838d..a3437d065 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl02.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl02.c
@@ -29,6 +29,7 @@
 
 #include "tst_safe_pthread.h"
 #include "tst_test.h"
+#include "tst_kconfig.h"
 #include "lapi/keyctl.h"
 
 #define LOOPS	20000
@@ -36,6 +37,7 @@
 #define PATH_KEY_COUNT_QUOTA	"/proc/sys/kernel/keys/root_maxkeys"
 
 static int orig_maxkeys;
+static int realtime_kernel;
 
 static void *do_read(void *arg)
 {
@@ -86,6 +88,15 @@ static void do_test(void)
 			tst_res(TINFO, "Runtime exhausted, exiting after %d loops", i);
 			break;
 		}
+
+		/*
+		 * Realtime kernel has deferred post-join thread cleanup which
+		 * may result in exhaustion of cgroup thread limit. Add delay
+		 * to limit the maximum number of stale threads to 4000
+		 * even with CONFIG_HZ=100.
+		 */
+		if (realtime_kernel)
+			usleep(100);
 	}
 
 	/*
@@ -126,8 +137,19 @@ static void do_test(void)
 
 static void setup(void)
 {
+	unsigned int i;
+	struct tst_kconfig_var rt_kconfigs[] = {
+		TST_KCONFIG_INIT("CONFIG_PREEMPT_RT"),
+		TST_KCONFIG_INIT("CONFIG_PREEMPT_RT_FULL")
+	};
+
 	SAFE_FILE_SCANF(PATH_KEY_COUNT_QUOTA, "%d", &orig_maxkeys);
 	SAFE_FILE_PRINTF(PATH_KEY_COUNT_QUOTA, "%d", orig_maxkeys + LOOPS + 1);
+
+	tst_kconfig_read(rt_kconfigs, ARRAY_SIZE(rt_kconfigs));
+
+	for (i = 0; i < ARRAY_SIZE(rt_kconfigs); i++)
+		realtime_kernel |= rt_kconfigs[i].choice == 'y';
 }
 
 static void cleanup(void)
-- 
2.42.0


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

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

* Re: [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro
  2023-11-13 15:06 [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro Martin Doucha
  2023-11-13 15:06 ` [LTP] [PATCH v2 2/2] keyctl02: Add delay between main loop iterations for RT kernels Martin Doucha
@ 2023-11-13 15:14 ` Petr Vorel
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2023-11-13 15:14 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

thanks for v2, patchset merged.

Kind regards,
Petr

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

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

end of thread, other threads:[~2023-11-13 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-13 15:06 [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro Martin Doucha
2023-11-13 15:06 ` [LTP] [PATCH v2 2/2] keyctl02: Add delay between main loop iterations for RT kernels Martin Doucha
2023-11-13 15:14 ` [LTP] [PATCH v2 1/2] Add TST_KCONFIG_INIT() helper macro Petr Vorel

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