From patchwork Tue Nov 20 18:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ho, Kenny" X-Patchwork-Id: 10691147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 413FF13AD for ; Tue, 20 Nov 2018 18:59:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F59D2ACD3 for ; Tue, 20 Nov 2018 18:59:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23B1A2ACD5; Tue, 20 Nov 2018 18:59:12 +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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,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 9E71F2ACD3 for ; Tue, 20 Nov 2018 18:59:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 321686E41E; Tue, 20 Nov 2018 18:59:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680078.outbound.protection.outlook.com [40.107.68.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CAD16E3D1; Tue, 20 Nov 2018 18:59:02 +0000 (UTC) Received: from CY4PR1201CA0018.namprd12.prod.outlook.com (2603:10b6:910:16::28) by SN1PR12MB0752.namprd12.prod.outlook.com (2a01:111:e400:c45b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.21; Tue, 20 Nov 2018 18:59:00 +0000 Received: from BY2NAM03FT025.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::201) by CY4PR1201CA0018.outlook.office365.com (2603:10b6:910:16::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1361.14 via Frontend Transport; Tue, 20 Nov 2018 18:59:00 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT025.mail.protection.outlook.com (10.152.84.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1339.10 via Frontend Transport; Tue, 20 Nov 2018 18:58:59 +0000 Received: from kho-5039A.amd.com (10.180.168.240) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.389.1; Tue, 20 Nov 2018 12:58:58 -0600 From: Kenny Ho To: , , , , , Subject: [PATCH RFC 4/5] drm/amdgpu: Add accounting of command submission via DRM cgroup Date: Tue, 20 Nov 2018 13:58:13 -0500 Message-ID: <20181120185814.13362-5-Kenny.Ho@amd.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120185814.13362-1-Kenny.Ho@amd.com> References: <20181120185814.13362-1-Kenny.Ho@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(136003)(39860400002)(2980300002)(428003)(199004)(189003)(126002)(2201001)(1076002)(476003)(575784001)(478600001)(2616005)(11346002)(97736004)(86362001)(446003)(104016004)(15650500001)(217873002)(14444005)(186003)(26005)(77096007)(53936002)(39060400002)(50466002)(47776003)(48376002)(486006)(316002)(7696005)(51416003)(6346003)(2870700001)(76176011)(356004)(6666004)(305945005)(110136005)(53416004)(426003)(336012)(8936002)(68736007)(72206003)(105586002)(106466001)(81156014)(36756003)(2906002)(5660300001)(81166006)(8676002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0752; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT025; 1:txAL+d3N1y02zN2rddkGGCHhkAoqxsOXhnClSQs8Ohzid6lOOf7sgbB0ipF7/vD1Y091sV9nGaFfYeqZAYuIC5c8nELZQUCS4hqJI9UCt96q3FEhuPl2biWEv7JnUcTE X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 601e444d-7080-4b95-094e-08d64f1a3b40 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:SN1PR12MB0752; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0752; 3:PctyVJ5q9v42PHS9LtBYTJ+dYQVUL1tXCTMvN3o7dERoFySr8lHKH90D4NqLEOQcTFCmiBC47/sBltWLqiOW+VSIid8df8hYZsZjs5h/MG+f1xYDmy2klCZFKzH4oHvUesVUoYwqupB9C14vgeMBmNckTswd21wnkAcEfcpcQ1cptSRlp9mjVayWuC1C4S8SK3NiDkqweNxpgPL/fx6kEXLHR8idFHeo6D51iGXff9SOL3IiWoVt+Q8fC2rQl6Gqm2UCTu5QNeRZLaGNf/QU7rFXExo8Hvxq9NVBKPrJuTW8OiZgyBSJBC9H8Hzm8DsRYrY6+4TPvUbTKe0CwYEhH5tyGSQYtYy0c+Ud5f3jVlU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RfxksIXDxCIgNISw+ex2mp8YXFz94DLP5VLhpywr2kOTeHcAze4A+mxcWTHZvXqf7UNRs+/lFpX+EMUq1XYyyBcTLyBRq9rOS9a7Gyb3j9NIVgHgW2b+0Kp X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231442)(944501410)(52105112)(93006095)(93003095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:SN1PR12MB0752; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0752; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0752; 4:8zTBAKu0O1d9PdN12N8PCAfpH8sv3wLuLNVk0YqcwXhVoyJs4RymQP+Il54OzvbHj8K02bXkrY8PoeJ9nUfxPTZw7vlI8L7Xzoraed7dWWvKZc/Ievu0lnyv+nUatePLWlLqbL471Aeuo1tuuEry87CNrruoi/1wjRSiYyqIdSM4C38Vcl/9zAWaQkIEy9K6zbl1zb9zNc9gFdB5d+D6hK2VqKecp95ZZu4QZiJyhmCfQN3eoX4Sde1hsIVFg8zvmgsFAGlLkGOxD0iUJQWUVQ== X-Forefront-PRVS: 08626BE3A5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0752; 23:4K4Cww5I6LQYCiVRTINchtRkxubDIv4YjkXpQMNfk?= l8ZlWtV2OOKJ2JnbB6MEE2tqxNF+QQwzdiLfLgOvuVVAeuMghR7aK1jrACFnYMi7i5mmQmG83VFa1DQIYd5/1zV364Nv+ht0JoLskVog0pUdwns0oo+f+zLO4Islz/mksjwRPzTRcfUXBfSKQmSH1MhS/TV96bRcGPyeDJSyIwQLV0yhifLlh1vgBcUNStHBY7DUqNP9FwJZXH1s8uU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llU8eWEg7TccasW2pJCaXq3F4jWV0WcBj+MONKAaPAl+MR6/wh00vG1tuCbXxy5a6yAbbA0FesmFHu4bOm4yLPgjA9YBN91dR6ZjyZoddDnEoDhLA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0752; 20:9fc0KFmns+JPrM8fpH3pfaQux2rJmceRlKAUBee7kg5XyoTqzBbS/JWttyNF6hXlqAKbcQof91i1rT1bBG58Cy91W8WU9e0KZYxeRoZbFATYubCQvFnEY8VC/raQEVASd14YgB10ksm5pOqh02S/b2P4GeOGNV/EupaemuGVftTY4vpf6k8FSITd7h2FlQco9lG7/3gZEkbngg+8UZXge5MgKdy7O42A9JNZJkN7Ownsc/Tif3G6I7bg4q2Dmj8j X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2018 18:58:59.9581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 601e444d-7080-4b95-094e-08d64f1a3b40 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0752 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Account for the number of command submitted to amdgpu by type on a per cgroup basis, for the purpose of profiling/monitoring applications. x prefix in the control file name x.cmd_submitted.amd.stat signify experimental. Change-Id: Ibc22e5bda600f54fe820fe0af5400ca348691550 Signed-off-by: Kenny Ho --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c | 54 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h | 5 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 15 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 5 +- 5 files changed, 83 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 663043c8f0f5..b448160aed89 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -33,6 +33,7 @@ #include "amdgpu_trace.h" #include "amdgpu_gmc.h" #include "amdgpu_gem.h" +#include "amdgpu_drmcgrp.h" static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, struct drm_amdgpu_cs_chunk_fence *data, @@ -1275,6 +1276,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) union drm_amdgpu_cs *cs = data; struct amdgpu_cs_parser parser = {}; bool reserved_buffers = false; + struct amdgpu_ring *ring; int i, r; if (!adev->accel_working) @@ -1317,6 +1319,9 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) if (r) goto out; + ring = to_amdgpu_ring(parser.entity->rq->sched); + amdgpu_drmcgrp_count_cs(current, dev, ring->funcs->type); + r = amdgpu_cs_submit(&parser, cs); out: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c index ed8aac17769c..853b77532428 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c @@ -1,11 +1,65 @@ // SPDX-License-Identifier: MIT // Copyright 2018 Advanced Micro Devices, Inc. #include +#include #include #include +#include "amdgpu_ring.h" #include "amdgpu_drmcgrp.h" +void amdgpu_drmcgrp_count_cs(struct task_struct *task, struct drm_device *dev, + enum amdgpu_ring_type r_type) +{ + struct drmcgrp *drmcgrp = get_drmcgrp(task); + struct drmcgrp_device_resource *ddr; + struct drmcgrp *p; + struct amd_drmcgrp_dev_resource *a_ddr; + + if (drmcgrp == NULL) + return; + + ddr = drmcgrp->dev_resources[dev->primary->index]; + + mutex_lock(&ddr->ddev->mutex); + for (p = drmcgrp; p != NULL; p = parent_drmcgrp(drmcgrp)) { + a_ddr = ddr_amdddr(p->dev_resources[dev->primary->index]); + + a_ddr->cs_count[r_type]++; + } + mutex_unlock(&ddr->ddev->mutex); +} + +int amd_drmcgrp_cmd_submit_accounting_read(struct seq_file *sf, void *v) +{ + struct drmcgrp *drmcgrp = css_drmcgrp(seq_css(sf)); + struct drmcgrp_device_resource *ddr = NULL; + struct amd_drmcgrp_dev_resource *a_ddr = NULL; + int i, j; + + seq_puts(sf, "---\n"); + for (i = 0; i < MAX_DRM_DEV; i++) { + ddr = drmcgrp->dev_resources[i]; + + if (ddr == NULL || ddr->ddev->vid != amd_drmcgrp_vendor_id) + continue; + + a_ddr = ddr_amdddr(ddr); + + seq_printf(sf, "card%d:\n", i); + for (j = 0; j < __MAX_AMDGPU_RING_TYPE; j++) + seq_printf(sf, " %s: %llu\n", amdgpu_ring_names[j], a_ddr->cs_count[j]); + } + + return 0; +} + + struct cftype files[] = { + { + .name = "x.cmd_submitted.amd.stat", + .seq_show = amd_drmcgrp_cmd_submit_accounting_read, + .flags = CFTYPE_NOT_ON_ROOT, + }, { } /* terminate */ }; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h index e2934b7a49f5..f894a9a1059f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h @@ -5,12 +5,17 @@ #define _AMDGPU_DRMCGRP_H #include +#include "amdgpu_ring.h" /* for AMD specific DRM resources */ struct amd_drmcgrp_dev_resource { struct drmcgrp_device_resource ddr; + u64 cs_count[__MAX_AMDGPU_RING_TYPE]; }; +void amdgpu_drmcgrp_count_cs(struct task_struct *task, struct drm_device *dev, + enum amdgpu_ring_type r_type); + static inline struct amd_drmcgrp_dev_resource *ddr_amdddr(struct drmcgrp_device_resource *ddr) { return ddr ? container_of(ddr, struct amd_drmcgrp_dev_resource, ddr) : NULL; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index b70e85ec147d..1606f84d2334 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -34,6 +34,21 @@ #include "amdgpu.h" #include "atom.h" +char const *amdgpu_ring_names[] = { + [AMDGPU_RING_TYPE_GFX] = "gfx", + [AMDGPU_RING_TYPE_COMPUTE] = "compute", + [AMDGPU_RING_TYPE_SDMA] = "sdma", + [AMDGPU_RING_TYPE_UVD] = "uvd", + [AMDGPU_RING_TYPE_VCE] = "vce", + [AMDGPU_RING_TYPE_KIQ] = "kiq", + [AMDGPU_RING_TYPE_UVD_ENC] = "uvd_enc", + [AMDGPU_RING_TYPE_VCN_DEC] = "vcn_dec", + [AMDGPU_RING_TYPE_VCN_ENC] = "vcn_enc", + [AMDGPU_RING_TYPE_VCN_JPEG] = "vcn_jpeg", + [__MAX_AMDGPU_RING_TYPE] = "_max" + +}; + /* * Rings * Most engines on the GPU are fed via ring buffers. Ring diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index 4caa301ce454..e292b7e89c6a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h @@ -56,9 +56,12 @@ enum amdgpu_ring_type { AMDGPU_RING_TYPE_UVD_ENC, AMDGPU_RING_TYPE_VCN_DEC, AMDGPU_RING_TYPE_VCN_ENC, - AMDGPU_RING_TYPE_VCN_JPEG + AMDGPU_RING_TYPE_VCN_JPEG, + __MAX_AMDGPU_RING_TYPE }; +extern char const *amdgpu_ring_names[]; + struct amdgpu_device; struct amdgpu_ring; struct amdgpu_ib;