Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1957198rwr; Fri, 28 Apr 2023 04:21:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7dHN816ckF4Vv5AG4iJoQ4P8suNo5qY/pZ27LJZiwMByb0Jsr32ep3MCxNqQ3o1ey4YA6P X-Received: by 2002:a05:6a21:78a8:b0:f0:a5b8:59f9 with SMTP id bf40-20020a056a2178a800b000f0a5b859f9mr5905114pzc.15.1682680912198; Fri, 28 Apr 2023 04:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682680912; cv=none; d=google.com; s=arc-20160816; b=d8DrZigDSUmBP9iPnHHDKgQ6gROYGm7e9Vs0BXGiClNgnP7GMtCQy0cessRmCIBdfd nU14QMe35ulD/igQJ9bn/sc6QEpV4Pzo8WsACMxoAc9ZKUtSEbybRKXJFcnR0U54JoXT ugLJSMefaSkOiyBAfjzzCL5feXVmNbNy74vnHMRZRfsDD4nkSgVH6j3zBVySUGja2uLX M8H7egAcsgAqFMxNWAiXNZz64JRADatuoSBjjNOy/XVt16zdqU11brOMDsIcelIr1t3U PZ9uRSJzadYGRY4dNRHNaOHTwZktQNfb1zc0AdPWJqJl66dCMtjs0+26+Hn09Fcf2hfc 50mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=RSjtmOEvBZLgSH1M6GR+OqEmfpfwprgrz4AKhk7fnIs=; b=DPholmIAyoZkicSrcQIlBhsPnSRLsyikfrWZryZN5gt7uT5uaa8dNgPE+kdMm/6cJ1 Vww6Y1boUDOOvAchUo3p4XjmSeOo6lqGoOlcczwZtbuYXx4ofW8nxs3nbilYJoiDDH1o q70QR9QJxi0NGrBv7m7VRHfgpQBMTcRUWboINE7JA5rwPOneLKbtX1rCbWj/DcIXQ8FY 48qzON5hl1mCtXxFkoFolzr8V40XXN+NRlnk25wVpzcosa1yPT4HsCl+JPtmtWQV4jkN J9dZsbrszLlmbji/ghfjLWBkhKM4D0J1VqMGdLMxjIkPGlsst+R3VWlUCZzTsVn7lvn8 UL4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BlKYJbpb; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c123-20020a633581000000b00513576ea7casi20712681pga.795.2023.04.28.04.21.36; Fri, 28 Apr 2023 04:21:52 -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=@intel.com header.s=Intel header.b=BlKYJbpb; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345610AbjD1LGC (ORCPT + 99 others); Fri, 28 Apr 2023 07:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345747AbjD1LFx (ORCPT ); Fri, 28 Apr 2023 07:05:53 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EBA74EE4; Fri, 28 Apr 2023 04:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682679941; x=1714215941; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=4JhFUNxs2IOSAeCxq2g3p+MSBgp8v39081pRbpfGz6A=; b=BlKYJbpbfdMUzhvh9xwZWdaQhcq1hiUFfG5agy9giUJMLt2EdwWuTQBO 28ZX5oavG2CdRDuNsosK8CB3vZAxwAC0Z3fh0oBXLRpGlJxMh26tY8/9z Ns24w3h2QNKkmW3nuUnPBehBvR3aMqsbZcTcfsCZAzp2HtLDbKbZRbQV9 kJ7NMuibX6gu2b1gPI+sgOgIFXfF2Ygu+tMUYL2Umd594GoXb+c0qV53B +Pc+BuoX4XNCAmTwyBE6R2alj37kk+tQSJAH6Jb5Oae0HvPh7BHg9h/iS dMBysm5qwubMfZok1aHhNjloE7OiQIr9WtPaiaGRA3o4e1jOXGsZH6fmT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="434007265" X-IronPort-AV: E=Sophos;i="5.99,234,1677571200"; d="scan'208";a="434007265" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2023 04:05:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="838812488" X-IronPort-AV: E=Sophos;i="5.99,234,1677571200"; d="scan'208";a="838812488" Received: from ksathish-mobl.ger.corp.intel.com (HELO [10.213.194.196]) ([10.213.194.196]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2023 04:05:37 -0700 Message-ID: <135ff649-e50c-50f4-55ba-a1b615865e02@linux.intel.com> Date: Fri, 28 Apr 2023 12:05:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 8/9] drm/fdinfo: Add comm/cmdline override fields Content-Language: en-US To: Rob Clark , dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, Daniel Vetter , Boris Brezillon , Christopher Healy , Emil Velikov , =?UTF-8?Q?Christian_K=c3=b6nig?= , Rob Clark , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , "open list:DOCUMENTATION" , open list References: <20230427175340.1280952-1-robdclark@gmail.com> <20230427175340.1280952-9-robdclark@gmail.com> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc In-Reply-To: <20230427175340.1280952-9-robdclark@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: X-Mailing-List: linux-kernel@vger.kernel.org On 27/04/2023 18:53, Rob Clark wrote: > From: Rob Clark > > These are useful in particular for VM scenarios where the process which > has opened to drm device file is just a proxy for the real user in a VM > guest. > > Signed-off-by: Rob Clark > --- > Documentation/gpu/drm-usage-stats.rst | 18 ++++++++++++++++++ > drivers/gpu/drm/drm_file.c | 15 +++++++++++++++ > include/drm/drm_file.h | 19 +++++++++++++++++++ > 3 files changed, 52 insertions(+) > > diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst > index 58dc0d3f8c58..e4877cf8089c 100644 > --- a/Documentation/gpu/drm-usage-stats.rst > +++ b/Documentation/gpu/drm-usage-stats.rst > @@ -73,6 +73,24 @@ scope of each device, in which case `drm-pdev` shall be present as well. > Userspace should make sure to not double account any usage statistics by using > the above described criteria in order to associate data to individual clients. > > +- drm-comm-override: > + > +Returns the client executable override string. Some drivers support letting > +userspace override this in cases where the userspace is simply a "proxy". > +Such as is the case with virglrenderer drm native context, where the host > +process is just forwarding command submission, etc, from guest userspace. > +This allows the proxy to make visible the executable name of the actual > +app in the VM guest. > + > +- drm-cmdline-override: > + > +Returns the client cmdline override string. Some drivers support letting > +userspace override this in cases where the userspace is simply a "proxy". > +Such as is the case with virglrenderer drm native context, where the host > +process is just forwarding command submission, etc, from guest userspace. > +This allows the proxy to make visible the cmdline of the actual app in the > +VM guest. Perhaps it would be okay to save space here by not repeating the description, like: drm-comm-override: drm-cmdline-override: Long description blah blah... This allows the proxy to make visible the _executable name *and* command line_ blah blah.. > + > Utilization > ^^^^^^^^^^^ > > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c > index 9321eb0bf020..d7514c313af1 100644 > --- a/drivers/gpu/drm/drm_file.c > +++ b/drivers/gpu/drm/drm_file.c > @@ -178,6 +178,8 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor) > spin_lock_init(&file->master_lookup_lock); > mutex_init(&file->event_read_lock); > > + mutex_init(&file->override_lock); > + > if (drm_core_check_feature(dev, DRIVER_GEM)) > drm_gem_open(dev, file); > > @@ -292,6 +294,8 @@ void drm_file_free(struct drm_file *file) > WARN_ON(!list_empty(&file->event_list)); > > put_pid(file->pid); > + kfree(file->override_comm); > + kfree(file->override_cmdline); > kfree(file); > } > > @@ -995,6 +999,17 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f) > PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); > } > > + mutex_lock(&file->override_lock); You could add a fast unlocked check before taking the mutex for no risk apart a transient false negative. For 99.9999% of userspace it would mean no pointless lock/unlock cycle. > + if (file->override_comm) { > + drm_printf(&p, "drm-comm-override:\t%s\n", > + file->override_comm); > + } > + if (file->override_cmdline) { > + drm_printf(&p, "drm-cmdline-override:\t%s\n", > + file->override_cmdline); > + } > + mutex_unlock(&file->override_lock); > + > if (dev->driver->show_fdinfo) > dev->driver->show_fdinfo(&p, file); > } > diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h > index 1339e925af52..604d05fa6f0c 100644 > --- a/include/drm/drm_file.h > +++ b/include/drm/drm_file.h > @@ -370,6 +370,25 @@ struct drm_file { > */ > struct drm_prime_file_private prime; > > + /** > + * @comm: Overridden task comm > + * > + * Accessed under override_lock > + */ > + char *override_comm; > + > + /** > + * @cmdline: Overridden task cmdline > + * > + * Accessed under override_lock > + */ > + char *override_cmdline; > + > + /** > + * @override_lock: Serialize access to override_comm and override_cmdline > + */ > + struct mutex override_lock; > + I don't think this should go to drm just yet though. Only one driver can make use of it so I'd leave it for later and print from msm_show_fdinfo for now. Regards, Tvrtko > /* private: */ > #if IS_ENABLED(CONFIG_DRM_LEGACY) > unsigned long lock_count; /* DRI1 legacy lock count */