Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp116926pxb; Thu, 7 Apr 2022 00:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbMFK2HTT2tM02FG90CaPexOK6IEpHjEcd/XSkgSDCJTifO7Diss66M6kf/2cHsAPFmAJk X-Received: by 2002:a17:90a:558a:b0:1ca:a819:d2d1 with SMTP id c10-20020a17090a558a00b001caa819d2d1mr14554146pji.126.1649316026925; Thu, 07 Apr 2022 00:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649316026; cv=none; d=google.com; s=arc-20160816; b=a9IjBXLGfxQ63mRdx3qROaWcQaTy7/y/NyKSNZbJMZ7yT3kCcOiS88q+bnGSquoaQg QUhCPXpIUvwWgIqdq/tKGgqDvv+AxinwdWrdK3hsHuEgE4/5nljpyV2FKmp+z05qzvs9 mNw20DpdbfwaylCYxwSIHwJvkj1nOpMjjpIRlN9RP4i1mF9a157BEH4uRFG8VhKtnRro Sw+7D2Con7Irr/qgMCE7oTSXhbPyEI3qh4BcdaWzaZ2/lmJGsrXEjLYLFY+795o35XID 9ak24I1JG5dhpzk4o2wHWPR0MWHcv+VZg+0+OH+JSElimRfh2pRwGl8iQ9Bfhi2RGzVn aceA== 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=BLlHrE4/3Q5dXoiIyxRCC0oUmaF9F+xq6LvaySDB8mM=; b=M48rPvxHVjZtWml4k7Iz+2WyLKEYFHpNSTnN96QS2M/UteV8vgPKbrTzX7ERVfSYiG HDzUwz21N3OblvNSLuf/zXsZQLu9Jd8AZy6YlyMtbjEslviw0ndc8EAa31SWBrB4M4jp e4jGeGjkhSVRFdi9NJrnhb+k8kGgmmJl5NB6mpq890hAibNPbKSnT/oOCoeOM7UaglHS fHLMg0P59m2PryGiURY39eJXxRmWRV0TH6/yq6YAxBW5kSiY6NQ/Ll0CS3vDPaLmKfjm w08y5UvZ45tDqLl7PD0lgPnmn0IAuixRytAUgcTHDJoJ3IfbQbLmP3DuosV66IAo8nBq 6PbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CbRgjWtz; 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 f6-20020a056a0022c600b004fa3a8dffc3si19041740pfj.122.2022.04.07.00.20.14; Thu, 07 Apr 2022 00:20:26 -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=CbRgjWtz; 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 S241055AbiDGG1z (ORCPT + 99 others); Thu, 7 Apr 2022 02:27:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241045AbiDGG1w (ORCPT ); Thu, 7 Apr 2022 02:27:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C6A623140 for ; Wed, 6 Apr 2022 23:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649312751; 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=BLlHrE4/3Q5dXoiIyxRCC0oUmaF9F+xq6LvaySDB8mM=; b=CbRgjWtzmMFEodKY241pi2fUvf6ueaZYQMUabYe8mP8Ln7zovRemtbxfj6IYe7Wqr2Ttit q/Q79Aq+xiQiU2P186yHkGCsQhESraYzq/Wt6OzEjClIUHn3B7+mZp9SQfso9pEIncvaO3 4ViTWSGf3W6tSkXdEQEA/B9StV5f7iA= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-502-Op709g23Nx6MDNr4u66UYw-1; Thu, 07 Apr 2022 02:25:50 -0400 X-MC-Unique: Op709g23Nx6MDNr4u66UYw-1 Received: by mail-pg1-f197.google.com with SMTP id p4-20020a631e44000000b00399598a48c5so2670116pgm.1 for ; Wed, 06 Apr 2022 23:25:50 -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=BLlHrE4/3Q5dXoiIyxRCC0oUmaF9F+xq6LvaySDB8mM=; b=IjKCu5YnGMaSh0TFzWPsvKUV/BzbpIYxV5VuaZteUtlKty15WWFcmAZRBlz9S8lfpN n3lFwv9rrbbBEWSP6cnv8SigV1lKNd5hFe9TbvrqUIHA2KHwfc4SfJXlIccdCypPBEuY da6Cs1AkvuXQ0lWIGiJoWaesFDOCEmsBxkVXaNh8GTa3s7qcZIIA9+fZz5IW3ZQUm8xI +QdOssbvskzPA6xrClZGlWkCBnjxPc8oEsyQjhvf5zG8+XdbuNOXxdVloqdZrq2WpDxc T9hpnJYJzJQoGR5C6DcRcStPv68rclWZuEc79rNNnLLTijSYCJdRd8TqvfYpmSkM9udd uJ3g== X-Gm-Message-State: AOAM532Zv9rBVObe3quaFP/Fz9AReaI4Vr4NAZ/xroUJXEGlFdKs3nYr OuDgoms9NhxyXbVRmnPlV3zB5koUF9tVYELiYrUj7+lyJalETXVY7yXS8q9/VhnaJpyDWJnRMPh 4L7K9CH+lZjWB1c0UpvRTbDoX X-Received: by 2002:a63:150c:0:b0:39c:c255:27c1 with SMTP id v12-20020a63150c000000b0039cc25527c1mr2456712pgl.293.1649312749688; Wed, 06 Apr 2022 23:25:49 -0700 (PDT) X-Received: by 2002:a63:150c:0:b0:39c:c255:27c1 with SMTP id v12-20020a63150c000000b0039cc25527c1mr2456702pgl.293.1649312749437; Wed, 06 Apr 2022 23:25:49 -0700 (PDT) Received: from [10.72.13.105] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id j22-20020a637a56000000b003984be1f515sm17860519pgn.69.2022.04.06.23.25.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Apr 2022 23:25:48 -0700 (PDT) Message-ID: <53831b99-6c63-7ca9-9b95-bc3f8c5e015c@redhat.com> Date: Thu, 7 Apr 2022 14:25:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH V2 3/5] virtio: introduce config op to synchronize vring callbacks Content-Language: en-US To: "Michael S. Tsirkin" Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, maz@kernel.org, tglx@linutronix.de, peterz@infradead.org, sgarzare@redhat.com, "Paul E. McKenney" References: <20220406083538.16274-1-jasowang@redhat.com> <20220406083538.16274-4-jasowang@redhat.com> <20220406075405-mutt-send-email-mst@kernel.org> From: Jason Wang In-Reply-To: <20220406075405-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.7 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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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/4/6 下午7:59, Michael S. Tsirkin 写道: > On Wed, Apr 06, 2022 at 04:35:36PM +0800, Jason Wang wrote: >> This patch introduce > introduces > >> a new > new > >> virtio config ops to vring >> callbacks. Transport specific method is required to call >> synchornize_irq() on the IRQs. For the transport that doesn't provide >> synchronize_vqs(), use synchornize_rcu() as a fallback. >> >> Cc: Thomas Gleixner >> Cc: Peter Zijlstra >> Cc: "Paul E. McKenney" >> Cc: Marc Zyngier >> Signed-off-by: Jason Wang >> --- >> include/linux/virtio_config.h | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h >> index b341dd62aa4d..08b73d9bbff2 100644 >> --- a/include/linux/virtio_config.h >> +++ b/include/linux/virtio_config.h >> @@ -57,6 +57,8 @@ struct virtio_shm_region { >> * include a NULL entry for vqs unused by driver >> * Returns 0 on success or error status >> * @del_vqs: free virtqueues found by find_vqs(). >> + * @synchronize_vqs: synchronize with the virtqueue callbacks. >> + * vdev: the virtio_device > I think I prefer synchronize_callbacks Ok, I will rename it. > >> * @get_features: get the array of feature bits for this device. >> * vdev: the virtio_device >> * Returns the first 64 feature bits (all we currently need). >> @@ -89,6 +91,7 @@ struct virtio_config_ops { >> const char * const names[], const bool *ctx, >> struct irq_affinity *desc); >> void (*del_vqs)(struct virtio_device *); >> + void (*synchronize_vqs)(struct virtio_device *); >> u64 (*get_features)(struct virtio_device *vdev); >> int (*finalize_features)(struct virtio_device *vdev); >> const char *(*bus_name)(struct virtio_device *vdev); >> @@ -217,6 +220,19 @@ int virtio_find_vqs_ctx(struct virtio_device *vdev, unsigned nvqs, >> desc); >> } >> >> +/** >> + * virtio_synchronize_vqs - synchronize with virtqueue callbacks >> + * @vdev: the device >> + */ >> +static inline >> +void virtio_synchronize_vqs(struct virtio_device *dev) >> +{ >> + if (dev->config->synchronize_vqs) >> + dev->config->synchronize_vqs(dev); >> + else >> + synchronize_rcu(); > I am not sure about this fallback and the latency impact. Unless each transport can implement their own synchronization routine, we need something that can do best effort as fallback here. > Maybe synchronize_rcu_expedited is better here. Not sure, it might lead IPIs and according to the Documentation/RCU/checklist.rst: """         The expedited forms of these primitives have the same semantics         as the non-expedited forms, but expediting is both expensive and         (with the exception of synchronize_srcu_expedited()) unfriendly         to real-time workloads.  Use of the expedited primitives should         be restricted to rare configuration-change operations that would         not normally be undertaken while a real-time workload is running.         However, real-time workloads can use rcupdate.rcu_normal kernel         boot parameter to completely disable expedited grace periods,         though this might have performance implications. """ It will be expensive for real time workloads. Thanks > >> +} >> + >> /** >> * virtio_device_ready - enable vq use in probe function >> * @vdev: the device >> -- >> 2.25.1