Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp719333pxb; Wed, 29 Sep 2021 08:19:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNvmO+cb2kaBLkXB3dL6Ry3BTk7GGQ1YSYCTy6ThLF30NSuRNH9ksX9BofU3qtfMKCrRDy X-Received: by 2002:adf:fe89:: with SMTP id l9mr538796wrr.0.1632928763636; Wed, 29 Sep 2021 08:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632928763; cv=none; d=google.com; s=arc-20160816; b=H+86BLh6eHDTqmV9E97jvYDS8p32T7ZInT+vI8HembgDhqXDF8AjypOTLht/Csw4vH qAiv3EedE0aDu2yv1K6qLrbvRSgdDBc6gTOQoPcCY35Q6B2SfZto3fV/YNRSeDXB4xmz N7V350bOjReOiZz+mnWd00fy1OA+ezFde3JutD6pJg0vehgIyJJHlAg4FlDL8PaYYfFh Zg0cXQdQaxinP+jaeTXMGwieecxqICAMKBmWTY3ohXnmRMdt/oDgWEeBVv7IuINWvPu3 hpDTYBbqy23X6rS4eYnEMOPDo9YS04blRgI6xGAHZjkrKWgB+PPTHyVknOlwlStqNMHW rBAA== 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=KJdqVhfU2lEDy7K+qwgUFw8t05s+Wh549DqDME5rELw=; b=Quab3ArThleGslQOVZywIxTkqklFZLvoqysezLGw53IfObIlXWfYDayIp9tnN1gyEx uw5msx3OeOzpu40qITLDYD3Ih+U7xVLy2u/SSkjuyflyk6Mmx/9xa1aHQ6La1BuhsFa1 jfBMCCXOgrHb40sBt1UssVLGg0CF7orAArbbZZwnfPqca69RAF1tuktGd0gsJMZw29ml sLq7zHPgkSTJEJnArbvs/xKD57vJHs/Y2LEmybhKI5nGp6uq0EmJ6Lpf92T/j0CPYxzp hT2aqLOtT32TLypOzRcG6MCTeUwmcY+pTEAGNmB+xm1N7PnlsJizCh7iFChTqYRQXc1C CQYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WKjPOmLG; 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 c2si200745edj.159.2021.09.29.08.18.59; Wed, 29 Sep 2021 08:19:23 -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=WKjPOmLG; 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 S1345072AbhI2PS6 (ORCPT + 99 others); Wed, 29 Sep 2021 11:18:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32297 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345012AbhI2PS5 (ORCPT ); Wed, 29 Sep 2021 11:18:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632928635; 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=KJdqVhfU2lEDy7K+qwgUFw8t05s+Wh549DqDME5rELw=; b=WKjPOmLGSVgm2qa3XXYF6dI4j+jzVBgplmrvXfBmwWv2ae7Pv9OiF96KkcFarlSaigDJlX DxF3qFC25ojj9wM+mPXP1/zLS/m71ki94c63bmEPScwQESAOj97yUhCXNbLS3ZYYox9bp0 1ffbASeOrfrmirVfh5Trr+UpanqW6s0= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-Yjoq9YOKPwGvCk_M_OBGTA-1; Wed, 29 Sep 2021 11:17:14 -0400 X-MC-Unique: Yjoq9YOKPwGvCk_M_OBGTA-1 Received: by mail-oi1-f197.google.com with SMTP id m189-20020aca58c6000000b0027381ff1c37so2085652oib.22 for ; Wed, 29 Sep 2021 08:17:14 -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=KJdqVhfU2lEDy7K+qwgUFw8t05s+Wh549DqDME5rELw=; b=cmURdVgEYSHdmYYWiybNPMdq2yZMQcYhgeZtAKMjb/iPq50joOCKsVSkYeHvm6mx2L fGBy+A9g8vcIeQhRdlcpKGtgSIHcTXUgptAyt7Yu6q41fQ4AgHldsiKB5u5YYs6382ap 5gcJLazT00oTwuyloymx6YsmhzuE7OplVvMhD59JygMYK3/gpUTLw6iKljgIKcmoTjLk LC7+pVAWv8capdyXHWPqOW1u1pQenMqlYIxnt1w4ixDxESj5D79GM/iJFsxxn8YdecgA MVodL/pqDwa67qF77Eb2KphIFWdXnIMoG+IkR/UGrBBV6t04wK+Ijt+isSVLylK9j/2d FOYw== X-Gm-Message-State: AOAM533zjd7yNt+reckPfvTtNaHj4Ng5KdNf/K/Sk4772vXv+phXA2uk nE5Wfx/K52nsks8+rEFZVCtroc6+sld0TeJ66AvdlZq1/pYmYAxFh/QiuNYzgn+Uk/Bplir95Cc j162cvbQsnwmBjOu3SDDa17WB X-Received: by 2002:a05:6808:2003:: with SMTP id q3mr358692oiw.173.1632928633975; Wed, 29 Sep 2021 08:17:13 -0700 (PDT) X-Received: by 2002:a05:6808:2003:: with SMTP id q3mr358670oiw.173.1632928633757; Wed, 29 Sep 2021 08:17:13 -0700 (PDT) Received: from redhat.com ([198.99.80.109]) by smtp.gmail.com with ESMTPSA id j4sm2288oia.56.2021.09.29.08.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 08:17:13 -0700 (PDT) Date: Wed, 29 Sep 2021 09:17:12 -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: <20210929091712.6390141c.alex.williamson@redhat.com> In-Reply-To: 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> <20210929075019.48d07deb.alex.williamson@redhat.com> 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 17:36:59 +0300 Max Gurtovoy wrote: > On 9/29/2021 4:50 PM, Alex Williamson wrote: > > 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. > > Userspace without migration doesn't care about this state. > > We left with kernel now. vfio-pci today doesn't support migration, right > ? state is in theory is 0 (STOP). > > This state machine is controlled by the migration SW. The drivers don't > move state implicitly. > > mlx5-vfio-pci support migration and will work fine with non-migration SW > (it will stay with state = 0 unless someone will move it. but nobody > will) exactly like vfio-pci does today. > > So where is the problem ? So you have a device that's actively modifying its internal state, performing I/O, including DMA (thereby dirtying VM memory), all while in the _STOP state? And you don't see this as a problem? There's a major inconsistency if the migration interface is telling us something different than we can actually observe through the behavior of the device. Thanks, Alex