eas: sched_boost: give time for utilization to track task usage
PELT will set the initial util_avg of a task to half the spare capacity
of the CPU the task starts to run on. This will cause problems for this
test since a task which is expected to be small will potenitally show a
large utilization while we are monitoring it.
Take half the test time (currently one second) to allow util_avg to
track the actual task usage prior to starting the trace and tracking the
max util_avg for comparison.
Bug: 144809570
Change-Id: Ie5d519078707749d94011dde3f13df7810955c7b
Signed-off-by: Steve Muckle <smuckle@google.com>
diff --git a/testcases/kernel/sched/eas/sched_boost.c b/testcases/kernel/sched/eas/sched_boost.c
index 09d69e0..26a72ae 100644
--- a/testcases/kernel/sched/eas/sched_boost.c
+++ b/testcases/kernel/sched/eas/sched_boost.c
@@ -40,6 +40,7 @@
#define SLEEP_USEC 19000
/* Run each test for one second. */
#define TEST_LENGTH_USEC USEC_PER_SEC
+
static void do_work(void)
{
struct timespec ts;
@@ -51,7 +52,7 @@
return;
}
now_usec = ts.tv_sec * USEC_PER_SEC + ts.tv_nsec / 1000;
- end_usec = now_usec + TEST_LENGTH_USEC;
+ end_usec = now_usec + TEST_LENGTH_USEC/2;
while (now_usec < end_usec) {
burn(BUSY_USEC, 0);
@@ -74,6 +75,10 @@
SAFE_FILE_PRINTF(STUNE_TEST_PATH "/tasks", "%d", task_pid);
while(tests_done < NUM_TESTS) {
sem_wait(&test_sem);
+ // give time for utilization to track real task usage
+ do_work();
+ // start measuring
+ SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1");
do_work();
sem_post(&result_sem);
tests_done++;
@@ -106,7 +111,6 @@
SAFE_FILE_PRINTF(STUNE_TEST_PATH "/schedtune.boost",
"%d", test_boost[test_index]);
SAFE_FILE_PRINTF(TRACING_DIR "trace", "\n");
- SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "1");
sem_post(&test_sem);
sem_wait(&result_sem);
SAFE_FILE_PRINTF(TRACING_DIR "tracing_on", "0");