[igt-dev] [PATCH i-g-t v6] intel-gpu-top: Support for client stats
Chris Wilson
chris at chris-wilson.co.uk
Fri Jan 22 12:15:34 UTC 2021
Quoting Tvrtko Ursulin (2021-01-22 11:55:24)
> +static int client_cmp(const void *_a, const void *_b)
> +{
> + const struct client *a = _a;
> + const struct client *b = _b;
> + long tot_a, tot_b;
> +
> + /*
> + * Sort clients in descending order of runtime in the previous sampling
> + * period for active ones, followed by inactive. Tie-breaker is client
> + * id.
> + */
> +
> + tot_a = a->status == ALIVE ? a->total : -1;
> + tot_b = b->status == ALIVE ? b->total : -1;
> +
> + tot_b -= tot_a;
> + if (!tot_b)
> + return (int)b->id - a->id;
> +
> + if (tot_b > 0)
> + return 1;
> + if (tot_b < 0)
> + return -1;
> + return 0;
Nit, this is clearly now
if (tot_b > 0)
return 1;
if (tot_b < 0)
return -1;
return (int)b->id - a->id;
And the decision flow now neatly matches the comment.
-Chris
More information about the igt-dev
mailing list