Message ID | 20230417201215.448099-4-robdclark@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2381404vqo; Mon, 17 Apr 2023 13:22:13 -0700 (PDT) X-Google-Smtp-Source: AKy350Y+He6xzS2SbhWC2g0JsZR9vNk5F0X7aVZ9XAXUSrPcpynuFYpRJ3dwUXS4NrpQ9EnmvNaa X-Received: by 2002:a05:6a00:148c:b0:63b:89a2:d624 with SMTP id v12-20020a056a00148c00b0063b89a2d624mr9364382pfu.12.1681762932982; Mon, 17 Apr 2023 13:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681762932; cv=none; d=google.com; s=arc-20160816; b=ljg4o8wr4wXR012wxn9sX0gpRvnDYq3m8GxpkJ/hkDyEKidLt9C7v+WNjr7ditFouB iiZ9gdcpuXi91XLyAZmEbnEr8zJhSjjdABfW3XH7FWze3BhwfIlqRO9qNn41nuvBE5yh m360+fv7qnh6QHfQuaq2ZzIWj8rrc6At2NgjcIjsdR4ucThJjr3c1hbEkuXebnxV2TC7 X5wiIcYlzSVVaZpJveg80IExbZ3kknLPdKwSUcuYGDrJC0yXzAyU1RROLzNwqi6DWA1n W+NNV6xO8eSm91XOjRT0CYOBaTqkMgYAtaNqrsVjLTr3cgk/7sdx4wiu8Xg3M6fGK0G4 1C4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uGGeQ34qFmH3qFSmAUdD5AsG5Jqn1gFFjidxM1csPmQ=; b=A3cDkos96MlLlqNW4FNIeO+1gwKx3PVaXtm5FexqwamvHaOLU2C4Af5T/HN6gADNV0 7Oz+ZsRlVbtYtAUF6uRy+5JlWk/Pgnw9llIiTeS3Ev469AhEtNYVHbfyeoVvyUhrf+se 8wd7h4TPI4NeCSWzenYawy/JAprKxLJVck9IP9bQGlyFfP8+elJRTeybX2lBu3nXh3OM nrY85DBR+H4ZXUO6yGFA98sSwPw00TM2t5Nzc9KW20JfR/OBhhJRJv1qmhsLuHv0+TTr uucfOljxRDiIm9XJ0wnvN4HIAY++yk/fbpDgq8c5iLRD73fGUf4t1neN7Lji/FQtZQH1 vy3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WP1cGmhD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a631304000000b0050bd27672e8si12449694pgl.421.2023.04.17.13.21.58; Mon, 17 Apr 2023 13:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WP1cGmhD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbjDQUMg (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 16:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbjDQUMb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 16:12:31 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A3C558D; Mon, 17 Apr 2023 13:12:25 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id h24-20020a17090a9c1800b002404be7920aso27709582pjp.5; Mon, 17 Apr 2023 13:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681762345; x=1684354345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uGGeQ34qFmH3qFSmAUdD5AsG5Jqn1gFFjidxM1csPmQ=; b=WP1cGmhDXEaM2XoZQjksyWZjyjJ8/dPdSZFCLLz/R19MHv4d8SYoajJ3n7KJGGRP2d QfL8ZCHeiRUBptfALCwXRF34t1z07YYlkovBk2/hsT8PJckcxJI+ZsBCXsg2pi9LvC1d rggmvYF4ju/BUSXm2VA+2JY6fVH8vgjnf0fz97JefdsnlbPsqu6gE2y7kSOZ9r2ZtnIy ygjwVBziEtNITmZ5gllCzuvyKpWojJLQwxnRhV3/072eKrNSg/4TfPqqi8S3Wpt3IGlm aGZiitnwhALRhD1nKBOWbwppjuXsprBAvS5mBlN4oYjef76qBN+AMd4pN7SrTzRzxWlF oqyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681762345; x=1684354345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uGGeQ34qFmH3qFSmAUdD5AsG5Jqn1gFFjidxM1csPmQ=; b=PLg+Ms/uCM7q/5+HUPoU6AwCmbX/OPEcCbpv4lhLJ2PvM2UvPI9iKVbcEl2P9tACgi AqgAa+IYoEtv0eY9EjalwXR7F6VGLsE0Cli/FDhNdjUFebsfa2wTrNQp/x8AUZWuh4OF FKK/udILpTHi1Cjb+ID5RocWOl4xkZTlchKYAnGNG7SBdQ10Mf4uOx8Cz+7gdLW0XmIo KP2fcIA7eKdFR6mg7CRaWu96BFHXHUjVxx1QzJNkHt76t7t5RXuQWm1x5wgc8yoxWLds tKpUiCuThUao+YSxDLT+rOR4GReilOQ8fTAnvRVPD06460dCop4063fWHYAsUAYjZDEs NK2w== X-Gm-Message-State: AAQBX9cYkmI0IZoZNYRfSKNuDrgRrFHoJ+g82QoNkS9DB8beJN7ofKlf kfrDAS0TvzVLb1zrYpvVA3g= X-Received: by 2002:a17:902:bc4b:b0:1a6:6a7c:9fde with SMTP id t11-20020a170902bc4b00b001a66a7c9fdemr140605plz.14.1681762345291; Mon, 17 Apr 2023 13:12:25 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id w24-20020a17090aaf9800b0023d0c2f39f2sm9118078pjq.19.2023.04.17.13.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:12:24 -0700 (PDT) From: Rob Clark <robdclark@gmail.com> To: dri-devel@lists.freedesktop.org Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, Rob Clark <robdclark@chromium.org>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, Jonathan Corbet <corbet@lwn.net>, Rob Clark <robdclark@gmail.com>, Abhinav Kumar <quic_abhinavk@quicinc.com>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>, Sean Paul <sean@poorly.run>, linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), freedreno@lists.freedesktop.org (open list:DRM DRIVER FOR MSM ADRENO GPU) Subject: [RFC 3/3] drm/msm: Add comm/cmdline fields Date: Mon, 17 Apr 2023 13:12:12 -0700 Message-Id: <20230417201215.448099-4-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417201215.448099-1-robdclark@gmail.com> References: <20230417201215.448099-1-robdclark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763456249183144505?= X-GMAIL-MSGID: =?utf-8?q?1763456249183144505?= |
Series |
drm: Add comm/cmdline fdinfo fields
|
|
Commit Message
Rob Clark
April 17, 2023, 8:12 p.m. UTC
From: Rob Clark <robdclark@chromium.org> Normally this would be the same information that can be obtained in other ways. But in some cases the process opening the drm fd is merely a sort of proxy for the actual process using the GPU. This is the case for guest VM processes using the GPU via virglrenderer, in which case the msm native-context renderer in virglrenderer overrides the comm/ cmdline to be the guest process's values. Exposing this via fdinfo allows tools like gputop to show something more meaningful than just a bunch of "pcivirtio-gpu" users. Signed-off-by: Rob Clark <robdclark@chromium.org> --- Documentation/gpu/drm-usage-stats.rst | 8 ++++++++ drivers/gpu/drm/msm/msm_gpu.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+)
Comments
On 17/04/2023 21:12, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > Normally this would be the same information that can be obtained in > other ways. But in some cases the process opening the drm fd is merely > a sort of proxy for the actual process using the GPU. This is the case > for guest VM processes using the GPU via virglrenderer, in which case > the msm native-context renderer in virglrenderer overrides the comm/ > cmdline to be the guest process's values. > > Exposing this via fdinfo allows tools like gputop to show something more > meaningful than just a bunch of "pcivirtio-gpu" users. You also later expanded with: """ I should have also mentioned, in the VM/proxy scenario we have a single process with separate drm_file's for each guest VM process. So it isn't an option to just change the proxy process's name to match the client. """ So how does that work - this single process temporarily changes it's name for each drm fd it opens and creates a context or it is actually in the native context protocol? > > Signed-off-by: Rob Clark <robdclark@chromium.org> > --- > Documentation/gpu/drm-usage-stats.rst | 8 ++++++++ > drivers/gpu/drm/msm/msm_gpu.c | 14 ++++++++++++++ > 2 files changed, 22 insertions(+) > > diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst > index 8e00d53231e0..bc90bed455e3 100644 > --- a/Documentation/gpu/drm-usage-stats.rst > +++ b/Documentation/gpu/drm-usage-stats.rst > @@ -148,6 +148,14 @@ percentage utilization of the engine, whereas drm-engine-<keystr> only reflects > time active without considering what frequency the engine is operating as a > percentage of it's maximum frequency. > > +- drm-comm: <valstr> > + > +Returns the clients executable path. Full path and not just current->comm? In this case probably give it a more descriptive name here. drm-client-executable drm-client-command-line So we stay in the drm-client- namespace? Or if the former is absolute path could one key be enough for both? drm-client-command-line: /path/to/executable --arguments > + > +- drm-cmdline: <valstr> > + > +Returns the clients cmdline. I think drm-usage-stats.rst text should provide some more text with these two. To precisely define their content and outline the use case under which driver authors may want to add them, and fdinfo consumer therefore expect to see them. Just so everything is completely clear and people do not start adding them for drivers which do not support native context (or like). But on the overall it sounds reasonable to me - it would be really cool to not just see pcivirtio-gpu as you say. Even if the standard virtiogpu use case (not native context) could show real users. Regards, Tvrtko > + > Implementation Details > ====================== > > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > index f0f4f845c32d..1150dcbf28aa 100644 > --- a/drivers/gpu/drm/msm/msm_gpu.c > +++ b/drivers/gpu/drm/msm/msm_gpu.c > @@ -148,12 +148,26 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) > return 0; > } > > +static void get_comm_cmdline(struct msm_file_private *ctx, char **comm, char **cmd); > + > void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > struct drm_printer *p) > { > + char *comm, *cmdline; > + > + get_comm_cmdline(ctx, &comm, &cmdline); > + > drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); > drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); > drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); > + > + if (comm) > + drm_printf(p, "drm-comm:\t%s\n", comm); > + if (cmdline) > + drm_printf(p, "drm-cmdline:\t%s\n", cmdline); > + > + kfree(comm); > + kfree(cmdline); > } > > int msm_gpu_hw_init(struct msm_gpu *gpu)
On Tue, Apr 18, 2023 at 1:53 AM Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > > > On 17/04/2023 21:12, Rob Clark wrote: > > From: Rob Clark <robdclark@chromium.org> > > > > Normally this would be the same information that can be obtained in > > other ways. But in some cases the process opening the drm fd is merely > > a sort of proxy for the actual process using the GPU. This is the case > > for guest VM processes using the GPU via virglrenderer, in which case > > the msm native-context renderer in virglrenderer overrides the comm/ > > cmdline to be the guest process's values. > > > > Exposing this via fdinfo allows tools like gputop to show something more > > meaningful than just a bunch of "pcivirtio-gpu" users. > > You also later expanded with: > > """ > I should have also mentioned, in the VM/proxy scenario we have a > single process with separate drm_file's for each guest VM process. So > it isn't an option to just change the proxy process's name to match > the client. > """ > > So how does that work - this single process temporarily changes it's > name for each drm fd it opens and creates a context or it is actually in > the native context protocol? It is part of the protocol, the mesa driver in the VM sends[1] this info to the native-context "shim" in host userspace which uses the SET_PARAM ioctl to pass this to the kernel. In the host userspace there is just a single process (you see the host PID below) but it does a separate open() of the drm dev for each guest process (so that they each have their own GPU address space for isolation): DRM minor 128 PID MEM ACTIV NAME gpu 5297 200M 82M com.mojang.minecr |██████████████▏ | 1859 199M 0B chrome |█▉ | 5297 64M 9M surfaceflinger | | 5297 12M 0B org.chromium.arc. | | 5297 12M 0B com.android.syste | | 5297 12M 0B org.chromium.arc. | | 5297 26M 0B com.google.androi | | 5297 65M 0B system_server | | [1] https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/src/drm/msm/msm_proto.h#L326 [2] https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/src/drm/msm/msm_renderer.c#L1050 > > > > Signed-off-by: Rob Clark <robdclark@chromium.org> > > --- > > Documentation/gpu/drm-usage-stats.rst | 8 ++++++++ > > drivers/gpu/drm/msm/msm_gpu.c | 14 ++++++++++++++ > > 2 files changed, 22 insertions(+) > > > > diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst > > index 8e00d53231e0..bc90bed455e3 100644 > > --- a/Documentation/gpu/drm-usage-stats.rst > > +++ b/Documentation/gpu/drm-usage-stats.rst > > @@ -148,6 +148,14 @@ percentage utilization of the engine, whereas drm-engine-<keystr> only reflects > > time active without considering what frequency the engine is operating as a > > percentage of it's maximum frequency. > > > > +- drm-comm: <valstr> > > + > > +Returns the clients executable path. > > Full path and not just current->comm? In this case probably give it a > more descriptive name here. > > drm-client-executable > drm-client-command-line > > So we stay in the drm-client- namespace? > > Or if the former is absolute path could one key be enough for both? > > drm-client-command-line: /path/to/executable --arguments comm and cmdline can be different. Android seems to change the comm to the apk name, for example (and w/ the zygote stuff cmdline isn't really a thing) I guess it could be drm-client-comm and drm-client-cmdline? Although comm/cmdline aren't the best names, they are just following what the kernel calls them elsewhere. > > + > > +- drm-cmdline: <valstr> > > + > > +Returns the clients cmdline. > > I think drm-usage-stats.rst text should provide some more text with > these two. To precisely define their content and outline the use case > under which driver authors may want to add them, and fdinfo consumer > therefore expect to see them. Just so everything is completely clear and > people do not start adding them for drivers which do not support native > context (or like). I really was just piggy-backing on existing comm/cmdline.. but I'll try to write up something better. I think it maybe should not be limited just to native context.. for ex. if the browser did somehow manage to create different displays associated with different drm_file instances (I guess it would have to use gbm to do this?) it would be nice to see browser tab names. > But on the overall it sounds reasonable to me - it would be really cool > to not just see pcivirtio-gpu as you say. Even if the standard virtiogpu > use case (not native context) could show real users. For vrend/virgl, we'd first need to solve the issue that there is just a single drm_file for all guest processes. But really, just don't use virgl. (I mean, like seriously, would you put a gl driver in the kernel? Vrend has access to all guest memory, so this is essentially what you have with virgl. This is just not a sane thing to do.) The only "valid" reason for not doing native-context is if you don't have the src code for your UMD to be able to modify it to talk native-context to virtgpu in the guest. ;-) BR, -R > Regards, > > Tvrtko > > > + > > Implementation Details > > ====================== > > > > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > > index f0f4f845c32d..1150dcbf28aa 100644 > > --- a/drivers/gpu/drm/msm/msm_gpu.c > > +++ b/drivers/gpu/drm/msm/msm_gpu.c > > @@ -148,12 +148,26 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) > > return 0; > > } > > > > +static void get_comm_cmdline(struct msm_file_private *ctx, char **comm, char **cmd); > > + > > void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > > struct drm_printer *p) > > { > > + char *comm, *cmdline; > > + > > + get_comm_cmdline(ctx, &comm, &cmdline); > > + > > drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); > > drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); > > drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); > > + > > + if (comm) > > + drm_printf(p, "drm-comm:\t%s\n", comm); > > + if (cmdline) > > + drm_printf(p, "drm-cmdline:\t%s\n", cmdline); > > + > > + kfree(comm); > > + kfree(cmdline); > > } > > > > int msm_gpu_hw_init(struct msm_gpu *gpu)
On 18/04/2023 15:56, Rob Clark wrote: > On Tue, Apr 18, 2023 at 1:53 AM Tvrtko Ursulin > <tvrtko.ursulin@linux.intel.com> wrote: >> >> >> On 17/04/2023 21:12, Rob Clark wrote: >>> From: Rob Clark <robdclark@chromium.org> >>> >>> Normally this would be the same information that can be obtained in >>> other ways. But in some cases the process opening the drm fd is merely >>> a sort of proxy for the actual process using the GPU. This is the case >>> for guest VM processes using the GPU via virglrenderer, in which case >>> the msm native-context renderer in virglrenderer overrides the comm/ >>> cmdline to be the guest process's values. >>> >>> Exposing this via fdinfo allows tools like gputop to show something more >>> meaningful than just a bunch of "pcivirtio-gpu" users. >> >> You also later expanded with: >> >> """ >> I should have also mentioned, in the VM/proxy scenario we have a >> single process with separate drm_file's for each guest VM process. So >> it isn't an option to just change the proxy process's name to match >> the client. >> """ >> >> So how does that work - this single process temporarily changes it's >> name for each drm fd it opens and creates a context or it is actually in >> the native context protocol? > > It is part of the protocol, the mesa driver in the VM sends[1] this > info to the native-context "shim" in host userspace which uses the > SET_PARAM ioctl to pass this to the kernel. In the host userspace > there is just a single process (you see the host PID below) but it > does a separate open() of the drm dev for each guest process (so that > they each have their own GPU address space for isolation): > > DRM minor 128 > PID MEM ACTIV NAME gpu > 5297 200M 82M com.mojang.minecr |██████████████▏ | > 1859 199M 0B chrome |█▉ | > 5297 64M 9M surfaceflinger | | > 5297 12M 0B org.chromium.arc. | | > 5297 12M 0B com.android.syste | | > 5297 12M 0B org.chromium.arc. | | > 5297 26M 0B com.google.androi | | > 5297 65M 0B system_server | | > > > [1] https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/src/drm/msm/msm_proto.h#L326 > [2] https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/src/drm/msm/msm_renderer.c#L1050 > >>> >>> Signed-off-by: Rob Clark <robdclark@chromium.org> >>> --- >>> Documentation/gpu/drm-usage-stats.rst | 8 ++++++++ >>> drivers/gpu/drm/msm/msm_gpu.c | 14 ++++++++++++++ >>> 2 files changed, 22 insertions(+) >>> >>> diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst >>> index 8e00d53231e0..bc90bed455e3 100644 >>> --- a/Documentation/gpu/drm-usage-stats.rst >>> +++ b/Documentation/gpu/drm-usage-stats.rst >>> @@ -148,6 +148,14 @@ percentage utilization of the engine, whereas drm-engine-<keystr> only reflects >>> time active without considering what frequency the engine is operating as a >>> percentage of it's maximum frequency. >>> >>> +- drm-comm: <valstr> >>> + >>> +Returns the clients executable path. >> >> Full path and not just current->comm? In this case probably give it a >> more descriptive name here. >> >> drm-client-executable >> drm-client-command-line >> >> So we stay in the drm-client- namespace? >> >> Or if the former is absolute path could one key be enough for both? >> >> drm-client-command-line: /path/to/executable --arguments > > comm and cmdline can be different. Android seems to change the comm to > the apk name, for example (and w/ the zygote stuff cmdline isn't > really a thing) > > I guess it could be drm-client-comm and drm-client-cmdline? Although > comm/cmdline aren't the best names, they are just following what the > kernel calls them elsewhere. I wasn't sure what do you plan to do given mention of a path under the drm-comm description. If it is a path then comm would be misleading, since comm as defined in procfs is not a path, I don't think so at least. Which is why I was suggesting executable. But if you remove the mention of a path from rst and rather refer to processes' comm value I think that is then okay. >>> + >>> +- drm-cmdline: <valstr> >>> + >>> +Returns the clients cmdline. >> >> I think drm-usage-stats.rst text should provide some more text with >> these two. To precisely define their content and outline the use case >> under which driver authors may want to add them, and fdinfo consumer >> therefore expect to see them. Just so everything is completely clear and >> people do not start adding them for drivers which do not support native >> context (or like). > > I really was just piggy-backing on existing comm/cmdline.. but I'll > try to write up something better. > > I think it maybe should not be limited just to native context.. for > ex. if the browser did somehow manage to create different displays > associated with different drm_file instances (I guess it would have to > use gbm to do this?) it would be nice to see browser tab names. Would be cool yes. My thinking behind why we maybe do not want to blanket add them is because for common case is it the same information which can be obtained from procfs. Like in igt_drm_clients.c I get the pid and comm from /proc/$pid/stat. So I was thinking it is only interesting to add to fdinfo for drivers where it could differ by the explicit override like you have with native context. It can be added once there is a GL/whatever extension which would allow it? (I am not familiar with how browsers manage rendering contexts so maybe I am missing something.) >> But on the overall it sounds reasonable to me - it would be really cool >> to not just see pcivirtio-gpu as you say. Even if the standard virtiogpu >> use case (not native context) could show real users. > > For vrend/virgl, we'd first need to solve the issue that there is just > a single drm_file for all guest processes. But really, just don't use > virgl. (I mean, like seriously, would you put a gl driver in the > kernel? Vrend has access to all guest memory, so this is essentially > what you have with virgl. This is just not a sane thing to do.) The > only "valid" reason for not doing native-context is if you don't have > the src code for your UMD to be able to modify it to talk > native-context to virtgpu in the guest. ;-) I am just observing the current state of things on an Intel based Chromebook. :) Presumably the custom name for a context would be passable via the virtio-gpu protocol or something? Regards, Tvrtko > > BR, > -R > >> Regards, >> >> Tvrtko >> >>> + >>> Implementation Details >>> ====================== >>> >>> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c >>> index f0f4f845c32d..1150dcbf28aa 100644 >>> --- a/drivers/gpu/drm/msm/msm_gpu.c >>> +++ b/drivers/gpu/drm/msm/msm_gpu.c >>> @@ -148,12 +148,26 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) >>> return 0; >>> } >>> >>> +static void get_comm_cmdline(struct msm_file_private *ctx, char **comm, char **cmd); >>> + >>> void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, >>> struct drm_printer *p) >>> { >>> + char *comm, *cmdline; >>> + >>> + get_comm_cmdline(ctx, &comm, &cmdline); >>> + >>> drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); >>> drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); >>> drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); >>> + >>> + if (comm) >>> + drm_printf(p, "drm-comm:\t%s\n", comm); >>> + if (cmdline) >>> + drm_printf(p, "drm-cmdline:\t%s\n", cmdline); >>> + >>> + kfree(comm); >>> + kfree(cmdline); >>> } >>> >>> int msm_gpu_hw_init(struct msm_gpu *gpu)
On Wed, Apr 19, 2023 at 6:36 AM Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > > > On 18/04/2023 15:56, Rob Clark wrote: > > On Tue, Apr 18, 2023 at 1:53 AM Tvrtko Ursulin > > <tvrtko.ursulin@linux.intel.com> wrote: > >> > >> > >> On 17/04/2023 21:12, Rob Clark wrote: > >>> From: Rob Clark <robdclark@chromium.org> > >>> > >>> Normally this would be the same information that can be obtained in > >>> other ways. But in some cases the process opening the drm fd is merely > >>> a sort of proxy for the actual process using the GPU. This is the case > >>> for guest VM processes using the GPU via virglrenderer, in which case > >>> the msm native-context renderer in virglrenderer overrides the comm/ > >>> cmdline to be the guest process's values. > >>> > >>> Exposing this via fdinfo allows tools like gputop to show something more > >>> meaningful than just a bunch of "pcivirtio-gpu" users. > >> > >> You also later expanded with: > >> > >> """ > >> I should have also mentioned, in the VM/proxy scenario we have a > >> single process with separate drm_file's for each guest VM process. So > >> it isn't an option to just change the proxy process's name to match > >> the client. > >> """ > >> > >> So how does that work - this single process temporarily changes it's > >> name for each drm fd it opens and creates a context or it is actually in > >> the native context protocol? > > > > It is part of the protocol, the mesa driver in the VM sends[1] this > > info to the native-context "shim" in host userspace which uses the > > SET_PARAM ioctl to pass this to the kernel. In the host userspace > > there is just a single process (you see the host PID below) but it > > does a separate open() of the drm dev for each guest process (so that > > they each have their own GPU address space for isolation): > > > > DRM minor 128 > > PID MEM ACTIV NAME gpu > > 5297 200M 82M com.mojang.minecr |██████████████▏ | > > 1859 199M 0B chrome |█▉ | > > 5297 64M 9M surfaceflinger | | > > 5297 12M 0B org.chromium.arc. | | > > 5297 12M 0B com.android.syste | | > > 5297 12M 0B org.chromium.arc. | | > > 5297 26M 0B com.google.androi | | > > 5297 65M 0B system_server | | > > > > > > [1] https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/src/drm/msm/msm_proto.h#L326 > > [2] https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/src/drm/msm/msm_renderer.c#L1050 > > > >>> > >>> Signed-off-by: Rob Clark <robdclark@chromium.org> > >>> --- > >>> Documentation/gpu/drm-usage-stats.rst | 8 ++++++++ > >>> drivers/gpu/drm/msm/msm_gpu.c | 14 ++++++++++++++ > >>> 2 files changed, 22 insertions(+) > >>> > >>> diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst > >>> index 8e00d53231e0..bc90bed455e3 100644 > >>> --- a/Documentation/gpu/drm-usage-stats.rst > >>> +++ b/Documentation/gpu/drm-usage-stats.rst > >>> @@ -148,6 +148,14 @@ percentage utilization of the engine, whereas drm-engine-<keystr> only reflects > >>> time active without considering what frequency the engine is operating as a > >>> percentage of it's maximum frequency. > >>> > >>> +- drm-comm: <valstr> > >>> + > >>> +Returns the clients executable path. > >> > >> Full path and not just current->comm? In this case probably give it a > >> more descriptive name here. > >> > >> drm-client-executable > >> drm-client-command-line > >> > >> So we stay in the drm-client- namespace? > >> > >> Or if the former is absolute path could one key be enough for both? > >> > >> drm-client-command-line: /path/to/executable --arguments > > > > comm and cmdline can be different. Android seems to change the comm to > > the apk name, for example (and w/ the zygote stuff cmdline isn't > > really a thing) > > > > I guess it could be drm-client-comm and drm-client-cmdline? Although > > comm/cmdline aren't the best names, they are just following what the > > kernel calls them elsewhere. > > I wasn't sure what do you plan to do given mention of a path under the > drm-comm description. If it is a path then comm would be misleading, > since comm as defined in procfs is not a path, I don't think so at > least. Which is why I was suggesting executable. But if you remove the > mention of a path from rst and rather refer to processes' comm value I > think that is then okay. Oh, whoops the mention of "path" for comm was a mistake. task->comm is described as executable name without path, and that is what the fdinfo field was intending to follow. > >>> + > >>> +- drm-cmdline: <valstr> > >>> + > >>> +Returns the clients cmdline. > >> > >> I think drm-usage-stats.rst text should provide some more text with > >> these two. To precisely define their content and outline the use case > >> under which driver authors may want to add them, and fdinfo consumer > >> therefore expect to see them. Just so everything is completely clear and > >> people do not start adding them for drivers which do not support native > >> context (or like). > > > > I really was just piggy-backing on existing comm/cmdline.. but I'll > > try to write up something better. > > > > I think it maybe should not be limited just to native context.. for > > ex. if the browser did somehow manage to create different displays > > associated with different drm_file instances (I guess it would have to > > use gbm to do this?) it would be nice to see browser tab names. > > Would be cool yes. > > My thinking behind why we maybe do not want to blanket add them is > because for common case is it the same information which can be obtained > from procfs. Like in igt_drm_clients.c I get the pid and comm from > /proc/$pid/stat. So I was thinking it is only interesting to add to > fdinfo for drivers where it could differ by the explicit override like > you have with native context. Yeah, I suppose I could define them as drm-client-comm-override and drm-client-cmdline-override > It can be added once there is a GL/whatever extension which would allow > it? (I am not familiar with how browsers manage rendering contexts so > maybe I am missing something.) > > >> But on the overall it sounds reasonable to me - it would be really cool > >> to not just see pcivirtio-gpu as you say. Even if the standard virtiogpu > >> use case (not native context) could show real users. > > > > For vrend/virgl, we'd first need to solve the issue that there is just > > a single drm_file for all guest processes. But really, just don't use > > virgl. (I mean, like seriously, would you put a gl driver in the > > kernel? Vrend has access to all guest memory, so this is essentially > > what you have with virgl. This is just not a sane thing to do.) The > > only "valid" reason for not doing native-context is if you don't have > > the src code for your UMD to be able to modify it to talk > > native-context to virtgpu in the guest. ;-) > > I am just observing the current state of things on an Intel based > Chromebook. :) Presumably the custom name for a context would be > passable via the virtio-gpu protocol or something? It is part of the context-type specific protocol. Ie. some parts of the protocol are "core" and dealt with in virtgpu guest kernel driver. But on top of that there are various context-types with their own protocol (ie. virgl, venus, cross-domain, msm native ctx, and some WIP native ctx types floating around) BR, -R > Regards, > > Tvrtko > > > > > BR, > > -R > > > >> Regards, > >> > >> Tvrtko > >> > >>> + > >>> Implementation Details > >>> ====================== > >>> > >>> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > >>> index f0f4f845c32d..1150dcbf28aa 100644 > >>> --- a/drivers/gpu/drm/msm/msm_gpu.c > >>> +++ b/drivers/gpu/drm/msm/msm_gpu.c > >>> @@ -148,12 +148,26 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) > >>> return 0; > >>> } > >>> > >>> +static void get_comm_cmdline(struct msm_file_private *ctx, char **comm, char **cmd); > >>> + > >>> void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > >>> struct drm_printer *p) > >>> { > >>> + char *comm, *cmdline; > >>> + > >>> + get_comm_cmdline(ctx, &comm, &cmdline); > >>> + > >>> drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); > >>> drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); > >>> drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); > >>> + > >>> + if (comm) > >>> + drm_printf(p, "drm-comm:\t%s\n", comm); > >>> + if (cmdline) > >>> + drm_printf(p, "drm-cmdline:\t%s\n", cmdline); > >>> + > >>> + kfree(comm); > >>> + kfree(cmdline); > >>> } > >>> > >>> int msm_gpu_hw_init(struct msm_gpu *gpu)
diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst index 8e00d53231e0..bc90bed455e3 100644 --- a/Documentation/gpu/drm-usage-stats.rst +++ b/Documentation/gpu/drm-usage-stats.rst @@ -148,6 +148,14 @@ percentage utilization of the engine, whereas drm-engine-<keystr> only reflects time active without considering what frequency the engine is operating as a percentage of it's maximum frequency. +- drm-comm: <valstr> + +Returns the clients executable path. + +- drm-cmdline: <valstr> + +Returns the clients cmdline. + Implementation Details ====================== diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index f0f4f845c32d..1150dcbf28aa 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -148,12 +148,26 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) return 0; } +static void get_comm_cmdline(struct msm_file_private *ctx, char **comm, char **cmd); + void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, struct drm_printer *p) { + char *comm, *cmdline; + + get_comm_cmdline(ctx, &comm, &cmdline); + drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); + + if (comm) + drm_printf(p, "drm-comm:\t%s\n", comm); + if (cmdline) + drm_printf(p, "drm-cmdline:\t%s\n", cmdline); + + kfree(comm); + kfree(cmdline); } int msm_gpu_hw_init(struct msm_gpu *gpu)