From patchwork Mon Sep 5 20:19:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeni Dodonov X-Patchwork-Id: 1125422 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p85KMHUe000590 for ; Mon, 5 Sep 2011 20:22:37 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD82CA099C for ; Mon, 5 Sep 2011 13:22:17 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from oproxy3-pub.bluehost.com (oproxy3-pub.bluehost.com [69.89.21.8]) by gabe.freedesktop.org (Postfix) with SMTP id 01FFFA0991 for ; Mon, 5 Sep 2011 13:20:34 -0700 (PDT) Received: (qmail 13183 invoked by uid 0); 5 Sep 2011 20:20:34 -0000 Received: from unknown (HELO box335.bluehost.com) (69.89.31.135) by oproxy3.bluehost.com with SMTP; 5 Sep 2011 20:20:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dodonov.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=YViIi2kG2TZq26qZIHe0mhG5zIK+FKousJ/U0QUuWic=; b=QeA/4Eliy5PUMQ3LQgIQgBD0SUkMN0UAjr/Sqj+MADYAUqVyKgsJ8nHSO2ce9HTuo245p0r+aaI6SFAQRJOJ/8O3NaAXwF4t8+kVcNH+uPdQnK31mV50y5ZOUZ6hzjRH; Received: from 200.188.217.18.dedicated.neoviatelecom.com.br ([200.188.217.18] helo=localhost.localdomain) by box335.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1R0fek-0007ag-7P; Mon, 05 Sep 2011 14:20:34 -0600 From: Eugeni Dodonov To: intel-gfx@lists.freedesktop.org Date: Mon, 5 Sep 2011 17:19:30 -0300 Message-Id: <1315253973-18950-4-git-send-email-eugeni@dodonov.net> X-Mailer: git-send-email 1.7.6.1 In-Reply-To: <1315253973-18950-1-git-send-email-eugeni@dodonov.net> References: <1315253973-18950-1-git-send-email-eugeni@dodonov.net> X-Identified-User: {669:box335.bluehost.com:dodonovn:dodonov.net} {sentby:smtp auth 200.188.217.18 authed with eugeni@dodonov.net} Cc: Eugeni Dodonov Subject: [Intel-gfx] [PATCH 3/6] intel_gpu_tool: initial support for non-screen output X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 05 Sep 2011 20:22:37 +0000 (UTC) From: Eugeni Dodonov This patch adds initial support for non-stdio output, to be used for non-interactive monitoring. Signed-off-by: Eugeni Dodonov --- tools/intel_gpu_top.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index abe9d4b..edb4a82 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -373,7 +373,8 @@ static void ring_sample(struct ring *ring) ring->full += full; } -static void ring_print(struct ring *ring, unsigned long samples_per_sec) +static void ring_print(struct ring *ring, unsigned long samples_per_sec, + FILE *output) { int samples_to_percent_ratio, percent, len; @@ -383,9 +384,9 @@ static void ring_print(struct ring *ring, unsigned long samples_per_sec) /* Calculate current value of samples_to_percent_ratio */ samples_to_percent_ratio = (ring->idle * 100) / samples_per_sec; percent = 100 - samples_to_percent_ratio; - len = printf("%25s busy: %3d%%: ", ring->name, percent); + len = fprintf(output, "%25s busy: %3d%%: ", ring->name, percent); print_percentage_bar (percent, len); - printf("%24s space: %d/%d (%d%%)\n", + fprintf(output, "%24s space: %d/%d (%d%%)\n", ring->name, (int)(ring->full / samples_per_sec), ring->size, @@ -427,6 +428,7 @@ int main(int argc, char **argv) }; int i, ch; int samples_per_sec = SAMPLES_PER_SEC; + FILE *output = stdout; /* Parse options? */ while ((ch = getopt(argc, argv, "s:h")) != -1) @@ -546,30 +548,30 @@ int main(int argc, char **argv) if (max_lines >= num_instdone_bits) max_lines = num_instdone_bits; - printf("%s", clear_screen); + fprintf(output, "%s", clear_screen); print_clock_info(pci_dev); - ring_print(&render_ring, last_samples_per_sec); - ring_print(&bsd_ring, last_samples_per_sec); - ring_print(&bsd6_ring, last_samples_per_sec); - ring_print(&blt_ring, last_samples_per_sec); + ring_print(&render_ring, last_samples_per_sec, output); + ring_print(&bsd_ring, last_samples_per_sec, output); + ring_print(&bsd6_ring, last_samples_per_sec, output); + ring_print(&blt_ring, last_samples_per_sec, output); - printf("\n%30s %s\n", "task", "percent busy"); + fprintf(output, "\n%30s %s\n", "task", "percent busy"); for (i = 0; i < max_lines; i++) { if (top_bits_sorted[i]->count > 0) { percent = (top_bits_sorted[i]->count * 100) / last_samples_per_sec; - len = printf("%30s: %3d%%: ", + len = fprintf(output, "%30s: %3d%%: ", top_bits_sorted[i]->bit->name, percent); print_percentage_bar (percent, len); } else { - printf("%*s", PERCENTAGE_BAR_END, ""); + fprintf(output, "%*s", PERCENTAGE_BAR_END, ""); } if (i < STATS_COUNT && HAS_STATS_REGS(devid)) { - printf("%13s: %llu (%lld/sec)", + fprintf(output, "%13s: %llu (%lld/sec)", stats_reg_names[i], stats[i], stats[i] - last_stats[i]); @@ -578,7 +580,7 @@ int main(int argc, char **argv) if (!top_bits_sorted[i]->count) break; } - printf("\n"); + fprintf(output, "\n"); } for (i = 0; i < num_instdone_bits; i++) {