From patchwork Wed Aug 2 10:29:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 9876589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A3D36041F for ; Wed, 2 Aug 2017 10:30:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C504287AB for ; Wed, 2 Aug 2017 10:30:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B08E287B3; Wed, 2 Aug 2017 10:30:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9BEAB287AB for ; Wed, 2 Aug 2017 10:29:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E2D76F067; Wed, 2 Aug 2017 10:29:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mblankhorst.nl (mblankhorst.nl [IPv6:2a02:2308::216:3eff:fe92:dfa3]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB94F6F067 for ; Wed, 2 Aug 2017 10:29:30 +0000 (UTC) From: Maarten Lankhorst To: intel-gfx@lists.freedesktop.org Date: Wed, 2 Aug 2017 12:29:17 +0200 Message-Id: <20170802102919.13340-1-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.11.0 Subject: [Intel-gfx] [PATCH i-g-t 1/3] lib/igt_aux: Export statistics of signal helper. 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Export 2 functions, igt_signal_helper_get_num and igt_signal_helper_get_hz. This will allow tests to measure how much time in a test was spent in a uninterruptible state, which is useful when testing whether certain ioctl's can be interrupted or not. Signed-off-by: Maarten Lankhorst --- lib/igt_aux.c | 30 +++++++++++++++++++++++++++--- lib/igt_aux.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 86a213c2032f..265e43f399e7 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -275,7 +275,7 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool enable) } static struct igt_helper_process signal_helper; -long long int sig_stat; +static int64_t sig_stat; static void __attribute__((noreturn)) signal_helper_process(pid_t pid) { /* Interrupt the parent process at 500Hz, just to be annoying */ @@ -314,6 +314,9 @@ void igt_fork_signal_helper(void) if (igt_only_list_subtests()) return; + /* Reset number of signalscaught */ + sig_stat = 0; + /* We pick SIGCONT as it is a "safe" signal - if we send SIGCONT to * an unexpecting process it spuriously wakes up and does nothing. * Most other signals (e.g. SIGUSR1) cause the process to die if they @@ -348,8 +351,29 @@ void igt_stop_signal_helper(void) return; igt_stop_helper(&signal_helper); +} - sig_stat = 0; +/** + * igt_signal_helper_get_num: + * + * Return the amount of signals generated since the last time + * igt_fork_signal_helper() was called. + * + * This is reset to 0 on every call to igt_fork_signal_helper. + */ +int64_t igt_signal_helper_get_num(void) +{ + return sig_stat; +} + +/** + * igt_signal_helper_get_hz: + * + * Return the approximate amount of signals generated per second. + */ +int igt_signal_helper_get_hz(void) +{ + return 50; } static struct igt_helper_process shrink_helper; @@ -357,7 +381,7 @@ static void __attribute__((noreturn)) shrink_helper_process(int fd, pid_t pid) { while (1) { igt_drop_caches_set(fd, DROP_SHRINK_ALL); - usleep(1000 * 1000 / 50); + usleep(1000 * 1000 / igt_signal_helper_get_hz()); if (kill(pid, 0)) /* Parent has died, so must we. */ exit(0); } diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 499a16796ebb..7e080089dcbc 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -55,6 +55,8 @@ extern int num_trash_bos; /* generally useful helpers */ void igt_fork_signal_helper(void); void igt_stop_signal_helper(void); +int64_t igt_signal_helper_get_num(void); +int igt_signal_helper_get_hz(void); void igt_fork_shrink_helper(int fd); void igt_stop_shrink_helper(void);