* Re: [Nouveau] [PATCH 0/7] Per client engine busyness [not found] ` <BYAPR12MB28409E25DEFD3DD620E596ABF42D9@BYAPR12MB2840.namprd12.prod.outlook.com> @ 2021-05-17 18:16 ` Nieto, David M 2021-05-17 19:03 ` Simon Ser 0 siblings, 1 reply; 13+ messages in thread From: Nieto, David M @ 2021-05-17 18:16 UTC (permalink / raw) To: Tvrtko Ursulin, Daniel Vetter, Koenig, Christian, jhubbard@nvidia.com, aritger@nvidia.com Cc: Alex Deucher, nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers [-- Attachment #1.1: Type: text/plain, Size: 3223 bytes --] [Public] Cycling some of the Nvidia/nouveau guys here too. I think there is a benefit on trying to estandarize how fdinfo can be used to expose per engine and device memory utilization. Another of the advantages of going the /proc/ way instead of the sysfs debugfs approach is that you inherit the access lists directly from the distribution and you don't need to start messing with ownership and group access. By default an user can monitor its own processes as long as /proc is mounted. I am not saying that fdinfo or the way we implemented is 100% the way to go, but I'd rather have a solution within the confines of proc first. David ________________________________ From: Nieto, David M <David.Nieto@amd.com> Sent: Monday, May 17, 2021 11:02 AM To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>; Daniel Vetter <daniel@ffwll.ch>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Alex Deucher <alexdeucher@gmail.com>; Intel Graphics Development <Intel-gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-devel@lists.freedesktop.org> Subject: Re: [PATCH 0/7] Per client engine busyness The format is simple: <ringname><index>: <XXX.XX> % we also have entries for the memory mapped: mem <ttm pool> : <size> KiB On my submission https://lists.freedesktop.org/archives/amd-gfx/2021-May/063149.html I added a python script to print out the info. It has a CPU usage lower that top, for example. To be absolutely honest, I agree that there is an overhead, but It might not be as much as you fear. ________________________________ From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Sent: Monday, May 17, 2021 9:00 AM To: Nieto, David M <David.Nieto@amd.com>; Daniel Vetter <daniel@ffwll.ch>; Koenig, Christian <Christian.Koenig@amd.com> Cc: Alex Deucher <alexdeucher@gmail.com>; Intel Graphics Development <Intel-gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-devel@lists.freedesktop.org> Subject: Re: [PATCH 0/7] Per client engine busyness On 17/05/2021 15:39, Nieto, David M wrote: > [AMD Official Use Only] > > > Maybe we could try to standardize how the different submission ring > usage gets exposed in the fdinfo? We went the simple way of just > adding name and index, but if someone has a suggestion on how else we > could format them so there is commonality across vendors we could just > amend those. Could you paste an example of your format? Standardized fdinfo sounds good to me in principle. But I would also like people to look at the procfs proposal from Chris, - link to which I have pasted elsewhere in the thread. Only potential issue with fdinfo I see at the moment is a bit of an extra cost in DRM client discovery (compared to my sysfs series and also procfs RFC from Chris). It would require reading all processes (well threads, then maybe aggregating threads into parent processes), all fd symlinks, and doing a stat on them to figure out which ones are DRM devices. Btw is DRM_MAJOR 226 consider uapi? I don't see it in uapi headers. > I’d really like to have the process managers tools display GPU usage > regardless of what vendor is installed. Definitely. Regards, Tvrtko [-- Attachment #1.2: Type: text/html, Size: 8121 bytes --] [-- Attachment #2: Type: text/plain, Size: 154 bytes --] _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 0/7] Per client engine busyness 2021-05-17 18:16 ` [Nouveau] [PATCH 0/7] Per client engine busyness Nieto, David M @ 2021-05-17 19:03 ` Simon Ser 2021-05-18 9:08 ` Tvrtko Ursulin 0 siblings, 1 reply; 13+ messages in thread From: Simon Ser @ 2021-05-17 19:03 UTC (permalink / raw) To: Nieto, David M Cc: Tvrtko Ursulin, nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Daniel Vetter, Koenig, Christian On Monday, May 17th, 2021 at 8:16 PM, Nieto, David M <David.Nieto@amd.com> wrote: > Btw is DRM_MAJOR 226 consider uapi? I don't see it in uapi headers. It's not in the headers, but it's de facto uAPI, as seen in libdrm: > git grep 226 xf86drm.c 99:#define DRM_MAJOR 226 /* Linux */ _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 0/7] Per client engine busyness 2021-05-17 19:03 ` Simon Ser @ 2021-05-18 9:08 ` Tvrtko Ursulin 2021-05-18 9:16 ` Daniel Stone 0 siblings, 1 reply; 13+ messages in thread From: Tvrtko Ursulin @ 2021-05-18 9:08 UTC (permalink / raw) To: Simon Ser, Nieto, David M Cc: nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Daniel Vetter, Koenig, Christian On 17/05/2021 20:03, Simon Ser wrote: > On Monday, May 17th, 2021 at 8:16 PM, Nieto, David M <David.Nieto@amd.com> wrote: > >> Btw is DRM_MAJOR 226 consider uapi? I don't see it in uapi headers. > > It's not in the headers, but it's de facto uAPI, as seen in libdrm: > > > git grep 226 > xf86drm.c > 99:#define DRM_MAJOR 226 /* Linux */ I suspected it would be yes, thanks. I was just wondering if stat(2) and a chrdev major check would be a solid criteria to more efficiently (compared to parsing the text content) detect drm files while walking procfs. Regards, Tvrtko _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 0/7] Per client engine busyness 2021-05-18 9:08 ` Tvrtko Ursulin @ 2021-05-18 9:16 ` Daniel Stone 2021-05-18 9:40 ` Tvrtko Ursulin 0 siblings, 1 reply; 13+ messages in thread From: Daniel Stone @ 2021-05-18 9:16 UTC (permalink / raw) To: Tvrtko Ursulin Cc: nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Simon Ser, Koenig, Christian, Nieto, David M Hi, On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > I was just wondering if stat(2) and a chrdev major check would be a > solid criteria to more efficiently (compared to parsing the text > content) detect drm files while walking procfs. Maybe I'm missing something, but is the per-PID walk actually a measurable performance issue rather than just a bit unpleasant? Cheers, Daniel _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 0/7] Per client engine busyness 2021-05-18 9:16 ` Daniel Stone @ 2021-05-18 9:40 ` Tvrtko Ursulin 2021-05-19 16:16 ` Tvrtko Ursulin 0 siblings, 1 reply; 13+ messages in thread From: Tvrtko Ursulin @ 2021-05-18 9:40 UTC (permalink / raw) To: Daniel Stone Cc: nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Simon Ser, Koenig, Christian, Nieto, David M On 18/05/2021 10:16, Daniel Stone wrote: > Hi, > > On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin > <tvrtko.ursulin@linux.intel.com> wrote: >> I was just wondering if stat(2) and a chrdev major check would be a >> solid criteria to more efficiently (compared to parsing the text >> content) detect drm files while walking procfs. > > Maybe I'm missing something, but is the per-PID walk actually a > measurable performance issue rather than just a bit unpleasant? Per pid and per each open fd. As said in the other thread what bothers me a bit in this scheme is that the cost of obtaining GPU usage scales based on non-GPU criteria. For use case of a top-like tool which shows all processes this is a smaller additional cost, but then for a gpu-top like tool it is somewhat higher. Regards, Tvrtko _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 0/7] Per client engine busyness 2021-05-18 9:40 ` Tvrtko Ursulin @ 2021-05-19 16:16 ` Tvrtko Ursulin 2021-05-19 18:23 ` [Nouveau] [Intel-gfx] " Daniel Vetter 0 siblings, 1 reply; 13+ messages in thread From: Tvrtko Ursulin @ 2021-05-19 16:16 UTC (permalink / raw) To: Daniel Stone Cc: nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Simon Ser, Koenig, Christian, Nieto, David M On 18/05/2021 10:40, Tvrtko Ursulin wrote: > > On 18/05/2021 10:16, Daniel Stone wrote: >> Hi, >> >> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin >> <tvrtko.ursulin@linux.intel.com> wrote: >>> I was just wondering if stat(2) and a chrdev major check would be a >>> solid criteria to more efficiently (compared to parsing the text >>> content) detect drm files while walking procfs. >> >> Maybe I'm missing something, but is the per-PID walk actually a >> measurable performance issue rather than just a bit unpleasant? > > Per pid and per each open fd. > > As said in the other thread what bothers me a bit in this scheme is that > the cost of obtaining GPU usage scales based on non-GPU criteria. > > For use case of a top-like tool which shows all processes this is a > smaller additional cost, but then for a gpu-top like tool it is somewhat > higher. To further expand, not only cost would scale per pid multiplies per open fd, but to detect which of the fds are DRM I see these three options: 1) Open and parse fdinfo. 2) Name based matching ie /dev/dri/.. something. 3) Stat the symlink target and check for DRM major. All sound quite sub-optimal to me. Name based matching is probably the least evil on system resource usage (Keeping the dentry cache too hot? Too many syscalls?), even though fundamentally I don't it is the right approach. What happens with dup(2) is another question. Does anyone have any feedback on the /proc/<pid>/gpu idea at all? Regards, Tvrtko _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-19 16:16 ` Tvrtko Ursulin @ 2021-05-19 18:23 ` Daniel Vetter 2021-05-19 23:17 ` Nieto, David M 2021-05-20 8:35 ` Tvrtko Ursulin 0 siblings, 2 replies; 13+ messages in thread From: Daniel Vetter @ 2021-05-19 18:23 UTC (permalink / raw) To: Tvrtko Ursulin Cc: Intel Graphics Development, Maling list - DRI developers, Daniel Stone, Simon Ser, nouveau@lists.freedesktop.org, Koenig, Christian, Nieto, David M On Wed, May 19, 2021 at 6:16 PM Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > > > On 18/05/2021 10:40, Tvrtko Ursulin wrote: > > > > On 18/05/2021 10:16, Daniel Stone wrote: > >> Hi, > >> > >> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin > >> <tvrtko.ursulin@linux.intel.com> wrote: > >>> I was just wondering if stat(2) and a chrdev major check would be a > >>> solid criteria to more efficiently (compared to parsing the text > >>> content) detect drm files while walking procfs. > >> > >> Maybe I'm missing something, but is the per-PID walk actually a > >> measurable performance issue rather than just a bit unpleasant? > > > > Per pid and per each open fd. > > > > As said in the other thread what bothers me a bit in this scheme is that > > the cost of obtaining GPU usage scales based on non-GPU criteria. > > > > For use case of a top-like tool which shows all processes this is a > > smaller additional cost, but then for a gpu-top like tool it is somewhat > > higher. > > To further expand, not only cost would scale per pid multiplies per open > fd, but to detect which of the fds are DRM I see these three options: > > 1) Open and parse fdinfo. > 2) Name based matching ie /dev/dri/.. something. > 3) Stat the symlink target and check for DRM major. stat with symlink following should be plenty fast. > All sound quite sub-optimal to me. > > Name based matching is probably the least evil on system resource usage > (Keeping the dentry cache too hot? Too many syscalls?), even though > fundamentally I don't it is the right approach. > > What happens with dup(2) is another question. We need benchmark numbers showing that on anything remotely realistic it's an actual problem. Until we've demonstrated it's a real problem we don't need to solve it. E.g. top with any sorting enabled also parses way more than it displays on every update. It seems to be doing Just Fine (tm). > Does anyone have any feedback on the /proc/<pid>/gpu idea at all? When we know we have a problem to solve we can take a look at solutions. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-19 18:23 ` [Nouveau] [Intel-gfx] " Daniel Vetter @ 2021-05-19 23:17 ` Nieto, David M 2021-05-20 14:11 ` Daniel Vetter 2021-05-20 8:35 ` Tvrtko Ursulin 1 sibling, 1 reply; 13+ messages in thread From: Nieto, David M @ 2021-05-19 23:17 UTC (permalink / raw) To: Daniel Vetter, Tvrtko Ursulin Cc: Intel Graphics Development, Maling list - DRI developers, Daniel Stone, Simon Ser, nouveau@lists.freedesktop.org, Koenig, Christian [-- Attachment #1.1: Type: text/plain, Size: 3525 bytes --] [AMD Official Use Only] Parsing over 550 processes for fdinfo is taking between 40-100ms single threaded in a 2GHz skylake IBRS within a VM using simple string comparisons and DIRent parsing. And that is pretty much the worst case scenario with some more optimized implementations. David ________________________________ From: Daniel Vetter <daniel@ffwll.ch> Sent: Wednesday, May 19, 2021 11:23 AM To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: Daniel Stone <daniel@fooishbar.org>; jhubbard@nvidia.com <jhubbard@nvidia.com>; nouveau@lists.freedesktop.org <nouveau@lists.freedesktop.org>; Intel Graphics Development <Intel-gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-devel@lists.freedesktop.org>; Simon Ser <contact@emersion.fr>; Koenig, Christian <Christian.Koenig@amd.com>; aritger@nvidia.com <aritger@nvidia.com>; Nieto, David M <David.Nieto@amd.com> Subject: Re: [Intel-gfx] [PATCH 0/7] Per client engine busyness On Wed, May 19, 2021 at 6:16 PM Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > > > On 18/05/2021 10:40, Tvrtko Ursulin wrote: > > > > On 18/05/2021 10:16, Daniel Stone wrote: > >> Hi, > >> > >> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin > >> <tvrtko.ursulin@linux.intel.com> wrote: > >>> I was just wondering if stat(2) and a chrdev major check would be a > >>> solid criteria to more efficiently (compared to parsing the text > >>> content) detect drm files while walking procfs. > >> > >> Maybe I'm missing something, but is the per-PID walk actually a > >> measurable performance issue rather than just a bit unpleasant? > > > > Per pid and per each open fd. > > > > As said in the other thread what bothers me a bit in this scheme is that > > the cost of obtaining GPU usage scales based on non-GPU criteria. > > > > For use case of a top-like tool which shows all processes this is a > > smaller additional cost, but then for a gpu-top like tool it is somewhat > > higher. > > To further expand, not only cost would scale per pid multiplies per open > fd, but to detect which of the fds are DRM I see these three options: > > 1) Open and parse fdinfo. > 2) Name based matching ie /dev/dri/.. something. > 3) Stat the symlink target and check for DRM major. stat with symlink following should be plenty fast. > All sound quite sub-optimal to me. > > Name based matching is probably the least evil on system resource usage > (Keeping the dentry cache too hot? Too many syscalls?), even though > fundamentally I don't it is the right approach. > > What happens with dup(2) is another question. We need benchmark numbers showing that on anything remotely realistic it's an actual problem. Until we've demonstrated it's a real problem we don't need to solve it. E.g. top with any sorting enabled also parses way more than it displays on every update. It seems to be doing Just Fine (tm). > Does anyone have any feedback on the /proc/<pid>/gpu idea at all? When we know we have a problem to solve we can take a look at solutions. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7CDavid.Nieto%40amd.com%7Cf6aea97532cf41f916de08d91af32cc1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637570453997158377%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4CFrY9qWbJREcIcSzeO9KIn2P%2Fw6k%2BYdNlh6rdS%2BEh4%3D&reserved=0 [-- Attachment #1.2: Type: text/html, Size: 5670 bytes --] [-- Attachment #2: Type: text/plain, Size: 154 bytes --] _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-19 23:17 ` Nieto, David M @ 2021-05-20 14:11 ` Daniel Vetter 2021-05-20 14:12 ` Christian König 0 siblings, 1 reply; 13+ messages in thread From: Daniel Vetter @ 2021-05-20 14:11 UTC (permalink / raw) To: Nieto, David M Cc: Tvrtko Ursulin, Simon Ser, nouveau@lists.freedesktop.org, Intel Graphics Development, Daniel Stone, Maling list - DRI developers, Daniel Vetter, Koenig, Christian On Wed, May 19, 2021 at 11:17:24PM +0000, Nieto, David M wrote: > [AMD Official Use Only] > > Parsing over 550 processes for fdinfo is taking between 40-100ms single > threaded in a 2GHz skylake IBRS within a VM using simple string > comparisons and DIRent parsing. And that is pretty much the worst case > scenario with some more optimized implementations. I think this is plenty ok, and if it's not you could probably make this massively faster with io_uring for all the fs operations and whack a parser-generator on top for real parsing speed. So imo we shouldn't worry about algorithmic inefficiency of the fdinfo approach at all, and focuse more on trying to reasonably (but not too much, this is still drm render stuff after all) standardize how it works and how we'll extend it all. I think there's tons of good suggestions in this thread on this topic already. /me out -Daniel > > David > ________________________________ > From: Daniel Vetter <daniel@ffwll.ch> > Sent: Wednesday, May 19, 2021 11:23 AM > To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> > Cc: Daniel Stone <daniel@fooishbar.org>; jhubbard@nvidia.com <jhubbard@nvidia.com>; nouveau@lists.freedesktop.org <nouveau@lists.freedesktop.org>; Intel Graphics Development <Intel-gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-devel@lists.freedesktop.org>; Simon Ser <contact@emersion.fr>; Koenig, Christian <Christian.Koenig@amd.com>; aritger@nvidia.com <aritger@nvidia.com>; Nieto, David M <David.Nieto@amd.com> > Subject: Re: [Intel-gfx] [PATCH 0/7] Per client engine busyness > > On Wed, May 19, 2021 at 6:16 PM Tvrtko Ursulin > <tvrtko.ursulin@linux.intel.com> wrote: > > > > > > On 18/05/2021 10:40, Tvrtko Ursulin wrote: > > > > > > On 18/05/2021 10:16, Daniel Stone wrote: > > >> Hi, > > >> > > >> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin > > >> <tvrtko.ursulin@linux.intel.com> wrote: > > >>> I was just wondering if stat(2) and a chrdev major check would be a > > >>> solid criteria to more efficiently (compared to parsing the text > > >>> content) detect drm files while walking procfs. > > >> > > >> Maybe I'm missing something, but is the per-PID walk actually a > > >> measurable performance issue rather than just a bit unpleasant? > > > > > > Per pid and per each open fd. > > > > > > As said in the other thread what bothers me a bit in this scheme is that > > > the cost of obtaining GPU usage scales based on non-GPU criteria. > > > > > > For use case of a top-like tool which shows all processes this is a > > > smaller additional cost, but then for a gpu-top like tool it is somewhat > > > higher. > > > > To further expand, not only cost would scale per pid multiplies per open > > fd, but to detect which of the fds are DRM I see these three options: > > > > 1) Open and parse fdinfo. > > 2) Name based matching ie /dev/dri/.. something. > > 3) Stat the symlink target and check for DRM major. > > stat with symlink following should be plenty fast. > > > All sound quite sub-optimal to me. > > > > Name based matching is probably the least evil on system resource usage > > (Keeping the dentry cache too hot? Too many syscalls?), even though > > fundamentally I don't it is the right approach. > > > > What happens with dup(2) is another question. > > We need benchmark numbers showing that on anything remotely realistic > it's an actual problem. Until we've demonstrated it's a real problem > we don't need to solve it. > > E.g. top with any sorting enabled also parses way more than it > displays on every update. It seems to be doing Just Fine (tm). > > > Does anyone have any feedback on the /proc/<pid>/gpu idea at all? > > When we know we have a problem to solve we can take a look at solutions. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7CDavid.Nieto%40amd.com%7Cf6aea97532cf41f916de08d91af32cc1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637570453997158377%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4CFrY9qWbJREcIcSzeO9KIn2P%2Fw6k%2BYdNlh6rdS%2BEh4%3D&reserved=0 -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-20 14:11 ` Daniel Vetter @ 2021-05-20 14:12 ` Christian König 2021-05-20 14:17 ` arabek 0 siblings, 1 reply; 13+ messages in thread From: Christian König @ 2021-05-20 14:12 UTC (permalink / raw) To: Daniel Vetter, Nieto, David M Cc: Tvrtko Ursulin, Simon Ser, nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Daniel Stone Am 20.05.21 um 16:11 schrieb Daniel Vetter: > On Wed, May 19, 2021 at 11:17:24PM +0000, Nieto, David M wrote: >> [AMD Official Use Only] >> >> Parsing over 550 processes for fdinfo is taking between 40-100ms single >> threaded in a 2GHz skylake IBRS within a VM using simple string >> comparisons and DIRent parsing. And that is pretty much the worst case >> scenario with some more optimized implementations. > I think this is plenty ok, and if it's not you could probably make this > massively faster with io_uring for all the fs operations and whack a > parser-generator on top for real parsing speed. Well if it becomes a problem fixing the debugfs "clients" file and making it sysfs shouldn't be much of a problem later on. Christian. > > So imo we shouldn't worry about algorithmic inefficiency of the fdinfo > approach at all, and focuse more on trying to reasonably (but not too > much, this is still drm render stuff after all) standardize how it works > and how we'll extend it all. I think there's tons of good suggestions in > this thread on this topic already. > > /me out > -Daniel > >> David >> ________________________________ >> From: Daniel Vetter <daniel@ffwll.ch> >> Sent: Wednesday, May 19, 2021 11:23 AM >> To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> >> Cc: Daniel Stone <daniel@fooishbar.org>; jhubbard@nvidia.com <jhubbard@nvidia.com>; nouveau@lists.freedesktop.org <nouveau@lists.freedesktop.org>; Intel Graphics Development <Intel-gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-devel@lists.freedesktop.org>; Simon Ser <contact@emersion.fr>; Koenig, Christian <Christian.Koenig@amd.com>; aritger@nvidia.com <aritger@nvidia.com>; Nieto, David M <David.Nieto@amd.com> >> Subject: Re: [Intel-gfx] [PATCH 0/7] Per client engine busyness >> >> On Wed, May 19, 2021 at 6:16 PM Tvrtko Ursulin >> <tvrtko.ursulin@linux.intel.com> wrote: >>> >>> On 18/05/2021 10:40, Tvrtko Ursulin wrote: >>>> On 18/05/2021 10:16, Daniel Stone wrote: >>>>> Hi, >>>>> >>>>> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin >>>>> <tvrtko.ursulin@linux.intel.com> wrote: >>>>>> I was just wondering if stat(2) and a chrdev major check would be a >>>>>> solid criteria to more efficiently (compared to parsing the text >>>>>> content) detect drm files while walking procfs. >>>>> Maybe I'm missing something, but is the per-PID walk actually a >>>>> measurable performance issue rather than just a bit unpleasant? >>>> Per pid and per each open fd. >>>> >>>> As said in the other thread what bothers me a bit in this scheme is that >>>> the cost of obtaining GPU usage scales based on non-GPU criteria. >>>> >>>> For use case of a top-like tool which shows all processes this is a >>>> smaller additional cost, but then for a gpu-top like tool it is somewhat >>>> higher. >>> To further expand, not only cost would scale per pid multiplies per open >>> fd, but to detect which of the fds are DRM I see these three options: >>> >>> 1) Open and parse fdinfo. >>> 2) Name based matching ie /dev/dri/.. something. >>> 3) Stat the symlink target and check for DRM major. >> stat with symlink following should be plenty fast. >> >>> All sound quite sub-optimal to me. >>> >>> Name based matching is probably the least evil on system resource usage >>> (Keeping the dentry cache too hot? Too many syscalls?), even though >>> fundamentally I don't it is the right approach. >>> >>> What happens with dup(2) is another question. >> We need benchmark numbers showing that on anything remotely realistic >> it's an actual problem. Until we've demonstrated it's a real problem >> we don't need to solve it. >> >> E.g. top with any sorting enabled also parses way more than it >> displays on every update. It seems to be doing Just Fine (tm). >> >>> Does anyone have any feedback on the /proc/<pid>/gpu idea at all? >> When we know we have a problem to solve we can take a look at solutions. >> -Daniel >> -- >> Daniel Vetter >> Software Engineer, Intel Corporation >> https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.ffwll.ch%2F&data=04%7C01%7CChristian.Koenig%40amd.com%7Ced2eccaa081d4cd336d408d91b991ee0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637571166744508313%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZihrnanU70nJAM6bHYCjRnURDDCIdwGI85imjGd%2FNgs%3D&reserved=0 _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-20 14:12 ` Christian König @ 2021-05-20 14:17 ` arabek 0 siblings, 0 replies; 13+ messages in thread From: arabek @ 2021-05-20 14:17 UTC (permalink / raw) To: Christian König Cc: Tvrtko Ursulin, nouveau@lists.freedesktop.org, Intel Graphics Development, Maling list - DRI developers, Daniel Stone, Daniel Vetter, Simon Ser, Nieto, David M > Well if it becomes a problem fixing the debugfs "clients" file and > making it sysfs shouldn't be much of a problem later on. Why not to try using something in terms of perf / opensnoop or bpf to do the work. Should be optimal enough. ie. http://www.brendangregg.com/blog/2014-07-25/opensnoop-for-linux.html https://man7.org/linux/man-pages/man2/bpf.2.html _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-19 18:23 ` [Nouveau] [Intel-gfx] " Daniel Vetter 2021-05-19 23:17 ` Nieto, David M @ 2021-05-20 8:35 ` Tvrtko Ursulin 2021-05-24 10:48 ` Tvrtko Ursulin 1 sibling, 1 reply; 13+ messages in thread From: Tvrtko Ursulin @ 2021-05-20 8:35 UTC (permalink / raw) To: Daniel Vetter Cc: Intel Graphics Development, Maling list - DRI developers, Daniel Stone, Simon Ser, nouveau@lists.freedesktop.org, Koenig, Christian, Nieto, David M On 19/05/2021 19:23, Daniel Vetter wrote: > On Wed, May 19, 2021 at 6:16 PM Tvrtko Ursulin > <tvrtko.ursulin@linux.intel.com> wrote: >> >> >> On 18/05/2021 10:40, Tvrtko Ursulin wrote: >>> >>> On 18/05/2021 10:16, Daniel Stone wrote: >>>> Hi, >>>> >>>> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin >>>> <tvrtko.ursulin@linux.intel.com> wrote: >>>>> I was just wondering if stat(2) and a chrdev major check would be a >>>>> solid criteria to more efficiently (compared to parsing the text >>>>> content) detect drm files while walking procfs. >>>> >>>> Maybe I'm missing something, but is the per-PID walk actually a >>>> measurable performance issue rather than just a bit unpleasant? >>> >>> Per pid and per each open fd. >>> >>> As said in the other thread what bothers me a bit in this scheme is that >>> the cost of obtaining GPU usage scales based on non-GPU criteria. >>> >>> For use case of a top-like tool which shows all processes this is a >>> smaller additional cost, but then for a gpu-top like tool it is somewhat >>> higher. >> >> To further expand, not only cost would scale per pid multiplies per open >> fd, but to detect which of the fds are DRM I see these three options: >> >> 1) Open and parse fdinfo. >> 2) Name based matching ie /dev/dri/.. something. >> 3) Stat the symlink target and check for DRM major. > > stat with symlink following should be plenty fast. Maybe. I don't think my point about keeping the dentry cache needlessly hot is getting through at all. On my lightly loaded desktop: $ sudo lsof | wc -l 599551 $ sudo lsof | grep "/dev/dri/" | wc -l 1965 It's going to look up ~600k pointless dentries in every iteration. Just to find a handful of DRM ones. Hard to say if that is better or worse than just parsing fdinfo text for all files. Will see. >> All sound quite sub-optimal to me. >> >> Name based matching is probably the least evil on system resource usage >> (Keeping the dentry cache too hot? Too many syscalls?), even though >> fundamentally I don't it is the right approach. >> >> What happens with dup(2) is another question. > > We need benchmark numbers showing that on anything remotely realistic > it's an actual problem. Until we've demonstrated it's a real problem > we don't need to solve it. Point about dup(2) is whether it is possible to distinguish the duplicated fds in fdinfo. If a DRM client dupes, and we found two fdinfos each saying client is using 20% GPU, we don't want to add it up to 40%. > E.g. top with any sorting enabled also parses way more than it > displays on every update. It seems to be doing Just Fine (tm). Ha, perceptions differ. I see it using 4-5% while building the kernel on a Xeon server which I find quite a lot. :) >> Does anyone have any feedback on the /proc/<pid>/gpu idea at all? > > When we know we have a problem to solve we can take a look at solutions. Yes I don't think the problem would be to add a better solution later, so happy to try the fdinfo first. I am simply pointing out a fundamental design inefficiency. Even if machines are getting faster and faster I don't think that should be an excuse to waste more and more under the hood, when a more efficient solution can be designed from the start. Regards, Tvrtko _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [Intel-gfx] [PATCH 0/7] Per client engine busyness 2021-05-20 8:35 ` Tvrtko Ursulin @ 2021-05-24 10:48 ` Tvrtko Ursulin 0 siblings, 0 replies; 13+ messages in thread From: Tvrtko Ursulin @ 2021-05-24 10:48 UTC (permalink / raw) To: Daniel Vetter Cc: Intel Graphics Development, Maling list - DRI developers, Daniel Stone, Simon Ser, nouveau@lists.freedesktop.org, Koenig, Christian, Nieto, David M On 20/05/2021 09:35, Tvrtko Ursulin wrote: > On 19/05/2021 19:23, Daniel Vetter wrote: >> On Wed, May 19, 2021 at 6:16 PM Tvrtko Ursulin >> <tvrtko.ursulin@linux.intel.com> wrote: >>> >>> >>> On 18/05/2021 10:40, Tvrtko Ursulin wrote: >>>> >>>> On 18/05/2021 10:16, Daniel Stone wrote: >>>>> Hi, >>>>> >>>>> On Tue, 18 May 2021 at 10:09, Tvrtko Ursulin >>>>> <tvrtko.ursulin@linux.intel.com> wrote: >>>>>> I was just wondering if stat(2) and a chrdev major check would be a >>>>>> solid criteria to more efficiently (compared to parsing the text >>>>>> content) detect drm files while walking procfs. >>>>> >>>>> Maybe I'm missing something, but is the per-PID walk actually a >>>>> measurable performance issue rather than just a bit unpleasant? >>>> >>>> Per pid and per each open fd. >>>> >>>> As said in the other thread what bothers me a bit in this scheme is >>>> that >>>> the cost of obtaining GPU usage scales based on non-GPU criteria. >>>> >>>> For use case of a top-like tool which shows all processes this is a >>>> smaller additional cost, but then for a gpu-top like tool it is >>>> somewhat >>>> higher. >>> >>> To further expand, not only cost would scale per pid multiplies per open >>> fd, but to detect which of the fds are DRM I see these three options: >>> >>> 1) Open and parse fdinfo. >>> 2) Name based matching ie /dev/dri/.. something. >>> 3) Stat the symlink target and check for DRM major. >> >> stat with symlink following should be plenty fast. > > Maybe. I don't think my point about keeping the dentry cache needlessly > hot is getting through at all. On my lightly loaded desktop: > > $ sudo lsof | wc -l > 599551 > > $ sudo lsof | grep "/dev/dri/" | wc -l > 1965 > > It's going to look up ~600k pointless dentries in every iteration. Just > to find a handful of DRM ones. Hard to say if that is better or worse > than just parsing fdinfo text for all files. Will see. CPU usage looks passable under a production kernel (non-debug). Once a second refresh period, on a not really that loaded system (115 running processes, 3096 open file descriptors as reported by lsof, none of which are DRM), results in a system call heavy load: real 0m55.348s user 0m0.100s sys 0m0.319s Once per second loop is essentially along the lines of: for each pid in /proc/<pid>: for each fd in /proc/<pid>/fdinfo: if fstatat(fd) is drm major: read fdinfo text in one sweep and parse it I'll post the quick intel_gpu_top patch for reference but string parsing in C leaves a few things to be desired there. Regards, Tvrtko _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-05-24 10:48 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <c6c61179-5b4b-4e0b-6e57-ec4839ca3268@linux.intel.com>
[not found] ` <CADnq5_N03pz6GmptzhRnCRQH=qkd4eWuAbuUysHp-A9NZHQMHg@mail.gmail.com>
[not found] ` <BYAPR12MB2840AA68BCAEBD9279C6184FF4509@BYAPR12MB2840.namprd12.prod.outlook.com>
[not found] ` <39ccc2ef-05d1-d9f0-0639-ea86bef58b80@amd.com>
[not found] ` <7d6d09fe-ec85-6aaf-9834-37a49ec7d6c5@linux.intel.com>
[not found] ` <9144f63b-953d-2019-742d-6553e09f5b40@amd.com>
[not found] ` <22e7d6ea-f2dd-26da-f264-b17aad25af95@linux.intel.com>
[not found] ` <b2203d34-2de3-7c58-de2f-bf6fafc3f67c@amd.com>
[not found] ` <6cf2f14a-6a16-5ea3-d307-004faad4cc79@linux.intel.com>
[not found] ` <a2b03603-eb3e-7bef-a799-c15cfb1a8e0b@amd.com>
[not found] ` <YKJ+F4KqEiQQYkRz@phenom.ffwll.local>
[not found] ` <BYAPR12MB2840C633CF05C1F29263F5BCF42D9@BYAPR12MB2840.namprd12.prod.outlook.com>
[not found] ` <c85fc53f-d25b-464c-d411-eed4a509a009@linux.intel.com>
[not found] ` <BYAPR12MB28409E25DEFD3DD620E596ABF42D9@BYAPR12MB2840.namprd12.prod.outlook.com>
2021-05-17 18:16 ` [Nouveau] [PATCH 0/7] Per client engine busyness Nieto, David M
2021-05-17 19:03 ` Simon Ser
2021-05-18 9:08 ` Tvrtko Ursulin
2021-05-18 9:16 ` Daniel Stone
2021-05-18 9:40 ` Tvrtko Ursulin
2021-05-19 16:16 ` Tvrtko Ursulin
2021-05-19 18:23 ` [Nouveau] [Intel-gfx] " Daniel Vetter
2021-05-19 23:17 ` Nieto, David M
2021-05-20 14:11 ` Daniel Vetter
2021-05-20 14:12 ` Christian König
2021-05-20 14:17 ` arabek
2021-05-20 8:35 ` Tvrtko Ursulin
2021-05-24 10:48 ` Tvrtko Ursulin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox