diff mbox series

[i-g-t] intel_gpu_top: Hide unused clients

Message ID 20210131031153.3399123-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [i-g-t] intel_gpu_top: Hide unused clients | expand

Commit Message

Chris Wilson Jan. 31, 2021, 3:11 a.m. UTC
Keep new clients hidden until they utilise the GPU.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
---
 tools/intel_gpu_top.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Tvrtko Ursulin Feb. 1, 2021, 8:14 a.m. UTC | #1
On 31/01/2021 03:11, Chris Wilson wrote:
> Keep new clients hidden until they utilise the GPU.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> ---
>   tools/intel_gpu_top.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 60ff62d28..66a8effa6 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -828,8 +828,11 @@ static void update_client(struct client *c, unsigned int pid, char *name)
>   		c->last[i] = val[i];
>   	}
>   
> -	c->samples++;
> +	if (!c->total_runtime)
> +		return;
> +
>   	c->status = ALIVE;
> +	c->samples++;
>   }
>   
>   static void
> 

Not sure we need to do it at this level and not instead at presentation 
time. Plus, in default sort mode they would be at the end of the list, 
so behind the more active clients. Or you go into sort by id and they 
annoy you there?

Regards,

Tvrtko
Chris Wilson Feb. 1, 2021, 8:21 a.m. UTC | #2
Quoting Tvrtko Ursulin (2021-02-01 08:14:45)
> 
> On 31/01/2021 03:11, Chris Wilson wrote:
> > Keep new clients hidden until they utilise the GPU.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > ---
> >   tools/intel_gpu_top.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> > index 60ff62d28..66a8effa6 100644
> > --- a/tools/intel_gpu_top.c
> > +++ b/tools/intel_gpu_top.c
> > @@ -828,8 +828,11 @@ static void update_client(struct client *c, unsigned int pid, char *name)
> >               c->last[i] = val[i];
> >       }
> >   
> > -     c->samples++;
> > +     if (!c->total_runtime)
> > +             return;
> > +
> >       c->status = ALIVE;
> > +     c->samples++;
> >   }
> >   
> >   static void
> > 
> 
> Not sure we need to do it at this level and not instead at presentation 
> time.

My goal was just presentation :(

> Plus, in default sort mode they would be at the end of the list, 
> so behind the more active clients. Or you go into sort by id and they 
> annoy you there?

No. I had a bunch of "Xorg" when launching steam which never became
anything. So I guess just a bunch of dlopen("libgl") spawing a bunch of
clients that we never used for anything more than gl[X]GetString, but
leaked the fd.

[Why does steam need 10% of the gpu to update an icon on the toolbar
which is hidden while minimised? Why do games sit in static menus at
100% gpu? Why?]
-Chris
Tvrtko Ursulin Feb. 1, 2021, 8:36 a.m. UTC | #3
On 01/02/2021 08:21, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2021-02-01 08:14:45)
>>
>> On 31/01/2021 03:11, Chris Wilson wrote:
>>> Keep new clients hidden until they utilise the GPU.
>>>
>>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>>> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
>>> ---
>>>    tools/intel_gpu_top.c | 5 ++++-
>>>    1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
>>> index 60ff62d28..66a8effa6 100644
>>> --- a/tools/intel_gpu_top.c
>>> +++ b/tools/intel_gpu_top.c
>>> @@ -828,8 +828,11 @@ static void update_client(struct client *c, unsigned int pid, char *name)
>>>                c->last[i] = val[i];
>>>        }
>>>    
>>> -     c->samples++;
>>> +     if (!c->total_runtime)
>>> +             return;
>>> +
>>>        c->status = ALIVE;
>>> +     c->samples++;
>>>    }
>>>    
>>>    static void
>>>
>>
>> Not sure we need to do it at this level and not instead at presentation
>> time.
> 
> My goal was just presentation :(

Something like this would be presentation time:

diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 60ff62d28e5d..f7c5cc3bf19f 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -1942,6 +1942,9 @@ print_client(struct client *c, struct engines 
*engines, double t, int lines,
         unsigned int i;

         if (output_mode == INTERACTIVE) {
+               if (!c->total_runtime) /* make a key toggle? */
+                       return;
+
                 lines++;

                 printf("%6u %17s ", c->pid, c->print_name);

But it worries me a bit to do it by default.

> 
>> Plus, in default sort mode they would be at the end of the list,
>> so behind the more active clients. Or you go into sort by id and they
>> annoy you there?
> 
> No. I had a bunch of "Xorg" when launching steam which never became
> anything. So I guess just a bunch of dlopen("libgl") spawing a bunch of
> clients that we never used for anything more than gl[X]GetString, but
> leaked the fd.

But they were at the end, so potentially even cut of if enough 
interesting clients? Or you actually sorted by id? Or something else is 
broken?

> 
> [Why does steam need 10% of the gpu to update an icon on the toolbar
> which is hidden while minimised? Why do games sit in static menus at
> 100% gpu? Why?]

Yep, I have this issue with animated KDE tray icons. :I

Regards,

Tvrtko
Chris Wilson Feb. 1, 2021, 8:49 a.m. UTC | #4
Quoting Tvrtko Ursulin (2021-02-01 08:36:04)
> 
> On 01/02/2021 08:21, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2021-02-01 08:14:45)
> >>
> >> On 31/01/2021 03:11, Chris Wilson wrote:
> >>> Keep new clients hidden until they utilise the GPU.
> >>>
> >>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> >>> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> >>> ---
> >>>    tools/intel_gpu_top.c | 5 ++++-
> >>>    1 file changed, 4 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> >>> index 60ff62d28..66a8effa6 100644
> >>> --- a/tools/intel_gpu_top.c
> >>> +++ b/tools/intel_gpu_top.c
> >>> @@ -828,8 +828,11 @@ static void update_client(struct client *c, unsigned int pid, char *name)
> >>>                c->last[i] = val[i];
> >>>        }
> >>>    
> >>> -     c->samples++;
> >>> +     if (!c->total_runtime)
> >>> +             return;
> >>> +
> >>>        c->status = ALIVE;
> >>> +     c->samples++;
> >>>    }
> >>>    
> >>>    static void
> >>>
> >>
> >> Not sure we need to do it at this level and not instead at presentation
> >> time.
> > 
> > My goal was just presentation :(
> 
> Something like this would be presentation time:
> 
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 60ff62d28e5d..f7c5cc3bf19f 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -1942,6 +1942,9 @@ print_client(struct client *c, struct engines 
> *engines, double t, int lines,
>          unsigned int i;
> 
>          if (output_mode == INTERACTIVE) {
> +               if (!c->total_runtime) /* make a key toggle? */
> +                       return;
> +
>                  lines++;
> 
>                  printf("%6u %17s ", c->pid, c->print_name);
> 
> But it worries me a bit to do it by default.

I was about to argue then remembered top behaves the same (although a
process cannot exist without consuming at least some CPU resources,
whereas a client can never touch the GPU or allocate GPU memory).

But if we are borrow ideas for filtering the view from top... :)

For top, it's 'i' and there's o%CPU>x

> >> Plus, in default sort mode they would be at the end of the list,
> >> so behind the more active clients. Or you go into sort by id and they
> >> annoy you there?
> > 
> > No. I had a bunch of "Xorg" when launching steam which never became
> > anything. So I guess just a bunch of dlopen("libgl") spawing a bunch of
> > clients that we never used for anything more than gl[X]GetString, but
> > leaked the fd.
> 
> But they were at the end, so potentially even cut of if enough 
> interesting clients? Or you actually sorted by id? Or something else is 
> broken?

But they were there! Unwanted DRI3 fd, abandoned, left homeless before
being used. Even if they are used, there's still a window where we would
see "Xorg" become "realname" (granted there's still a window as we
sample pidname before totalruntime), it irks me.
-Chris
diff mbox series

Patch

diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 60ff62d28..66a8effa6 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -828,8 +828,11 @@  static void update_client(struct client *c, unsigned int pid, char *name)
 		c->last[i] = val[i];
 	}
 
-	c->samples++;
+	if (!c->total_runtime)
+		return;
+
 	c->status = ALIVE;
+	c->samples++;
 }
 
 static void