Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] perf_event_open02: set process as RT during Setup stage
@ 2025-02-27 18:49 Edward Liaw via ltp
  2025-03-18 11:19 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Edward Liaw via ltp @ 2025-02-27 18:49 UTC (permalink / raw)
  To: ltp; +Cc: kuan-ying.zhu, kernel-team

From: "kuan-ying.zhu" <kuan-ying.zhu@mediatek.com>

Move the action of set the task RT from the Verify stage to the Setup
stage. Avoid potential risks of task migration due to scheduler policy.

Signed-off-by: kuan-ying.zhu <kuan-ying.zhu@mediatek.com>
Signed-off-by: Edward Liaw <edliaw@google.com>
---
 .../syscalls/perf_event_open/perf_event_open02.c    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index 7306ecf51..7b3305a52 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -198,6 +198,12 @@ static void setup(void)
 {
 	int i;
 	struct perf_event_attr tsk_event, hw_event;
+	struct sched_param sparam = {.sched_priority = 1};
+
+	if (sched_setscheduler(0, SCHED_FIFO, &sparam)) {
+		tst_brk(TBROK | TERRNO,
+			"sched_setscheduler(0, SCHED_FIFO, ...) failed");
+	}
 
 	for (i = 0; i < MAX_CTRS; i++) {
 		hwfd[i] = -1;
@@ -271,12 +277,7 @@ static void verify(void)
 	unsigned long long vtsum = 0, vhsum = 0;
 	int i;
 	double ratio;
-	struct sched_param sparam = {.sched_priority = 1};
-
-	if (sched_setscheduler(0, SCHED_FIFO, &sparam)) {
-		tst_brk(TBROK | TERRNO,
-			"sched_setscheduler(0, SCHED_FIFO, ...) failed");
-	}
+	struct sched_param sparam = {.sched_priority = 0};
 
 	all_counters_set(PR_TASK_PERF_EVENTS_ENABLE);
 	do_work(8);
-- 
2.48.1.711.g2feabab25a-goog


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

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

* Re: [LTP] [PATCH] perf_event_open02: set process as RT during Setup stage
  2025-02-27 18:49 [LTP] [PATCH] perf_event_open02: set process as RT during Setup stage Edward Liaw via ltp
@ 2025-03-18 11:19 ` Cyril Hrubis
  2025-05-05  7:09   ` [LTP] 回覆: " Kuan-ying Zhu (朱冠穎) via ltp
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2025-03-18 11:19 UTC (permalink / raw)
  To: Edward Liaw; +Cc: kuan-ying.zhu, kernel-team, ltp

Hi!
> Move the action of set the task RT from the Verify stage to the Setup
> stage. Avoid potential risks of task migration due to scheduler policy.

What exactly goes wrong if we switch to the realtime policy later? I
see that we do bench_work(500) at the start of the setup. That may mean
that we may get different estimate on how many loops we do per second,
but that would only mean that the test would run for shorter time.

We also do bind_to_current_cpu() just after that, the task shouldn't be
migrated after that.

The actual change looks reasonable, however the patch description should
tell why we need to do this change.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* [LTP] 回覆:  [PATCH] perf_event_open02: set process as RT during Setup stage
  2025-03-18 11:19 ` Cyril Hrubis
@ 2025-05-05  7:09   ` Kuan-ying Zhu (朱冠穎) via ltp
  0 siblings, 0 replies; 3+ messages in thread
From: Kuan-ying Zhu (朱冠穎) via ltp @ 2025-05-05  7:09 UTC (permalink / raw)
  To: Cyril Hrubis, Edward Liaw; +Cc: kernel-team@android.com, ltp@lists.linux.it

Hi,

Because in mobile products, power consumption requirements may cause the CPU to enter a temporary isolation state (CPU is active but tasks are not assigned) to save power. At this time, task affinity may fail. Therefore, to avoid testing errors caused by power-saving features related to this issue in embedded devices, this suggestion is proposed.

Kuan-ying.Zhu
Kuan-ying.Zhu@mediatek.com

________________________________
寄件者: Cyril Hrubis
已傳送: 星期二, 2025 年 3 月 18 日 下午 07:19
收件者: Edward Liaw
副本: ltp@lists.linux.it; Kuan-ying Zhu (朱冠穎); kernel-team@android.com
主旨: Re: [LTP] [PATCH] perf_event_open02: set process as RT during Setup stage


External email : Please do not click links or open attachments until you have verified the sender or the content.


Hi!
> Move the action of set the task RT from the Verify stage to the Setup
> stage. Avoid potential risks of task migration due to scheduler policy.

What exactly goes wrong if we switch to the realtime policy later? I
see that we do bench_work(500) at the start of the setup. That may mean
that we may get different estimate on how many loops we do per second,
but that would only mean that the test would run for shorter time.

We also do bind_to_current_cpu() just after that, the task shouldn't be
migrated after that.

The actual change looks reasonable, however the patch description should
tell why we need to do this change.

--
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2025-05-07 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 18:49 [LTP] [PATCH] perf_event_open02: set process as RT during Setup stage Edward Liaw via ltp
2025-03-18 11:19 ` Cyril Hrubis
2025-05-05  7:09   ` [LTP] 回覆: " Kuan-ying Zhu (朱冠穎) via ltp

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