On 22/01/2021 12:15, Chris Wilson wrote:
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.

Fair enough, I forgot some other bits I wanted to do anyway. :)

Regards,

Tvrtko


_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to