public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v5 0/2] sched/starvation: Choose from available cpus
@ 2024-06-19 16:28 Edward Liaw via ltp
  2024-06-19 16:28 ` [LTP] [PATCH v5 1/2] sched/starvation: Fix sched_setaffinity return check Edward Liaw via ltp
  2024-06-19 16:28 ` [LTP] [PATCH v5 2/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
  0 siblings, 2 replies; 4+ messages in thread
From: Edward Liaw via ltp @ 2024-06-19 16:28 UTC (permalink / raw)
  To: ltp; +Cc: kernel-team

The starvation test was failing as a 32bit test for some arm
architectures where cpu 0 does not support 32bit applications.

v1: https://lore.kernel.org/ltp/20240605180536.1288027-1-edliaw@google.com/

v2: https://lore.kernel.org/ltp/20240606014022.1425928-1-edliaw@google.com/
Made these substitutions based on Wei's suggestions:
s/TST_EXP_POSITIVE/TST_EXP_PASS
s/TCONF/TBROK

v3: https://lore.kernel.org/ltp/20240606173933.1671989-1-edliaw@google.com/
Substituted test macros with check based on Petr's suggestions.
Split commit into two: first to fix the return code check on
sched_setaffinity.  Second to choose the cpu.

v4: https://lore.kernel.org/ltp/20240613210059.352767-1-edliaw@google.com/
Fixed some typos and commit tags.

v5:
Got the return code check reversed again.  Fixed it.

Edward Liaw via ltp (2):
  sched/starvation: Fix sched_setaffinity return check
  sched/starvation: Choose from available cpus

 .../kernel/sched/cfs-scheduler/starvation.c   | 21 +++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

--
2.45.2.627.g7a2c4fd464-goog


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

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

* [LTP] [PATCH v5 1/2] sched/starvation: Fix sched_setaffinity return check
  2024-06-19 16:28 [LTP] [PATCH v5 0/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
@ 2024-06-19 16:28 ` Edward Liaw via ltp
  2024-06-19 16:28 ` [LTP] [PATCH v5 2/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
  1 sibling, 0 replies; 4+ messages in thread
From: Edward Liaw via ltp @ 2024-06-19 16:28 UTC (permalink / raw)
  To: ltp; +Cc: kernel-team

From: Edward Liaw via ltp <ltp@lists.linux.it>

TST_EXP_POSITIVE to check the return value is incorrect because
sched_setaffinity returns 0 on success / -1 on failure.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Edward Liaw <edliaw@google.com>
---
 testcases/kernel/sched/cfs-scheduler/starvation.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c
index eb9fd6ff5..c845af849 100644
--- a/testcases/kernel/sched/cfs-scheduler/starvation.c
+++ b/testcases/kernel/sched/cfs-scheduler/starvation.c
@@ -54,7 +54,8 @@ static void setup(void)
 
 	CPU_SET(0, &mask);
 
-	TST_EXP_POSITIVE(sched_setaffinity(0, sizeof(mask), &mask));
+	if (sched_setaffinity(0, sizeof(mask), &mask) < 0)
+		tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");
 
 	if (tst_parse_long(str_loop, &loop, 1, LONG_MAX))
 		tst_brk(TBROK, "Invalid number of loop number '%s'", str_loop);
-- 
2.45.2.627.g7a2c4fd464-goog


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

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

* [LTP] [PATCH v5 2/2] sched/starvation: Choose from available cpus
  2024-06-19 16:28 [LTP] [PATCH v5 0/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
  2024-06-19 16:28 ` [LTP] [PATCH v5 1/2] sched/starvation: Fix sched_setaffinity return check Edward Liaw via ltp
@ 2024-06-19 16:28 ` Edward Liaw via ltp
  2024-06-19 17:50   ` Petr Vorel
  1 sibling, 1 reply; 4+ messages in thread
From: Edward Liaw via ltp @ 2024-06-19 16:28 UTC (permalink / raw)
  To: ltp; +Cc: kernel-team

From: Edward Liaw via ltp <ltp@lists.linux.it>

Use the first available cpu in the sched_getaffinity set.

This test was failing as a 32bit test for some arm architectures where
cpu 0 does not support 32bit applications.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Edward Liaw <edliaw@google.com>
---
 .../kernel/sched/cfs-scheduler/starvation.c    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c
index c845af849..9ac388fdc 100644
--- a/testcases/kernel/sched/cfs-scheduler/starvation.c
+++ b/testcases/kernel/sched/cfs-scheduler/starvation.c
@@ -49,10 +49,26 @@ again:
 static void setup(void)
 {
 	cpu_set_t mask;
+	int cpu = 0;
+	long ncpus = tst_ncpus_conf();
 
 	CPU_ZERO(&mask);
 
-	CPU_SET(0, &mask);
+	/* Restrict test to a single cpu */
+	if (sched_getaffinity(0, sizeof(mask), &mask) < 0)
+		tst_brk(TBROK | TERRNO, "sched_getaffinity() failed");
+
+	if (CPU_COUNT(&mask) == 0)
+		tst_brk(TBROK, "No cpus available");
+
+	while (CPU_ISSET(cpu, &mask) == 0 && cpu < ncpus)
+		cpu++;
+
+	CPU_ZERO(&mask);
+
+	CPU_SET(cpu, &mask);
+
+	tst_res(TINFO, "Setting affinity to CPU %d", cpu);
 
 	if (sched_setaffinity(0, sizeof(mask), &mask) < 0)
 		tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");
-- 
2.45.2.627.g7a2c4fd464-goog


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

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

* Re: [LTP] [PATCH v5 2/2] sched/starvation: Choose from available cpus
  2024-06-19 16:28 ` [LTP] [PATCH v5 2/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
@ 2024-06-19 17:50   ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2024-06-19 17:50 UTC (permalink / raw)
  To: Edward Liaw; +Cc: kernel-team, ltp

Hi Edward,

Thanks a lot for spotting reversed return code check in v4.
merged, thank you!

Kind regards,
Petr

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

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

end of thread, other threads:[~2024-06-19 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 16:28 [LTP] [PATCH v5 0/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
2024-06-19 16:28 ` [LTP] [PATCH v5 1/2] sched/starvation: Fix sched_setaffinity return check Edward Liaw via ltp
2024-06-19 16:28 ` [LTP] [PATCH v5 2/2] sched/starvation: Choose from available cpus Edward Liaw via ltp
2024-06-19 17:50   ` Petr Vorel

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