Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp643310pxb; Wed, 29 Sep 2021 06:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs47uxfshOggySWeakOlW8rAaybVvGlkCNaEU0EoV14MK0WP8DJ5CIqSaCxmWfPzEpwg0T X-Received: by 2002:a17:902:ecd2:b0:13e:17c4:ce08 with SMTP id a18-20020a170902ecd200b0013e17c4ce08mr10434944plh.67.1632923577644; Wed, 29 Sep 2021 06:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632923577; cv=none; d=google.com; s=arc-20160816; b=m65bDJgiX7z0+PsGOrDZUqrHK1YBsu6IGJHcGQ06dk64KfCbYF+DKrwu7cFg2UHPjF gkPPNq3ATfs6VDH8fvOqMwTm4vtZWweTadHW9qlVGt3HrwWC3KBKtiVN0qZEY+pjq4mi +sFBO2nQhXD75EM7tYFrpoTn8pyX9BP01t20sEwf7Zl6CC4CVEnJ165Vd4hB3UTikF/y ljKAVy+QaWdfHhM0C90OZfOAz55yyvHsr2CVgRqvZQjzV3jhYJ+YpSh8y2wxueXu67El p0pP1qe0Oe01Z6FzqGBcbKlFFsYzxmydM8zUmSsZ2FAdClvKlmQx5cJSkott2j2D4/Hr nAmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=FhEYkN6eSJLZP/cV07GjlQRPbO9M+hVC+ywwE/y96y8=; b=GJVN59VEjHcKDy96e7uYLNI3Dwvs4NcbQCEtJpRG9lg7FPEg5LT5aLbaAhMHsU4BAY efeb8YiZlBnh6u8MWLd0WErkq6cnFWuOCfCd/o8lNGMOlwjvKb6Ju7Ks7+vAw7lwOoLt IvTekkZgHtIfTsQIxK8FuzBMICdWMWxGArW6VtlYuvErFUnp/A0gViiUdAk6OhQBFk5S NGoWL669i8M76pLItLi/BWWdq6TrPB9BcJ0Cg687CwkHIIFB5YiG90srJqcesAK3xKfE DhTuQSQ49DDoiZoaAEz5LWZ9bvBs7yRHqw4vMHbpjUllTg4MyvNRvhY/jhVyeH5GQmWj KBjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gl7PIxOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e125si3195034pfe.83.2021.09.29.06.52.43; Wed, 29 Sep 2021 06:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gl7PIxOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344348AbhI2NwF (ORCPT + 99 others); Wed, 29 Sep 2021 09:52:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46562 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344274AbhI2NwF (ORCPT ); Wed, 29 Sep 2021 09:52:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632923423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FhEYkN6eSJLZP/cV07GjlQRPbO9M+hVC+ywwE/y96y8=; b=gl7PIxOHnXveXEhqmHZ/sFQ962stFMlpM+TVhOzsI+RTkQpQWU5twg07D6lcl4aAlZtr0/ puj0zUBNjvHLm2KobPmcvyITiOwYzY9CsimohDTXbBO9LbMJB/cCWAfrbj504xZ/IrEcUS iO3ipYfwt4CicWHo1xTT4fXUjxFCjro= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-8APSx4OKPm2n6vVJUDlzHA-1; Wed, 29 Sep 2021 09:50:22 -0400 X-MC-Unique: 8APSx4OKPm2n6vVJUDlzHA-1 Received: by mail-oi1-f199.google.com with SMTP id b11-20020aca220b000000b0027645eae849so1965995oic.12 for ; Wed, 29 Sep 2021 06:50:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=FhEYkN6eSJLZP/cV07GjlQRPbO9M+hVC+ywwE/y96y8=; b=QzjH3Wa4/OpzAIRwa2KtBT2Ob8yWmlgTXsyDfvlU8PFkGjkwpdGE/f2uo3e6ZWBRXu FGfn1ydfJPEb4F/Jq9BWSU6YxSIv+lAkEU4MjmZG/AHa+9dKkbHg0EtaHC0uDo8bXpsC HAD0Qutgtoa4BpFZBg7VI3nQ593gM4SZaKTayu5K1E/G0vIJECuPIndcJMCzhcAXHjaC aVyoH7nJsnX/Xy2/oEEqdCfYAMSGAbxA314tTXb1Zu8ytlc8egwI5MsCyyE1koKOPmL5 K4rq8wt+qZUuFJti7nbDYgugi9ziCZEB/Go4FjENE1Lu8OthvcqpqnS6e82XkMqx4Dvb EKuA== X-Gm-Message-State: AOAM530E8oB8dNlhdxI9RmkjxHpGXvI4v7JXgidcZNO/luVUY9Jx8PoX TGarq8b9vdgcOyLPOyqe+y1xX1ea0M6eVX0VURqxI5FAx5iqncnRYTj/pYMm+WZfMaaoATfGRZ9 7IjyqaFKvknlNcBjBLk6HVRww X-Received: by 2002:aca:adc5:: with SMTP id w188mr8119140oie.40.1632923421714; Wed, 29 Sep 2021 06:50:21 -0700 (PDT) X-Received: by 2002:aca:adc5:: with SMTP id w188mr8119119oie.40.1632923421462; Wed, 29 Sep 2021 06:50:21 -0700 (PDT) Received: from redhat.com ([198.99.80.109]) by smtp.gmail.com with ESMTPSA id p8sm458585oti.15.2021.09.29.06.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:50:21 -0700 (PDT) Date: Wed, 29 Sep 2021 07:50:19 -0600 From: Alex Williamson To: Max Gurtovoy Cc: Jason Gunthorpe , Leon Romanovsky , "Doug Ledford" , Yishai Hadas , "Bjorn Helgaas" , "David S. Miller" , "Jakub Kicinski" , Kirti Wankhede , , , , , , Saeed Mahameed , Cornelia Huck Subject: Re: [PATCH mlx5-next 2/7] vfio: Add an API to check migration state transition validity Message-ID: <20210929075019.48d07deb.alex.williamson@redhat.com> In-Reply-To: <1eba059c-4743-4675-9f72-1a26b8f3c0f6@nvidia.com> References: <20210927164648.1e2d49ac.alex.williamson@redhat.com> <20210927231239.GE3544071@ziepe.ca> <25c97be6-eb4a-fdc8-3ac1-5628073f0214@nvidia.com> <20210929063551.47590fbb.alex.williamson@redhat.com> <1eba059c-4743-4675-9f72-1a26b8f3c0f6@nvidia.com> Organization: Red Hat X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Sep 2021 16:26:55 +0300 Max Gurtovoy wrote: > On 9/29/2021 3:35 PM, Alex Williamson wrote: > > On Wed, 29 Sep 2021 13:44:10 +0300 > > Max Gurtovoy wrote: > > > >> On 9/28/2021 2:12 AM, Jason Gunthorpe wrote: > >>> On Mon, Sep 27, 2021 at 04:46:48PM -0600, Alex Williamson wrote: > >>>>> + enum { MAX_STATE = VFIO_DEVICE_STATE_RESUMING }; > >>>>> + static const u8 vfio_from_state_table[MAX_STATE + 1][MAX_STATE + 1] = { > >>>>> + [VFIO_DEVICE_STATE_STOP] = { > >>>>> + [VFIO_DEVICE_STATE_RUNNING] = 1, > >>>>> + [VFIO_DEVICE_STATE_RESUMING] = 1, > >>>>> + }, > >>>> Our state transition diagram is pretty weak on reachable transitions > >>>> out of the _STOP state, why do we select only these two as valid? > >>> I have no particular opinion on specific states here, however adding > >>> more states means more stuff for drivers to implement and more risk > >>> driver writers will mess up this uAPI. > >> _STOP == 000b => Device Stopped, not saving or resuming (from UAPI). > >> > >> This is the default initial state and not RUNNING. > >> > >> The user application should move device from STOP => RUNNING or STOP => > >> RESUMING. > >> > >> Maybe we need to extend the comment in the UAPI file. > > > > include/uapi/linux/vfio.h: > > ... > > * +------- _RESUMING > > * |+------ _SAVING > > * ||+----- _RUNNING > > * ||| > > * 000b => Device Stopped, not saving or resuming > > * 001b => Device running, which is the default state > > ^^^^^^^^^^^^^^^^^^^^^^^^^^ > > ... > > * State transitions: > > * > > * _RESUMING _RUNNING Pre-copy Stop-and-copy _STOP > > * (100b) (001b) (011b) (010b) (000b) > > * 0. Running or default state > > * | > > ^^^^^^^^^^^^^ > > ... > > * 0. Default state of VFIO device is _RUNNING when the user application starts. > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > The uAPI is pretty clear here. A default state of _STOP is not > > compatible with existing devices and userspace that does not support > > migration. Thanks, > > Why do you need this state machine for userspace that doesn't support > migration ? For userspace that doesn't support migration, there's one state, _RUNNING. That's what we're trying to be compatible and consistent with. Migration is an extension, not a base requirement. > What is the definition of RUNNING state for a paused VM that is waiting > for incoming migration blob ? A VM supporting migration of the device would move the device to _RESUMING to load the incoming data. If the VM leaves the device in _RUNNING, then it doesn't support migration of the device and it's out of scope how it handles that device state. Existing devices continue running regardless of whether the VM state is paused, it's only devices supporting migration where userspace could optionally have the device run state follow the VM run state. Thanks, Alex