[Intel-gfx] [PATCH igt] tools/intel_residency: use setitimer instead of {, u}alarm

Morton, Derek J derek.j.morton at intel.com
Tue Jan 26 06:44:00 PST 2016


I verified this patch fixes the ualarm issue on android.

I posted the patch
[PATCH] tests/Android.mk: Make intel_residency CAIRO dependant
Which adds this tool to the list that are cairo dependant in the android makefile.

//Derek


-----Original Message-----
From: Intel-gfx [mailto:intel-gfx-bounces at lists.freedesktop.org] On Behalf Of Paulo Zanoni
Sent: Tuesday, January 26, 2016 1:40 PM
To: intel-gfx at lists.freedesktop.org
Cc: Zanoni, Paulo R
Subject: [Intel-gfx] [PATCH igt] tools/intel_residency: use setitimer instead of {, u}alarm

It seems that Android doesn't have ualarm(). Let's use setitimer() instead.

The tool still won't compile on Android due to igt_fb requiring Cairo, but we're supposed to solve this in another patch since our igt_fb calls don't actually require Cairo.

Reported-by: Derek Morton <derek.j.morton at intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
 tools/intel_residency.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/tools/intel_residency.c b/tools/intel_residency.c index 7b820c1..74074c5 100644
--- a/tools/intel_residency.c
+++ b/tools/intel_residency.c
@@ -23,6 +23,8 @@
  * Authors: Paulo Zanoni <paulo.r.zanoni at intel.com>
  *
  */
+
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -311,6 +313,14 @@ static void setup_alarm(void)
 	sigaction(SIGALRM, &sa, NULL);
 }
 
+static void set_alarm(time_t sec, suseconds_t usec) {
+	struct itimerval timerval = {{0, 0}, {sec, usec}};
+
+	alarm_received = false;
+	igt_assert(setitimer(ITIMER_REAL, &timerval, NULL) == 0); }
+
 static void unset_mode(void)
 {
 	int rc;
@@ -370,8 +380,7 @@ static void wait_until_idle(void)
 	uint64_t tsc, pc, res;
 
 	do {
-		alarm_received = false;
-		ualarm(500 * 1000, 0);
+		set_alarm(0, 500 * 1000);
 
 		tsc = msr_read(IA32_TIME_STAMP_COUNTER);
 		pc = msr_read(deepest_pc_state);
@@ -398,12 +407,10 @@ static uint64_t do_measurement(void (*callback)(void *ptr), void *ptr)
 
 	wait_until_idle();
 
-	alarm_received = false;
-	alarm(opts.res_warm_time);
+	set_alarm(opts.res_warm_time, 0);
 	callback(ptr);
 
-	alarm_received = false;
-	alarm(opts.res_calc_time);
+	set_alarm(opts.res_calc_time, 0);
 
 	tsc = msr_read(IA32_TIME_STAMP_COUNTER);
 	pc = msr_read(deepest_pc_state);
@@ -423,13 +430,11 @@ static void setup_idle(void)
 
 	for (retries = 0; ; retries++) {
 
-		alarm_received = false;
-		alarm(opts.res_warm_time);
+		set_alarm(opts.res_warm_time, 0);
 		while (!alarm_received)
 			pause();
 
-		alarm_received = false;
-		alarm(opts.res_calc_time);
+		set_alarm(opts.res_calc_time, 0);
 
 		tsc = msr_read(IA32_TIME_STAMP_COUNTER);
 		for (pc_i = best_pc_i; pc_i < NUM_PC_STATES; pc_i++)
--
2.7.0.rc3

_______________________________________________
Intel-gfx mailing list
Intel-gfx at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the Intel-gfx mailing list