From patchwork Fri Jan 27 11:12:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13118381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F50DC61DA4 for ; Fri, 27 Jan 2023 11:12:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43D9910E459; Fri, 27 Jan 2023 11:12:55 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id D3F5110E454; Fri, 27 Jan 2023 11:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674817971; x=1706353971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HfP297QW8gIkpCYO2BzVqMKCU4NmSe3qOUmwVqCBKVY=; b=AOvh6kldbekhwZIIaEjbe2EqpxFaljvatmQW7IhjJiRf9fNMGWKGo/3p 3BT0nvc31nFQWYktJd4bTqJWginvdoywxPlOYHstKxKAs6Qz0d++2jEjA m1ICibruRBlTWJ5Q8VI5ehNZfy7/t7xunYfRPDK3kFcvsUqOBkHvbZA/S 20fV+9t9Ll7akgtHyuqxGwrGciN0kOl7nPy/AY6QHMsc3AL8VC+rRYq43 Trus0QEP7gypP9v2CwyE3lemTsb3sEzAIlfOq/6RXaPFRR+i0NziMPooa 4+tDVU+8ARMs0ZXwXlYtmmPE92iGw+63ZI81m3TerriqWwQg/gZwKbOUb A==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="328352645" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="328352645" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:51 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="908638121" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="908638121" Received: from jgeary-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.233.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:50 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2023 11:12:36 +0000 Message-Id: <20230127111241.3624629-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> References: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/6] intel_gpu_top: Fix man page formatting X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin New lines are not respected when rst2man generates the page so try to work around that by followin advice from the Internet. v2: * Improve some wording. * Tidy -o option description. * Update dates. * Convert the filter list to table. Signed-off-by: Tvrtko Ursulin Reviewed-by: Kamil Konieczny # v1 --- man/intel_gpu_top.rst | 55 ++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/man/intel_gpu_top.rst b/man/intel_gpu_top.rst index 748c7740c800..4417bcff0d5b 100644 --- a/man/intel_gpu_top.rst +++ b/man/intel_gpu_top.rst @@ -7,9 +7,9 @@ Display a top-like summary of Intel GPU usage --------------------------------------------- .. include:: defs.rst :Author: IGT Developers -:Date: 2020-03-18 +:Date: 2023-01-27 :Version: |PACKAGE_STRING| -:Copyright: 2009,2011,2012,2016,2018,2019,2020 Intel Corporation +:Copyright: 2009,2011,2012,2016,2018,2019,2020,2023 Intel Corporation :Manual section: |MANUAL_SECTION| :Manual group: |MANUAL_GROUP| @@ -23,7 +23,7 @@ DESCRIPTION **intel_gpu_top** is a tool to display usage information on Intel GPU's. -The tool gathers data using perf performance counters (PMU) exposed by i915 and other platform drivers like RAPL (power) and Uncore IMC (memory bandwidth). +The tool presents data collected from performance counters (PMU), exposed by i915 and other platform drivers like RAPL (power) and Uncore IMC (memory bandwidth). OPTIONS ======= @@ -37,49 +37,44 @@ OPTIONS -l List plain text data. --o - Output to the specified file instead of standard output. - '-' can also be specified to explicitly select standard output. +-o , or -o - + Output to the specified file instead of standard output. '-' can also be specified to explicitly select standard output. -s Refresh period in milliseconds. + -L - List available GPUs on the platform. + List available GPUs on the system. + -d - Select a specific GPU using supported filter. + Select a specific GPU using one of the supported filters. RUNTIME CONTROL =============== Supported keys: - 'q' Exit from the tool. - 'h' Show interactive help. - '1' Toggle between aggregated engine class and physical engine mode. - 'n' Toggle display of numeric client busyness overlay. - 's' Toggle between sort modes (runtime, total runtime, pid, client id). - 'i' Toggle display of clients which used no GPU time. - 'H' Toggle between per PID aggregation and individual clients. +| +| 'q' Exit from the tool. +| 'h' Show interactive help. +| '1' Toggle between aggregated by engine class and physical engine mode. +| 'n' Toggle display of numeric client busyness overlay. +| 's' Toggle between sort modes (runtime, total runtime, pid, client id). +| 'i' Toggle display of clients which used no GPU time. +| 'H' Toggle between per PID aggregation and individual clients. DEVICE SELECTION ================ -User can select specific GPU for performance monitoring on platform where multiple GPUs are available. -A GPU can be selected by sysfs path, drm node or using various PCI sub filters. - -Filter types: :: - - --- - filter syntax - --- - sys sys:/sys/devices/pci0000:00/0000:00:02.0 - find device by its sysfs path - - drm drm:/dev/dri/* path - find drm device by /dev/dri/* node +On systems where multiple GPUs are present it is possible to select a specific GPU to be monitored. A GPU can be selected by sysfs path, drm device node or using various PCI sub filters. - pci pci:[vendor=%04x/name][,device=%04x][,card=%d] - vendor is hex number or vendor name +========== ====================================================== ====================== +**Filter** **Syntax** **GPU selection criteria** +========== ====================================================== ====================== +sys | ``sys:/sys/devices/pci0000:00/0000:00:02.0`` Select using the sysfs path. +drm | ``drm:/dev/dri/`` Select using the /dev/dri/\* device node. +pci | ``pci:[vendor=%04x/name][,device=%04x][,card=%d]`` Select using the PCI addrress. Vendor is hexadecinal number or vendor name. +========== ====================================================== ====================== JSON OUTPUT =========== From patchwork Fri Jan 27 11:12:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13118384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B9B8C38142 for ; Fri, 27 Jan 2023 11:13:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B325310E461; Fri, 27 Jan 2023 11:13:03 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A32F10E452; Fri, 27 Jan 2023 11:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674817973; x=1706353973; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4EUo78eqCR4vzVuzw9kpw88MrcKCkVdPmbiE3N//srs=; b=Ujn9tQlMCq9jkqn6KRGEo8qGYP0WFEW5eYEU0ISX+TzS0/XoBKA5e8+F mD1Xqnh3vlQyWPD9Aqvgr892b9tqNPHEccOA4hpTZdjxFG+BmB6R6tE7N 4R0XSeS1tSRJLIBC5VM2RqycCMszZQYMOa/UX7LpZhy6xRgePo5FUl08H /Rpm4TSmyRY8W9EiUN/UhFFn39hLemqQu0z5AIla7+eahhdFxp6vXx02P +8fI9cIgy5JqNSh5+ohLiHnFxN8WueR937VNrq3ZGwNyfVjtt998xBSK4 uiGODn0vpVWeVSHO4dVza9nEg5JZDbQTQQquHdTNfRYOdQooPfaYupn/c g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="328352649" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="328352649" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:53 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="908638125" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="908638125" Received: from jgeary-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.233.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:51 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2023 11:12:37 +0000 Message-Id: <20230127111241.3624629-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> References: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/6] intel_gpu_top: Automatically enclose JSON output into brackets X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eero Tamminen Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Parsers need the whole output enclosed into square brackets so every period sample becomes an array element. So far we have been suggesting this in the man page but we can trivially make the tool output that itself. Signed-off-by: Tvrtko Ursulin Cc: Eero Tamminen Reviewed-by: Kamil Konieczny --- man/intel_gpu_top.rst | 2 +- tools/intel_gpu_top.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/man/intel_gpu_top.rst b/man/intel_gpu_top.rst index 4417bcff0d5b..caf0a9f9432c 100644 --- a/man/intel_gpu_top.rst +++ b/man/intel_gpu_top.rst @@ -79,7 +79,7 @@ pci | ``pci:[vendor=%04x/name][,device=%04x][,card=%d]`` Select using JSON OUTPUT =========== -To parse the JSON as output by the tool the consumer should wrap its entirety into square brackets ([ ]). This will make each sample point a JSON array element and will avoid "Multiple root elements" JSON validation error. +JSON output will be correctly terminated when the tool cleanly exits, otherwise one square bracket needs to be added before parsing. LIMITATIONS =========== diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 6de8a164fcff..c4d98de4fe31 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2597,6 +2597,9 @@ int main(int argc, char **argv) scan_clients(clients, false); codename = igt_device_get_pretty_name(&card, false); + if (output_mode == JSON) + printf("[\n"); + while (!stop_top) { struct clients *disp_clients; bool consumed = false; @@ -2683,6 +2686,9 @@ int main(int argc, char **argv) usleep(period_us); } + if (output_mode == JSON) + printf("]\n"); + if (clients) free_clients(clients); From patchwork Fri Jan 27 11:12:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13118382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7EAB6C54EAA for ; Fri, 27 Jan 2023 11:13:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7B4F10E460; Fri, 27 Jan 2023 11:13:02 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A09210E458; Fri, 27 Jan 2023 11:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674817975; x=1706353975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8TZ/wvve9Dvq4Y9T5zmRqt6DdJbRlIJjzSZ9OFSR+i0=; b=bOualiIfVS6+EezXZ1DrIN+LkZEkhX12/UpfKV1Ty1VXr3EjQ9HzsrGY Xd2jeuja+2We+OL63C7OsbFI03maqYYH9H6fEPQgp04V95KP7gogTPzId 0TPrwJ0Z2kX6cuWH5hvrEVmHGoq2KW64sTkmStdsAifS0BbUr5xZe3qQj quc8EpnytO1fobAV1nhAUkQJ2Q3n9FOutYgbi5r/k1/6PDFsfXDleYJ/4 sLDZV98Kr9EvrnUcuBoNM6KPpZT0cQrVQNf3Id5nFcOaFYnVkQBR9PMf+ Dmktey/7xh3lckAmNhy01whXGlMA1eCoKxc5o7XxV/HuQOEuX7Nv3g1n8 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="328352652" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="328352652" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:54 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="908638128" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="908638128" Received: from jgeary-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.233.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:53 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2023 11:12:38 +0000 Message-Id: <20230127111241.3624629-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> References: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 3/6] intel_gpu_top: Add command line switch to start in physical engine mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Default mode is to aggreate engines per class but some users would prefer to be able to start in physical engine mode too. Signed-off-by: Tvrtko Ursulin Cc: Dmitry Rogozhkin Reviewed-by: Kamil Konieczny --- man/intel_gpu_top.rst | 3 +++ tools/intel_gpu_top.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/man/intel_gpu_top.rst b/man/intel_gpu_top.rst index caf0a9f9432c..69834756b81e 100644 --- a/man/intel_gpu_top.rst +++ b/man/intel_gpu_top.rst @@ -49,6 +49,9 @@ OPTIONS -d Select a specific GPU using one of the supported filters. +-p + Default to showing physical engines instead of aggregated classes. + RUNTIME CONTROL =============== diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index c4d98de4fe31..e91b47baf72b 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1268,6 +1268,7 @@ usage(const char *appname) "\t[-s ] Refresh period in milliseconds (default %ums).\n" "\t[-L] List all cards.\n" "\t[-d ] Device filter, please check manual page for more details.\n" + "\t[-p] Default to showing physical engines instead of classes.\n" "\n", appname, DEFAULT_PERIOD_MS); igt_device_print_filter_types(); @@ -2446,6 +2447,7 @@ int main(int argc, char **argv) { unsigned int period_us = DEFAULT_PERIOD_MS * 1000; struct clients *clients = NULL; + bool physical_engines = false; int con_w = -1, con_h = -1; char *output_path = NULL; struct engines *engines; @@ -2456,7 +2458,7 @@ int main(int argc, char **argv) char *codename = NULL; /* Parse options */ - while ((ch = getopt(argc, argv, "o:s:d:JLlh")) != -1) { + while ((ch = getopt(argc, argv, "o:s:d:pJLlh")) != -1) { switch (ch) { case 'o': output_path = optarg; @@ -2467,6 +2469,9 @@ int main(int argc, char **argv) case 'd': opt_device = strdup(optarg); break; + case 'p': + physical_engines = true; + break; case 'J': output_mode = JSON; break; @@ -2508,7 +2513,7 @@ int main(int argc, char **argv) case INTERACTIVE: pops = &term_pops; interactive_stdin(); - class_view = true; + class_view = !physical_engines; break; case STDOUT: pops = &stdout_pops; From patchwork Fri Jan 27 11:12:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13118383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D42A5C61DA4 for ; Fri, 27 Jan 2023 11:13:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C282E10E45F; Fri, 27 Jan 2023 11:13:02 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id B412810E45A; Fri, 27 Jan 2023 11:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674817976; x=1706353976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/qHkGQFLJZlAAXAn7zVWr+8FIvWlDhfkV9s87Hkkg9Y=; b=gWrBlhMUv7SaQKIxBsU5Pbih9PQUG1sURHwTdpVsTadqd+Cg3Cj8XP1s QR9Uv7/qUx63V1UDw4j9f9HiBvr/Xa9uo1cI4TYckAGHq0hzdgzsGiq2W K1yMLFnlImChtgnQyzfK0t2qP/MMcoIlvWMyeSfWf4bOQ+H2kKVgzLmnr bONfIlseis7OM2qZpbDYXk1vc0rYVan1atGVYnloOxRIb4Q0SmafpRL68 CPxOoM3psZBZrnzgm/ctRMdcI2uf/1Nkx985agt6KddL8o7oJYoFu56TE JfHPfl+TXIYvpEHVK+f81U8desDJ4gJRZYbjOfhw4ibtK8a/xuVaFVBGC w==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="328352657" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="328352657" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:56 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="908638131" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="908638131" Received: from jgeary-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.233.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:54 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2023 11:12:39 +0000 Message-Id: <20230127111241.3624629-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> References: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 4/6] intel_gpu_top: Aggregate engine classes in all output modes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Use the same default for stdout and JSON output modes as it is for interactive. Previously added command line switch can be used to go back to showing all physical engines. Signed-off-by: Tvrtko Ursulin Cc: Dmitry Rogozhkin Reviewed-by: Kamil Konieczny --- tools/intel_gpu_top.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index e91b47baf72b..7aa233570463 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2509,11 +2509,12 @@ int main(int argc, char **argv) if (signal(SIGINT, sigint_handler) == SIG_ERR) fprintf(stderr, "Failed to install signal handler!\n"); + class_view = !physical_engines; + switch (output_mode) { case INTERACTIVE: pops = &term_pops; interactive_stdin(); - class_view = !physical_engines; break; case STDOUT: pops = &stdout_pops; From patchwork Fri Jan 27 11:12:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13118386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEB36C61DA7 for ; Fri, 27 Jan 2023 11:13:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2125F10E463; Fri, 27 Jan 2023 11:13:05 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 836D710E45A; Fri, 27 Jan 2023 11:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674817978; x=1706353978; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fbL/b4nzlV1gzZmk3j8X9z1Zu/a0IY1oM0bY+/erhLA=; b=Ew8/9U3gDP6jT5OkQX4q0A6Lg0RSDscyygJV5i4WeWZPdb2e007JRNgN q888et62C6TgaUgWAZDPBiBte883UiAz5ORg7ZCkaUBtTeMM82dCdeTrb WMPQ6Xz5Xd3eI3zoRedRrukgAJ5+ke0g3MoS/dBrwZHCKlV3M0OswZUW3 RfbyWC/LoFW487plSWwb2G86Qs3yuq+sIQVvigrKHzwpbrjHbhPbk1UR9 pIsG27T1P8y2AoQGem0bkLafNgUQWcTYLq6bTkJsD/dJp6Gm8Pa9Euj5/ 2/81bA/N0ueHctCeDv4RYMl5bnB8Zd2vcWoLA4M7n8AGyiDTpQEOGkATB g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="328352664" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="328352664" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:58 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="908638134" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="908638134" Received: from jgeary-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.233.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:56 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2023 11:12:40 +0000 Message-Id: <20230127111241.3624629-6-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> References: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 5/6] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Avoid trying to dereference null engines on exit when there are either none which are supported, or kernel does not have i915 PMU support. Also fix a memory leak on the same failure path just so Valgrind runs are quite. v2: * Fix a memory leak in the same failure mode too. Signed-off-by: Tvrtko Ursulin Acked-by: Nirmoy Das # v1 --- tools/intel_gpu_top.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 7aa233570463..0a1de41b3374 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -340,7 +340,7 @@ static struct engines *discover_engines(char *device) d = opendir(sysfs_root); if (!d) - return NULL; + goto err; while ((dent = readdir(d)) != NULL) { const char *endswith = "-busy"; @@ -423,10 +423,8 @@ static struct engines *discover_engines(char *device) } if (ret) { - free(engines); errno = ret; - - return NULL; + goto err; } qsort(engine_ptr(engines, 0), engines->num_engines, @@ -435,6 +433,11 @@ static struct engines *discover_engines(char *device) engines->root = d; return engines; + +err: + free(engines); + + return NULL; } static void free_engines(struct engines *engines) @@ -448,6 +451,9 @@ static void free_engines(struct engines *engines) }; unsigned int i; + if (!engines) + return; + for (pmu = &free_list[0]; *pmu; pmu++) { if ((*pmu)->present) free((char *)(*pmu)->units); @@ -2568,7 +2574,7 @@ int main(int argc, char **argv) "Failed to detect engines! (%s)\n(Kernel 4.16 or newer is required for i915 PMU support.)\n", strerror(errno)); ret = EXIT_FAILURE; - goto err; + goto err_engines; } ret = pmu_init(engines); @@ -2585,7 +2591,7 @@ int main(int argc, char **argv) "More information can be found at 'Perf events and tool security' document:\n" "https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html\n"); ret = EXIT_FAILURE; - goto err; + goto err_pmu; } ret = EXIT_SUCCESS; @@ -2699,8 +2705,9 @@ int main(int argc, char **argv) free_clients(clients); free(codename); -err: +err_pmu: free_engines(engines); +err_engines: free(pmu_device); exit: igt_devices_free(); From patchwork Fri Jan 27 11:12:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13118385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9BB5AC61DA4 for ; Fri, 27 Jan 2023 11:13:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E943C10E462; Fri, 27 Jan 2023 11:13:03 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id C904210E45D; Fri, 27 Jan 2023 11:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674817979; x=1706353979; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rl0QsDk0kRAIzGw/liTYCZfpI8wU+/W6zi1qDuzXQuc=; b=aLcxqeI6yoI3qvP0yUqOx1xipw2t/B/SENONYIsBiXX+BMNnFrlZDvEn U8WrqLW9kwAGu+KcsEvv3cudiloX3bbT+TvxBOQBAYTysgRg4OkxAW+Os o3XZ2N+SfdnAw4CrmIdMARYTngL25B3GBUvDNIB8K6JzdICP2+6p1fKcQ ooLhJ7S9YgkZ+ZSLVezku6DTb/rpfwY6A8UMsOmCifZGMIjziErWMxqj6 a+wAiSnKp7VqbANUl9Zdl/PynOP4CO6UM/OGoPmuKnyqGwiT6xG7qxVIX E7YzWXXvLo1WRa0LB7dDAX5Pa5KMI65R8KUbDmUcdszXGYDjSJyx81Kul w==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="328352668" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="328352668" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:59 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="908638138" X-IronPort-AV: E=Sophos;i="5.97,250,1669104000"; d="scan'208";a="908638138" Received: from jgeary-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.233.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2023 03:12:57 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2023 11:12:41 +0000 Message-Id: <20230127111241.3624629-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> References: <20230127111241.3624629-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 6/6] lib/igt_device_scan: Improve Intel discrete GPU selection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Now that DRM subsystem can contain PCI cards with the vendor set to Intel but they are not Intel GPUs, we need a better selection logic than looking at the vendor. Use the driver name instead. Caveat that the driver key was on a blacklist so far, and although I can't imagine it can be slow to probe, this is something to double check. Signed-off-by: Tvrtko Ursulin Cc: Kamil Konieczny Cc: Zbigniew Kempczyński Reviewed-by: Zbigniew Kempczyński --- lib/igt_device_scan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c index ed128d24dd10..8b767eed202d 100644 --- a/lib/igt_device_scan.c +++ b/lib/igt_device_scan.c @@ -237,6 +237,7 @@ struct igt_device { char *vendor; char *device; char *pci_slot_name; + char *driver; int gpu_index; /* For more than one GPU with same vendor and device. */ char *codename; /* For grouping by codename */ @@ -440,7 +441,6 @@ static bool is_on_blacklist(const char *what) "resource3", "resource4", "resource5", "resource0_wc", "resource1_wc", "resource2_wc", "resource3_wc", "resource4_wc", "resource5_wc", - "driver", "uevent", NULL}; const char *key; int i = 0; @@ -662,6 +662,8 @@ static struct igt_device *igt_device_new_from_udev(struct udev_device *dev) get_pci_vendor_device(idev, &vendor, &device); idev->codename = __pci_codename(vendor, device); idev->dev_type = __pci_devtype(vendor, device, idev->pci_slot_name); + idev->driver = strdup_nullsafe(get_attr(idev, "driver")); + igt_assert(idev->driver); } return idev; @@ -776,7 +778,7 @@ static bool __find_first_i915_card(struct igt_device_card *card, bool discrete) igt_list_for_each_entry(dev, &igt_devs.all, link) { - if (!is_pci_subsystem(dev) || !is_vendor_matched(dev, "intel")) + if (!is_pci_subsystem(dev) || strcmp(dev->driver, "i915")) continue; cmp = strncmp(dev->pci_slot_name, INTEGRATED_I915_GPU_PCI_ID, @@ -1023,6 +1025,7 @@ static void igt_device_free(struct igt_device *dev) free(dev->drm_render); free(dev->vendor); free(dev->device); + free(dev->driver); free(dev->pci_slot_name); g_hash_table_destroy(dev->attrs_ht); g_hash_table_destroy(dev->props_ht);