Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5186080pxb; Tue, 28 Sep 2021 12:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytZ7DXPQ0ukNhq1BmvMy/VsA/PYTqvThQcuf72/Ptdl2NdCiYX7IRqRCCLRxX6IS6MOGec X-Received: by 2002:a17:906:a0da:: with SMTP id bh26mr8664467ejb.505.1632857049736; Tue, 28 Sep 2021 12:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632857049; cv=none; d=google.com; s=arc-20160816; b=JJaoSDAAAN/49FyyKItgCxzKq67YzoKDZzLrjrfWgCYjugZjPvogW6u0vqgLpXRvHU J0HkakIW7WsJNBNHjdcpNbUYgFmAgIjV9RchrZuiL10Wqv+ajR6ChY0d7mmtIjCxqfez os/PutOAEjQ8UVa8i/Ms9suzVvtO6Q6XmdM2yuNBVUcqAeVXurBP1xhfjY96ICwOhGXi wCkiS13wMXi16aPE3zEBnRzTqgaQlXGEteBFVG53718krHOlcPwsJULUwOCJG6+LLHqW ORdc+VVhPd8LZKn6VY4gN3LxSHYX3n73BpWtI2KFz33rj4105D3gsMofvwYj22iLHuc+ cB2Q== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Za4UIa1i/i1OBgAuhO+2BMEIFPExsbIEIdBHDtNVqsI=; b=ibbegKhJFxz6M7HYc/9+gh4hoIpMgya5ShIHePl8puWR4u0u6n0q2kz7h8CISh7Xrp gwVuQsz9K32/RAX1o76V1cXoTx6GODgwqQWagY99rSx1KVuVKI7qq4nCcP0V0fWpp4hn 2rS+NiB/VXGRgAZiCFmSUbvRbdUzC+l1k3OLNmNo2Ss8UGI0IGasRkGadXHWtWLMgnTV KY822eZ6w+ScFswMPG89odp3lZKA/EGcO9i3tX8QV4gCuUNQtKV2D1x0mTNS0MC82+PM NKfeFHqRjnAlIppQZPRjLp5yIvAcZ0ynCaAJ6ahW+dNb5okTlWTwP5OxLJQH36+Ai2/y z1gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MuwFUZrQ; 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 e7si28469436edk.440.2021.09.28.12.23.45; Tue, 28 Sep 2021 12:24:09 -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=MuwFUZrQ; 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 S242518AbhI1TVx (ORCPT + 99 others); Tue, 28 Sep 2021 15:21:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44465 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242495AbhI1TVn (ORCPT ); Tue, 28 Sep 2021 15:21:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632856802; 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=Za4UIa1i/i1OBgAuhO+2BMEIFPExsbIEIdBHDtNVqsI=; b=MuwFUZrQJTDIJTf9afKrAoFZP+/MDVnwWTW/DtFTcpsydn1ipe0KcGMDel9Cq7ya1O+zg8 +VnD5/UX2rEkyKiJwbKb3ddtLhkWmI98CvjnOr2cHJvIz4TVLNKWueUk323VyPKoPGFjaP kZmodv0G1tf9OPCJNztA+oAUD2t/Lfk= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-O4tZ-FHRM0655kQlWUZv1g-1; Tue, 28 Sep 2021 15:20:01 -0400 X-MC-Unique: O4tZ-FHRM0655kQlWUZv1g-1 Received: by mail-oo1-f70.google.com with SMTP id 68-20020a4a0d47000000b0028fe7302d04so25258676oob.8 for ; Tue, 28 Sep 2021 12:20:01 -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:mime-version:content-transfer-encoding; bh=Za4UIa1i/i1OBgAuhO+2BMEIFPExsbIEIdBHDtNVqsI=; b=lUhKs/iIqjcAsSYNHO7pXiNSDDq3sKozJhBWC1cX2iQ1+3OY+gvIO/OeqeaHC9Ud65 5Kkl+YPrSf48jIzIDs/IZccdfWvWUNNMq2cZBu9KUTiX/bOujmuQbjB9mkjQRwhZSEjY nP9YgMvoMZovJKU5bsnShVKDPP/ANNQVkEkFNiUkPjd2017LJv+Ytg2IleUdL+vM3RKU 0gKoiah/sWZRuWKuH+rNWpiVP09nVpAc8Kqq7OqSGr8CDn72g7Zxol53Zx+Udz9syYuj tcu2Dk1+PpB2VrShJqUTz7tD8VXl1yDYPyyHeLE7BtdIJ7r2ebXNax7sGX2Z/lbn3wu+ tihA== X-Gm-Message-State: AOAM533dIVtYu+PC0INwgQRpyIeTeDv9CPSVJ1Wi0z3X3m+FiCxAiXGe jN23hzLNjvjGhwQU3F3jHy7c1ccHo5PLe2/93WDOb5ryymLBAKhcKJr/JlKB7+Wlr9E29qe5vr7 MZKh77ZskveBNcO+TKctPZ5/y X-Received: by 2002:a54:410b:: with SMTP id l11mr4950313oic.74.1632856800916; Tue, 28 Sep 2021 12:20:00 -0700 (PDT) X-Received: by 2002:a54:410b:: with SMTP id l11mr4950299oic.74.1632856800685; Tue, 28 Sep 2021 12:20:00 -0700 (PDT) Received: from redhat.com ([198.99.80.109]) by smtp.gmail.com with ESMTPSA id u15sm5269230oon.35.2021.09.28.12.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 12:20:00 -0700 (PDT) Date: Tue, 28 Sep 2021 13:19:58 -0600 From: Alex Williamson To: Jason Gunthorpe Cc: Leon Romanovsky , Doug Ledford , Yishai Hadas , Bjorn Helgaas , "David S. Miller" , Jakub Kicinski , Kirti Wankhede , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Saeed Mahameed , Cornelia Huck Subject: Re: [PATCH mlx5-next 2/7] vfio: Add an API to check migration state transition validity Message-ID: <20210928131958.61b3abec.alex.williamson@redhat.com> In-Reply-To: <20210927231239.GE3544071@ziepe.ca> References: <20210927164648.1e2d49ac.alex.williamson@redhat.com> <20210927231239.GE3544071@ziepe.ca> 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 Mon, 27 Sep 2021 20:12:39 -0300 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. It looks like state transitions were largely discussed in v9 and v10 of the migration proposals: https://lore.kernel.org/all/1573578220-7530-2-git-send-email-kwankhede@nvidia.com/ https://lore.kernel.org/all/1576527700-21805-2-git-send-email-kwankhede@nvidia.com/ I'm not seeing that we really excluded many transitions there. > So only on those grounds I'd suggest to keep this to the minimum > needed instead of the maximum logically possible.. > > Also, probably the FSM comment from the uapi header file should be > moved into a function comment above this function? It's not clear this function shouldn't be anything more than: if (new_state > MAX_STATE || old_state > MAX_STATE) return false; /* exited via device reset, */ /* entered via transition fault */ return true; That's still only 5 fully interconnected states to work between, and potentially a 6th if we decide _RESUMING|_RUNNING is valid for a device supporting post-copy. In defining the device state, we tried to steer away from defining it in terms of the QEMU migration API, but rather as a set of controls that could be used to support that API to leave us some degree of independence that QEMU implementation might evolve. To that extent, it actually seems easier for a device implementation to focus on bit definition rather than the state machine node. I'd also vote that any clarification of state validity and transitions belongs in the uAPI header and a transition test function should reference that header as the source of truth, rather than the other way around. Thanks, Alex