* [PATCH v3 0/7] drm: fdinfo memory stats @ 2023-04-11 22:56 Rob Clark 2023-04-11 22:56 ` [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper Rob Clark 2023-04-12 9:34 ` [PATCH v3 0/7] drm: fdinfo memory stats Christian König 0 siblings, 2 replies; 6+ messages in thread From: Rob Clark @ 2023-04-11 22:56 UTC (permalink / raw) To: dri-devel Cc: open list:DOCUMENTATION, open list, Michel Dänzer, YiPeng Chai, Mario Limonciello, Rob Clark, Guchun Chen, Shashank Sharma, open list:RADEON and AMDGPU DRM DRIVERS, Russell King, Arunpravin Paneer Selvam, linux-arm-msm, intel-gfx, moderated list:DRM DRIVERS FOR VIVANTE GPU IP, Christian Gmeiner, Evan Quan, Sean Paul, Tvrtko Ursulin, Tvrtko Ursulin, Emil Velikov, Christopher Healy, Boris Brezillon, Alex Deucher, freedreno, Christian König, Hawking Zhang From: Rob Clark <robdclark@chromium.org> Similar motivation to other similar recent attempt[1]. But with an attempt to have some shared code for this. As well as documentation. It is probably a bit UMA-centric, I guess devices with VRAM might want some placement stats as well. But this seems like a reasonable start. Basic gputop support: https://patchwork.freedesktop.org/series/116236/ And already nvtop support: https://github.com/Syllo/nvtop/pull/204 [1] https://patchwork.freedesktop.org/series/112397/ Rob Clark (7): drm: Add common fdinfo helper drm/msm: Switch to fdinfo helper drm/amdgpu: Switch to fdinfo helper drm/i915: Switch to fdinfo helper drm/etnaviv: Switch to fdinfo helper drm: Add fdinfo memory stats drm/msm: Add memory stats to fdinfo Documentation/gpu/drm-usage-stats.rst | 21 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- drivers/gpu/drm/drm_file.c | 115 +++++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 +- drivers/gpu/drm/i915/i915_driver.c | 3 +- drivers/gpu/drm/i915/i915_drm_client.c | 18 +--- drivers/gpu/drm/i915/i915_drm_client.h | 2 +- drivers/gpu/drm/msm/msm_drv.c | 11 +- drivers/gpu/drm/msm/msm_gem.c | 15 +++ drivers/gpu/drm/msm/msm_gpu.c | 2 - include/drm/drm_drv.h | 7 ++ include/drm/drm_file.h | 5 + include/drm/drm_gem.h | 19 ++++ 15 files changed, 208 insertions(+), 41 deletions(-) -- 2.39.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper 2023-04-11 22:56 [PATCH v3 0/7] drm: fdinfo memory stats Rob Clark @ 2023-04-11 22:56 ` Rob Clark 2023-04-12 7:58 ` Daniel Vetter 2023-04-12 9:34 ` [PATCH v3 0/7] drm: fdinfo memory stats Christian König 1 sibling, 1 reply; 6+ messages in thread From: Rob Clark @ 2023-04-11 22:56 UTC (permalink / raw) To: dri-devel Cc: open list, Michel Dänzer, YiPeng Chai, Mario Limonciello, David Airlie, Rob Clark, Guchun Chen, Shashank Sharma, open list:RADEON and AMDGPU DRM DRIVERS, Arunpravin Paneer Selvam, linux-arm-msm, Evan Quan, Tvrtko Ursulin, Tvrtko Ursulin, Pan, Xinhui, Emil Velikov, Christopher Healy, Boris Brezillon, Daniel Vetter, Alex Deucher, freedreno, Christian König, Hawking Zhang From: Rob Clark <robdclark@chromium.org> Signed-off-by: Rob Clark <robdclark@chromium.org> --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 ++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index f5ffca24def4..3611cfd5f076 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2752,7 +2752,7 @@ static const struct file_operations amdgpu_driver_kms_fops = { .compat_ioctl = amdgpu_kms_compat_ioctl, #endif #ifdef CONFIG_PROC_FS - .show_fdinfo = amdgpu_show_fdinfo + .show_fdinfo = drm_fop_show_fdinfo, #endif }; @@ -2807,6 +2807,7 @@ static const struct drm_driver amdgpu_kms_driver = { .dumb_map_offset = amdgpu_mode_dumb_mmap, .fops = &amdgpu_driver_kms_fops, .release = &amdgpu_driver_release_kms, + .show_fdinfo = amdgpu_show_fdinfo, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index 99a7855ab1bc..c2fdd5e448d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -53,9 +53,8 @@ static const char *amdgpu_ip_name[AMDGPU_HW_IP_NUM] = { [AMDGPU_HW_IP_VCN_JPEG] = "jpeg", }; -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) { - struct drm_file *file = f->private_data; struct amdgpu_device *adev = drm_to_adev(file->minor->dev); struct amdgpu_fpriv *fpriv = file->driver_priv; struct amdgpu_vm *vm = &fpriv->vm; @@ -86,18 +85,15 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) * ****************************************************************** */ - seq_printf(m, "pasid:\t%u\n", fpriv->vm.pasid); - seq_printf(m, "drm-driver:\t%s\n", file->minor->dev->driver->name); - seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n", domain, bus, dev, fn); - seq_printf(m, "drm-client-id:\t%Lu\n", vm->immediate.fence_context); - seq_printf(m, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); - seq_printf(m, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); - seq_printf(m, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); + drm_printf(p, "pasid:\t%u\n", fpriv->vm.pasid); + drm_printf(p, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); + drm_printf(p, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); + drm_printf(p, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); for (hw_ip = 0; hw_ip < AMDGPU_HW_IP_NUM; ++hw_ip) { if (!usage[hw_ip]) continue; - seq_printf(m, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], + drm_printf(p, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], ktime_to_ns(usage[hw_ip])); } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h index e86834bfea1d..0398f5a159ef 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h @@ -37,6 +37,6 @@ #include "amdgpu_ids.h" uint32_t amdgpu_get_ip_count(struct amdgpu_device *adev, int id); -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f); +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file); #endif -- 2.39.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper 2023-04-11 22:56 ` [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper Rob Clark @ 2023-04-12 7:58 ` Daniel Vetter 0 siblings, 0 replies; 6+ messages in thread From: Daniel Vetter @ 2023-04-12 7:58 UTC (permalink / raw) To: Rob Clark Cc: dri-devel, open list, Michel Dänzer, YiPeng Chai, Mario Limonciello, David Airlie, Rob Clark, Guchun Chen, Shashank Sharma, open list:RADEON and AMDGPU DRM DRIVERS, Arunpravin Paneer Selvam, linux-arm-msm, Evan Quan, Tvrtko Ursulin, Tvrtko Ursulin, Pan, Xinhui, Emil Velikov, Christopher Healy, Boris Brezillon, Daniel Vetter, Alex Deucher, freedreno, Christian König, Hawking Zhang On Tue, Apr 11, 2023 at 03:56:08PM -0700, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > Signed-off-by: Rob Clark <robdclark@chromium.org> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- > drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 ++++++---------- > drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- > 3 files changed, 9 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > index f5ffca24def4..3611cfd5f076 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > @@ -2752,7 +2752,7 @@ static const struct file_operations amdgpu_driver_kms_fops = { > .compat_ioctl = amdgpu_kms_compat_ioctl, > #endif > #ifdef CONFIG_PROC_FS > - .show_fdinfo = amdgpu_show_fdinfo > + .show_fdinfo = drm_fop_show_fdinfo, > #endif > }; > > @@ -2807,6 +2807,7 @@ static const struct drm_driver amdgpu_kms_driver = { > .dumb_map_offset = amdgpu_mode_dumb_mmap, > .fops = &amdgpu_driver_kms_fops, > .release = &amdgpu_driver_release_kms, > + .show_fdinfo = amdgpu_show_fdinfo, > > .prime_handle_to_fd = drm_gem_prime_handle_to_fd, > .prime_fd_to_handle = drm_gem_prime_fd_to_handle, > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c > index 99a7855ab1bc..c2fdd5e448d1 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c > @@ -53,9 +53,8 @@ static const char *amdgpu_ip_name[AMDGPU_HW_IP_NUM] = { > [AMDGPU_HW_IP_VCN_JPEG] = "jpeg", > }; > > -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) > +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) > { > - struct drm_file *file = f->private_data; > struct amdgpu_device *adev = drm_to_adev(file->minor->dev); > struct amdgpu_fpriv *fpriv = file->driver_priv; > struct amdgpu_vm *vm = &fpriv->vm; > @@ -86,18 +85,15 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) > * ****************************************************************** > */ > > - seq_printf(m, "pasid:\t%u\n", fpriv->vm.pasid); > - seq_printf(m, "drm-driver:\t%s\n", file->minor->dev->driver->name); > - seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n", domain, bus, dev, fn); > - seq_printf(m, "drm-client-id:\t%Lu\n", vm->immediate.fence_context); > - seq_printf(m, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); > - seq_printf(m, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); > - seq_printf(m, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); > + drm_printf(p, "pasid:\t%u\n", fpriv->vm.pasid); > + drm_printf(p, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); > + drm_printf(p, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); > + drm_printf(p, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); random aside, but we're not super consistent here, some of these have an additional ' ' space. I guess a next step would be a drm_fdinfo_printf(drm_printer *p, const char *name, const char *printf, ...) and maybe some specialized ones that dtrt for specific parameters, like drm_fdinfo_llu(). But that's for next one I guess :-) -Daniel > for (hw_ip = 0; hw_ip < AMDGPU_HW_IP_NUM; ++hw_ip) { > if (!usage[hw_ip]) > continue; > > - seq_printf(m, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], > + drm_printf(p, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], > ktime_to_ns(usage[hw_ip])); > } > } > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h > index e86834bfea1d..0398f5a159ef 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h > @@ -37,6 +37,6 @@ > #include "amdgpu_ids.h" > > uint32_t amdgpu_get_ip_count(struct amdgpu_device *adev, int id); > -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f); > +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file); > > #endif > -- > 2.39.2 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/7] drm: fdinfo memory stats 2023-04-11 22:56 [PATCH v3 0/7] drm: fdinfo memory stats Rob Clark 2023-04-11 22:56 ` [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper Rob Clark @ 2023-04-12 9:34 ` Christian König 2023-04-12 12:10 ` Tvrtko Ursulin 1 sibling, 1 reply; 6+ messages in thread From: Christian König @ 2023-04-12 9:34 UTC (permalink / raw) To: Rob Clark, dri-devel Cc: open list:DOCUMENTATION, open list, Michel Dänzer, YiPeng Chai, Mario Limonciello, Rob Clark, Guchun Chen, Shashank Sharma, open list:RADEON and AMDGPU DRM DRIVERS, Russell King, Arunpravin Paneer Selvam, linux-arm-msm, intel-gfx, moderated list:DRM DRIVERS FOR VIVANTE GPU IP, Christian Gmeiner, Evan Quan, Sean Paul, Tvrtko Ursulin, Tvrtko Ursulin, Emil Velikov, Christopher Healy, Boris Brezillon, Alex Deucher, freedreno, Hawking Zhang Am 12.04.23 um 00:56 schrieb Rob Clark: > From: Rob Clark <robdclark@chromium.org> > > Similar motivation to other similar recent attempt[1]. But with an > attempt to have some shared code for this. As well as documentation. > > It is probably a bit UMA-centric, I guess devices with VRAM might want > some placement stats as well. But this seems like a reasonable start. > > Basic gputop support: https://patchwork.freedesktop.org/series/116236/ > And already nvtop support: https://github.com/Syllo/nvtop/pull/204 > > [1] https://patchwork.freedesktop.org/series/112397/ I think the extra client id looks a bit superfluous since the ino of the file should already be unique and IIRC we have been already using that one. Apart from that looks good to me, Christian. PS: For some reason only the two patches I was CCed on ended up in my inbox, dri-devel swallowed all the rest and hasn't spit it out yet. Had to dig up the rest from patchwork. > > Rob Clark (7): > drm: Add common fdinfo helper > drm/msm: Switch to fdinfo helper > drm/amdgpu: Switch to fdinfo helper > drm/i915: Switch to fdinfo helper > drm/etnaviv: Switch to fdinfo helper > drm: Add fdinfo memory stats > drm/msm: Add memory stats to fdinfo > > Documentation/gpu/drm-usage-stats.rst | 21 ++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 ++- > drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- > drivers/gpu/drm/drm_file.c | 115 +++++++++++++++++++++ > drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 +- > drivers/gpu/drm/i915/i915_driver.c | 3 +- > drivers/gpu/drm/i915/i915_drm_client.c | 18 +--- > drivers/gpu/drm/i915/i915_drm_client.h | 2 +- > drivers/gpu/drm/msm/msm_drv.c | 11 +- > drivers/gpu/drm/msm/msm_gem.c | 15 +++ > drivers/gpu/drm/msm/msm_gpu.c | 2 - > include/drm/drm_drv.h | 7 ++ > include/drm/drm_file.h | 5 + > include/drm/drm_gem.h | 19 ++++ > 15 files changed, 208 insertions(+), 41 deletions(-) > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/7] drm: fdinfo memory stats 2023-04-12 9:34 ` [PATCH v3 0/7] drm: fdinfo memory stats Christian König @ 2023-04-12 12:10 ` Tvrtko Ursulin 2023-04-12 12:22 ` Christian König 0 siblings, 1 reply; 6+ messages in thread From: Tvrtko Ursulin @ 2023-04-12 12:10 UTC (permalink / raw) To: Christian König, Rob Clark, dri-devel Cc: open list:DOCUMENTATION, open list, Michel Dänzer, YiPeng Chai, Mario Limonciello, Rob Clark, Guchun Chen, Shashank Sharma, open list:RADEON and AMDGPU DRM DRIVERS, Russell King, Arunpravin Paneer Selvam, linux-arm-msm, intel-gfx, moderated list:DRM DRIVERS FOR VIVANTE GPU IP, Christian Gmeiner, Evan Quan, Sean Paul, Tvrtko Ursulin, Emil Velikov, Christopher Healy, Boris Brezillon, Alex Deucher, freedreno, Hawking Zhang On 12/04/2023 10:34, Christian König wrote: > Am 12.04.23 um 00:56 schrieb Rob Clark: >> From: Rob Clark <robdclark@chromium.org> >> >> Similar motivation to other similar recent attempt[1]. But with an >> attempt to have some shared code for this. As well as documentation. >> >> It is probably a bit UMA-centric, I guess devices with VRAM might want >> some placement stats as well. But this seems like a reasonable start. >> >> Basic gputop support: https://patchwork.freedesktop.org/series/116236/ >> And already nvtop support: https://github.com/Syllo/nvtop/pull/204 >> >> [1] https://patchwork.freedesktop.org/series/112397/ > > I think the extra client id looks a bit superfluous since the ino of the > file should already be unique and IIRC we have been already using that one. Do you mean file_inode(struct drm_file->filp)->i_ino ? That one would be the same number for all clients which open the same device node so wouldn't work. I also don't think the atomic_add_return for client id works either, since it can alias on overflow. In i915 I use an xarray and __xa_alloc_cyclic. Regards, Tvrtko ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/7] drm: fdinfo memory stats 2023-04-12 12:10 ` Tvrtko Ursulin @ 2023-04-12 12:22 ` Christian König 0 siblings, 0 replies; 6+ messages in thread From: Christian König @ 2023-04-12 12:22 UTC (permalink / raw) To: Tvrtko Ursulin, Rob Clark, dri-devel Cc: open list:DOCUMENTATION, open list, Michel Dänzer, YiPeng Chai, Mario Limonciello, Rob Clark, Guchun Chen, Shashank Sharma, open list:RADEON and AMDGPU DRM DRIVERS, Russell King, Arunpravin Paneer Selvam, linux-arm-msm, intel-gfx, moderated list:DRM DRIVERS FOR VIVANTE GPU IP, Christian Gmeiner, Evan Quan, Sean Paul, Tvrtko Ursulin, Emil Velikov, Christopher Healy, Boris Brezillon, Alex Deucher, freedreno, Hawking Zhang Am 12.04.23 um 14:10 schrieb Tvrtko Ursulin: > > On 12/04/2023 10:34, Christian König wrote: >> Am 12.04.23 um 00:56 schrieb Rob Clark: >>> From: Rob Clark <robdclark@chromium.org> >>> >>> Similar motivation to other similar recent attempt[1]. But with an >>> attempt to have some shared code for this. As well as documentation. >>> >>> It is probably a bit UMA-centric, I guess devices with VRAM might want >>> some placement stats as well. But this seems like a reasonable start. >>> >>> Basic gputop support: https://patchwork.freedesktop.org/series/116236/ >>> And already nvtop support: https://github.com/Syllo/nvtop/pull/204 >>> >>> [1] https://patchwork.freedesktop.org/series/112397/ >> >> I think the extra client id looks a bit superfluous since the ino of >> the file should already be unique and IIRC we have been already using >> that one. > > Do you mean file_inode(struct drm_file->filp)->i_ino ? That one would > be the same number for all clients which open the same device node so > wouldn't work. Ah, right. DMA-buf used a separate ino per buffer, but we don't do that for the drm_file. > > I also don't think the atomic_add_return for client id works either, > since it can alias on overflow. Yeah, we might want to use a 64bit number here if any. Christian. > > In i915 I use an xarray and __xa_alloc_cyclic. > > Regards, > > Tvrtko ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-12 12:24 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-04-11 22:56 [PATCH v3 0/7] drm: fdinfo memory stats Rob Clark 2023-04-11 22:56 ` [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper Rob Clark 2023-04-12 7:58 ` Daniel Vetter 2023-04-12 9:34 ` [PATCH v3 0/7] drm: fdinfo memory stats Christian König 2023-04-12 12:10 ` Tvrtko Ursulin 2023-04-12 12:22 ` Christian König
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox