]> xenbits.xensource.com Git - xen.git/commit
tools/xentop: Fix cpu% sort order
authorLeigh Brown <leigh@solinno.co.uk>
Tue, 21 May 2024 08:25:30 +0000 (10:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 21 May 2024 08:25:30 +0000 (10:25 +0200)
commitf3d20dd31770a70971f4f85521eec1e741d38695
tree3b8791e23218bc15b89db2563c0cecc9d4b94a00
parentdfabab2cd9461ef9d21a708461f35d2ae4b55220
tools/xentop: Fix cpu% sort order

In compare_cpu_pct(), there is a double -> unsigned long long converion when
calling compare().  In C, this discards the fractional part, resulting in an
out-of order sorting such as:

        NAME  STATE   CPU(sec) CPU(%)
       xendd --b---       4020    5.7
    icecream --b---       2600    3.8
    Domain-0 -----r       1060    1.5
        neon --b---        827    1.1
      cheese --b---        225    0.7
       pizza --b---        359    0.5
     cassini --b---        490    0.4
     fusilli --b---        159    0.2
         bob --b---        502    0.2
     blender --b---        121    0.2
       bread --b---         69    0.1
    chickpea --b---         67    0.1
      lentil --b---         67    0.1

Introduce compare_dbl() function and update compare_cpu_pct() to call it.

Fixes: 49839b535b78 ("Add xenstat framework.")
Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: e27fc7d15eab79e604e8b8728778594accc23cf1
master date: 2024-05-15 19:59:52 +0100
tools/xentop/xentop.c