Skip to content
  • Daniel Henrique Barboza's avatar
    51254ffb
    spapr_drc.c: introduce unplug_timeout_timer · 51254ffb
    Daniel Henrique Barboza authored
    
    
    The LoPAR spec provides no way for the guest kernel to report failure of
    hotplug/hotunplug events. This wouldn't be bad if those operations were
    granted to always succeed, but that's far for the reality.
    
    What ends up happening is that, in the case of a failed hotunplug,
    regardless of whether it was a QEMU error or a guest misbehavior, the
    pSeries machine is retaining the unplug state of the device in the
    running guest.  This state is cleanup in machine reset, where it is
    assumed that this state represents a device that is pending unplug, and
    the device is hotunpluged from the board. Until the reset occurs, any
    hotunplug operation of the same device is forbid because there is a
    pending unplug state.
    
    This behavior has at least one undesirable side effect. A long standing
    pending unplug state is, more often than not, the result of a hotunplug
    error. The user had to dealt with it, since retrying to unplug the
    device is noy allowed, and then in the machine reset we're removing the
    device from the guest. This means that we're failing the user twice -
    failed to hotunplug when asked, then hotunplugged without notice.
    
    Solutions to this problem range between trying to predict when the
    hotunplug will fail and forbid the operation from the QEMU layer, from
    opening up the IRQ queue to allow for multiple hotunplug attempts, from
    telling the users to 'reboot the machine if something goes wrong'. The
    first solution is flawed because we can't fully predict guest behavior
    from QEMU, the second solution is a trial and error remediation that
    counts on a hope that the unplug will eventually succeed, and the third
    is ... well.
    
    This patch introduces a crude, but effective solution to hotunplug
    errors in the pSeries machine. For each unplug done, we'll timeout after
    some time. If a certain amount of time passes, we'll cleanup the
    hotunplug state from the machine.  During the timeout period, any unplug
    operations in the same device will still be blocked. After that, we'll
    assume that the guest failed the operation, and allow the user to try
    again. If the timeout is too short we'll prevent legitimate hotunplug
    situations to occur, so we'll need to overestimate the regular time an
    unplug operation takes to succeed to account that.
    
    The true solution for the hotunplug errors in the pSeries machines is a
    PAPR change to allow for the guest to warn the platform about it. For
    now, the work done in this timeout design can be used for the new PAPR
    'abort hcall' in the future, given that for both cases we'll need code
    to cleanup the existing unplug states of the DRCs.
    
    At this moment we're adding the basic wiring of the timer into the DRC.
    Next patch will use the timer to timeout failed CPU hotunplugs.
    
    Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
    Message-Id: <20210222194531.62717-4-danielhb413@gmail.com>
    Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    51254ffb
    spapr_drc.c: introduce unplug_timeout_timer
    Daniel Henrique Barboza authored
    
    
    The LoPAR spec provides no way for the guest kernel to report failure of
    hotplug/hotunplug events. This wouldn't be bad if those operations were
    granted to always succeed, but that's far for the reality.
    
    What ends up happening is that, in the case of a failed hotunplug,
    regardless of whether it was a QEMU error or a guest misbehavior, the
    pSeries machine is retaining the unplug state of the device in the
    running guest.  This state is cleanup in machine reset, where it is
    assumed that this state represents a device that is pending unplug, and
    the device is hotunpluged from the board. Until the reset occurs, any
    hotunplug operation of the same device is forbid because there is a
    pending unplug state.
    
    This behavior has at least one undesirable side effect. A long standing
    pending unplug state is, more often than not, the result of a hotunplug
    error. The user had to dealt with it, since retrying to unplug the
    device is noy allowed, and then in the machine reset we're removing the
    device from the guest. This means that we're failing the user twice -
    failed to hotunplug when asked, then hotunplugged without notice.
    
    Solutions to this problem range between trying to predict when the
    hotunplug will fail and forbid the operation from the QEMU layer, from
    opening up the IRQ queue to allow for multiple hotunplug attempts, from
    telling the users to 'reboot the machine if something goes wrong'. The
    first solution is flawed because we can't fully predict guest behavior
    from QEMU, the second solution is a trial and error remediation that
    counts on a hope that the unplug will eventually succeed, and the third
    is ... well.
    
    This patch introduces a crude, but effective solution to hotunplug
    errors in the pSeries machine. For each unplug done, we'll timeout after
    some time. If a certain amount of time passes, we'll cleanup the
    hotunplug state from the machine.  During the timeout period, any unplug
    operations in the same device will still be blocked. After that, we'll
    assume that the guest failed the operation, and allow the user to try
    again. If the timeout is too short we'll prevent legitimate hotunplug
    situations to occur, so we'll need to overestimate the regular time an
    unplug operation takes to succeed to account that.
    
    The true solution for the hotunplug errors in the pSeries machines is a
    PAPR change to allow for the guest to warn the platform about it. For
    now, the work done in this timeout design can be used for the new PAPR
    'abort hcall' in the future, given that for both cases we'll need code
    to cleanup the existing unplug states of the DRCs.
    
    At this moment we're adding the basic wiring of the timer into the DRC.
    Next patch will use the timer to timeout failed CPU hotunplugs.
    
    Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
    Message-Id: <20210222194531.62717-4-danielhb413@gmail.com>
    Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Loading