Subject: Re: [RFC/PATCH 0/3] Add support for stop instruction inside KVM guest

From: Gautham R Shenoy <[email-masked]>
Date: Tue, 31 Mar 2020 17:44:47 +0530

On Tue, Mar 31, 2020 at 05:40:55PM +0530, Gautham R. Shenoy wrote:
> From: "Gautham R. Shenoy" <[email-masked]>
> 
> 
>  *** RFC Only. Not intended for inclusion ************
> 
> Motivation
> ~~~~~~~~~~~~~~~
> 
> The POWER ISA v3.0 allows stop instruction to be executed from a Guest
> Kernel (HV=0,PR=0) context. If the hypervisor has cleared
> PSSCR[ESL|EC] bits, then the stop instruction thus executed will cause
> the vCPU thread to "pause", thereby donating its cycles to the other
> threads in the core until the paused thread is woken up by an
> interrupt. If the hypervisor has set the PSSCR[ESL|EC] bits, then
> execution of the "stop" instruction will raise a Hypervisor Facility
> Unavailable exception.
> 
> The stop idle state in the guest (henceforth referred to as stop0lite)
> when enabled
> 
> * has a very small wakeup latency (1-3us) comparable to that of
>   snooze and considerably better compared the Shared CEDE state
>   (25-30us).  Results are provided below for wakeup latency measured
>   by waking up an idle CPU in a given state using a timer as well as
>   using an IPI.
> 
>   ======================================================================
>   Wakeup Latency measured using a timer (in ns) [Lower is better]
>   ======================================================================
>   Idle state |  Nr samples |  Min    | Max    | Median | Avg   | Stddev|
>   ======================================================================
>   snooze     |   60        |  787    | 1059   |  938   | 937.4 | 42.27 |
>   ======================================================================
>   stop0lite  |   60        |  770    | 1182   |  948   | 946.4 | 67.41 |
>   ======================================================================
>   Shared CEDE|   60        | 9550    | 36694  | 29219  |28564.1|3545.9 |
>   ======================================================================
>

Posted two copies of Wakeup latency measured by timer. Here is the
wakeup latency measured using an IPI.

======================================================================
Wakeup latency measured using an IPI (in ns) [Lower is better]
======================================================================
Idle state |  Nr    |  Min    | Max    | Median | Avg     | Stddev   |
           |samples |         |        |        |         |          |
----------------------------------------------------------------------
snooze     |   60   |     2089|    4228|    2259|  2342.31|    316.56|
----------------------------------------------------------------------
stop0lite  |   60   |     1947|    3674|    2653|  2610.57|    266.73|
----------------------------------------------------------------------
Shared CEDE|   60   |    20147|   36305|   21827| 26762.65|   6875.01|
======================================================================

--
Thanks and Regards
gautham.