]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commit
tools/xentop: Fix cpu% sort order
authorLeigh Brown <leigh@solinno.co.uk>
Tue, 14 May 2024 08:13:44 +0000 (09:13 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 15 May 2024 18:59:52 +0000 (19:59 +0100)
commite27fc7d15eab79e604e8b8728778594accc23cf1
tree55aa2f633041e4c35a15b51ab8d04258e75b70a3
parent9b7d793889438ecb5fc6e48fa973c244f9832248
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>
tools/xentop/xentop.c