Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2516479ioo; Mon, 23 May 2022 22:37:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8Zd1KS/9OLPT5CY0b5Rn7XpTu+bDkMoCYgTa5E94WVk9qsdVS7Rw6JYpdN58FPz40/y0w X-Received: by 2002:a17:907:6e01:b0:6fe:fe21:8c56 with SMTP id sd1-20020a1709076e0100b006fefe218c56mr3065983ejc.579.1653370642428; Mon, 23 May 2022 22:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653370642; cv=none; d=google.com; s=arc-20160816; b=schMAApSka9yYX76grH9R/IDPz3333Acg7UmTPHJiVJCr7iK3VWLQexVv2nECCjNwS 9vaeLC28A14pZZx/gfshW5nLgE0YV+vIPQ0bQKQBnO5gK04y85U2slkGzli5VizPvDDk 7x3fUaRNQmF8hDo9LLih7eCjZRl0+IRvCMxR85AYo+PtjGnjRbUeKYZM3xAJ1tXJfNk1 a4OlmwW9Xrq4iJPJ4GAN42f6MDWrfDXSHS4oDfOoj64qSa/bDro0O8sE3RpSQAkFXoaX 2mbRoIomboSlgKauoUi8TNuG176YhYkhE4WGd0JHl+dChBA72nhFLHO7bKPRp/TaaW2K uU/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=BYJFy+Y4pkEYziHYoAeekoD+3Bc8Qu3A80VyOZfUR80=; b=iUcZbRUD5sGRdxHR3obKv/ZsZRwCuANKwFvQUhJjy+XtQddscvG0rTa6wezZKCrh6k +F95qGvnsz5TFsa+twbsxMiWgIRETRENwc87nn3Pf3HOzJV9YIo35pmTLuRPUnUvy+29 bvgf2ojnuKSGVSGhfYLn1Yo2ckk+FICAeK3veq1uj7Guc+iH9Gj/7PiiDzkO0puF+zzE BTXnuNoKiXxjv8LkNkrq3Fhj+4oeaB9SKFQUIOubFAa/Z9wZtah/1rcj8xj+Ejf606AJ aBDJSeFTizMAiuad0ZNPzkOvoIdxAG8AJB+R3TKi9TKwjTrYwM1vF2iHo4UK5BAyWw0y gSzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UYMXCT19; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw19-20020a170907a0d300b006fe95bb93f0si12736053ejc.501.2022.05.23.22.36.56; Mon, 23 May 2022 22:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UYMXCT19; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233430AbiEXCqi (ORCPT + 99 others); Mon, 23 May 2022 22:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233423AbiEXCqY (ORCPT ); Mon, 23 May 2022 22:46:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A4C113F50 for ; Mon, 23 May 2022 19:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653360377; 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=BYJFy+Y4pkEYziHYoAeekoD+3Bc8Qu3A80VyOZfUR80=; b=UYMXCT19ZQ8x8GVGoPilGhgtBXAy+Z1L96OGFj9zadCF3s8wwfpSE4aQc84ZbWeajCpx+y mW9yOY6EsBDptTrnTkZcQFK6msAGeGVlIkIXyRyVOv+B5pWl+k9fVH40m1vdIXz1BGR4ZE NQpkUZ8ctieqXVTbcmbGRU7Lx8lMbfA= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-u-wIa7SZN2qn2hSfp_FZKw-1; Mon, 23 May 2022 22:46:13 -0400 X-MC-Unique: u-wIa7SZN2qn2hSfp_FZKw-1 Received: by mail-pl1-f198.google.com with SMTP id t14-20020a1709028c8e00b0015cf7e541feso8968743plo.1 for ; Mon, 23 May 2022 19:46:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=BYJFy+Y4pkEYziHYoAeekoD+3Bc8Qu3A80VyOZfUR80=; b=GYc+yIrLrZJ8WrmW6b6NtuN75hJSLu9qSgBndGPSd+ofSXZWBRlYz2TbFM80FyAg+5 5qtADzgZjijkNLmU6nKHInhY/8nOHa6BpHe3ch+YhWTC34xvSI6uC0TfZ3+JAVynzv/J 5iv9FZY/ip+Zu0a1krWQNFqG7xvxa2cW1w/EIzKSrObHByHVNiICsHpKRLWmeYsPBpQy Yf05rmW/eUHTWvo0TFUsBSWt4Umx8N3xzi8uwLYD+ajSYJXyUN9hZ8Abi/lMkuL+iXnY ddx1sft0oYom4G3wHMXiowaOsLF1P9qDmTzZNvkoP0YS02RpRhNcwbt3/8NjedZM1A9Z UlOQ== X-Gm-Message-State: AOAM531ELx64QljOPqcS9zb5jbWMrCb+KxBXd2xyFJyHtzWCWqt3Ib2L JnPLrRUsPSI7Ca/tkfNeCUHVXqrt4LUABcgtAvnjnBcMjVBVFVHPbOvwm18RI6lr/cY3mtmH71r 0IcRdnI37ojoNHjxos5ZOObJS X-Received: by 2002:a17:903:246:b0:153:87f0:a93e with SMTP id j6-20020a170903024600b0015387f0a93emr25486839plh.171.1653360372498; Mon, 23 May 2022 19:46:12 -0700 (PDT) X-Received: by 2002:a17:903:246:b0:153:87f0:a93e with SMTP id j6-20020a170903024600b0015387f0a93emr25486789plh.171.1653360372044; Mon, 23 May 2022 19:46:12 -0700 (PDT) Received: from [10.72.12.128] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id l9-20020a17090aaa8900b001cd4989fec6sm417537pjq.18.2022.05.23.19.45.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 May 2022 19:46:08 -0700 (PDT) Message-ID: <333e957d-af84-24fb-6636-843a9dcfc1e2@redhat.com> Date: Tue, 24 May 2022 10:45:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH 1/4] vdpa: Add stop operation Content-Language: en-US To: Si-Wei Liu , Eugenio Perez Martin Cc: virtualization , kvm list , "Michael S. Tsirkin" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefano Garzarella , Longpeng , Zhu Lingshan , Martin Petrus Hubertus Habets , Harpreet Singh Anand , dinang@xilinx.com, Eli Cohen , Laurent Vivier , pabloc@xilinx.com, "Dawar, Gautam" , Xie Yongji , habetsm.xilinx@gmail.com, Christophe JAILLET , tanuj.kamde@amd.com, Wu Zongyong , martinpo@xilinx.com, Cindy Lu , ecree.xilinx@gmail.com, Parav Pandit , Dan Carpenter , Zhang Min References: <20220520172325.980884-1-eperezma@redhat.com> <20220520172325.980884-2-eperezma@redhat.com> <79089dc4-07c4-369b-826c-1c6e12edcaff@oracle.com> <4de97962-cf7e-c334-5874-ba739270c705@oracle.com> <9f68802c-2692-7321-f916-670ee0abfc40@oracle.com> From: Jason Wang In-Reply-To: <9f68802c-2692-7321-f916-670ee0abfc40@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/5/24 08:01, Si-Wei Liu 写道: > > > On 5/23/2022 4:54 PM, Si-Wei Liu wrote: >> >> >> On 5/23/2022 12:20 PM, Eugenio Perez Martin wrote: >>> On Sat, May 21, 2022 at 12:13 PM Si-Wei Liu >>> wrote: >>>> >>>> >>>> On 5/20/2022 10:23 AM, Eugenio Pérez wrote: >>>>> This operation is optional: It it's not implemented, backend >>>>> feature bit >>>>> will not be exposed. >>>>> >>>>> Signed-off-by: Eugenio Pérez >>>>> --- >>>>>    include/linux/vdpa.h | 6 ++++++ >>>>>    1 file changed, 6 insertions(+) >>>>> >>>>> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h >>>>> index 15af802d41c4..ddfebc4e1e01 100644 >>>>> --- a/include/linux/vdpa.h >>>>> +++ b/include/linux/vdpa.h >>>>> @@ -215,6 +215,11 @@ struct vdpa_map_file { >>>>>     * @reset:                  Reset device >>>>>     *                          @vdev: vdpa device >>>>>     *                          Returns integer: success (0) or >>>>> error (< 0) >>>>> + * @stop:                    Stop or resume the device (optional, >>>>> but it must >>>>> + *                           be implemented if require device stop) >>>>> + *                           @vdev: vdpa device >>>>> + *                           @stop: stop (true), not stop (false) >>>>> + *                           Returns integer: success (0) or >>>>> error (< 0) >>>> Is this uAPI meant to address all use cases described in the full >>>> blown >>>> _F_STOP virtio spec proposal, such as: >>>> >>>> --------------%<-------------- >>>> >>>> ...... the device MUST finish any in flight >>>> operations after the driver writes STOP.  Depending on the device, it >>>> can do it >>>> in many ways as long as the driver can recover its normal operation >>>> if it >>>> resumes the device without the need of resetting it: >>>> >>>> - Drain and wait for the completion of all pending requests until a >>>>     convenient avail descriptor. Ignore any other posterior >>>> descriptor. >>>> - Return a device-specific failure for these descriptors, so the >>>> driver >>>>     can choose to retry or to cancel them. >>>> - Mark them as done even if they are not, if the kind of device can >>>>     assume to lose them. >>>> --------------%<-------------- >>>> >>> Right, this is totally underspecified in this series. >>> >>> I'll expand on it in the next version, but that text proposed to >>> virtio-comment was complicated and misleading. I find better to get >>> the previous version description. Would the next description work? >>> >>> ``` >>> After the return of ioctl, the device MUST finish any pending >>> operations like >>> in flight requests. It must also preserve all the necessary state (the >>> virtqueue vring base plus the possible device specific states) >> Hmmm, "possible device specific states" is a bit vague. Does it >> require the device to save any device internal state that is not >> defined in the virtio spec - such as any failed in-flight requests to >> resubmit upon resume? Or you would lean on SVQ to intercept it in >> depth and save it with some other means? I think network device also >> has internal state such as flow steering state that needs bookkeeping >> as well. > Noted that I understand you may introduce additional feature call > similar to VHOST_USER_GET_INFLIGHT_FD for (failed) in-flight request, > but since that's is a get interface, I assume the actual state > preserving should still take place in this STOP call. > Yes, I think so. > -Siwei > >> >> A follow-up question is what is the use of the `stop` argument of >> false, does it require the device to support resume? Yes, this is required by the hypervisor e.g for Qemu it supports vm stop/resume. >> I seem to recall this is something to abandon in favor of device >> reset plus setting queue base/addr after. Or it's just a optional >> feature that may be device specific (if one can do so in simple way). Rest is more like a workarond consider we don't have a stop API. Consider we don't add stop at the beginning, it can only be an optional feature. Thanks >> >> -Siwei >> >>>   that is required >>> for restoring in the future. >>> >>> In the future, we will provide features similar to >>> VHOST_USER_GET_INFLIGHT_FD >>> so the device can save pending operations. >>> ``` >>> >>> Thanks for pointing it out! >>> >>> >>> >>> >>> >>>> E.g. do I assume correctly all in flight requests are flushed after >>>> return from this uAPI call? Or some of pending requests may be subject >>>> to loss or failure? How does the caller/user specify these various >>>> options (if there are) for device stop? >>>> >>>> BTW, it would be nice to add the corresponding support to vdpa_sim_blk >>>> as well to demo the stop handling. To just show it on vdpa-sim-net >>>> IMHO >>>> is perhaps not so convincing. >>>> >>>> -Siwei >>>> >>>>>     * @get_config_size: Get the size of the configuration space >>>>> includes >>>>>     *                          fields that are conditional on >>>>> feature bits. >>>>>     *                          @vdev: vdpa device >>>>> @@ -316,6 +321,7 @@ struct vdpa_config_ops { >>>>>        u8 (*get_status)(struct vdpa_device *vdev); >>>>>        void (*set_status)(struct vdpa_device *vdev, u8 status); >>>>>        int (*reset)(struct vdpa_device *vdev); >>>>> +     int (*stop)(struct vdpa_device *vdev, bool stop); >>>>>        size_t (*get_config_size)(struct vdpa_device *vdev); >>>>>        void (*get_config)(struct vdpa_device *vdev, unsigned int >>>>> offset, >>>>>                           void *buf, unsigned int len); >> >