From patchwork Tue Jan 26 14:44:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Morton X-Patchwork-Id: 8123701 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 28617BEEE5 for ; Tue, 26 Jan 2016 14:44:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0F0F2026D for ; Tue, 26 Jan 2016 14:44:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B0657201F2 for ; Tue, 26 Jan 2016 14:44:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38C976E5F4; Tue, 26 Jan 2016 06:44:04 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 32ADA6E5F4 for ; Tue, 26 Jan 2016 06:44:02 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 26 Jan 2016 06:44:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,350,1449561600"; d="scan'208";a="868971701" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga001.jf.intel.com with ESMTP; 26 Jan 2016 06:44:01 -0800 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.97]) by IRSMSX103.ger.corp.intel.com ([169.254.3.30]) with mapi id 14.03.0248.002; Tue, 26 Jan 2016 14:44:00 +0000 From: "Morton, Derek J" To: "Zanoni, Paulo R" , "intel-gfx@lists.freedesktop.org" Thread-Topic: [Intel-gfx] [PATCH igt] tools/intel_residency: use setitimer instead of {, u}alarm Thread-Index: AQHRWD9XSRGXzI8Akku9QrrG/h9e8Z8N3sTA Date: Tue, 26 Jan 2016 14:44:00 +0000 Message-ID: <2D016F5BA44C744783BA96B1D3EBC5BD13F118D3@IRSMSX102.ger.corp.intel.com> References: <1453815615-29099-1-git-send-email-paulo.r.zanoni@intel.com> In-Reply-To: <1453815615-29099-1-git-send-email-paulo.r.zanoni@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] MIME-Version: 1.0 Cc: "Zanoni, Paulo R" Subject: Re: [Intel-gfx] [PATCH igt] tools/intel_residency: use setitimer instead of {, u}alarm X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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@lists.freedesktop.org] On Behalf Of Paulo Zanoni Sent: Tuesday, January 26, 2016 1:40 PM To: intel-gfx@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 Signed-off-by: Paulo Zanoni --- tools/intel_residency.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx 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 * */ + +#include #include #include #include @@ -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;