From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28747C433E9 for ; Fri, 5 Mar 2021 07:02:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8D6865009 for ; Fri, 5 Mar 2021 07:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbhCEHB7 (ORCPT ); Fri, 5 Mar 2021 02:01:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39451 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhCEHB5 (ORCPT ); Fri, 5 Mar 2021 02:01:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614927716; 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=HQk/Exv1XbZRWS+o6Mxm1eVPkotVmEcyq/oY4rVGxAw=; b=Iw0qOj7cXI/UJ1kuziWurWrCIuh0oguZuh0MC9OzvEXWF2MpdzzXuOG444HUyiqd/QYVvc 1BI3oG/YaGtIN72h7W8zSS9NT6K2HhK4yhf/p4DwW+CQD4ST2iem99F1IKCD80NlPznQu7 EVr2NaZ07yb2jpXxdDIbphRSg1ZQxAU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-DC6JDHC-OBeLqxZYzHn40A-1; Fri, 05 Mar 2021 02:01:51 -0500 X-MC-Unique: DC6JDHC-OBeLqxZYzHn40A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 472E41937FDE; Fri, 5 Mar 2021 07:01:49 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-12-165.pek2.redhat.com [10.72.12.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FDEB5C1A1; Fri, 5 Mar 2021 07:01:34 +0000 (UTC) Subject: Re: [RFC v4 10/11] vduse: Introduce a workqueue for irq injection To: Yongji Xie Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Bob Liu , Christoph Hellwig , Randy Dunlap , Matthew Wilcox , viro@zeniv.linux.org.uk, Jens Axboe , bcrl@kvack.org, Jonathan Corbet , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org References: <20210223115048.435-1-xieyongji@bytedance.com> <20210223115048.435-11-xieyongji@bytedance.com> <2d3418d9-856c-37ee-7614-af5b721becd7@redhat.com> From: Jason Wang Message-ID: Date: Fri, 5 Mar 2021 15:01:32 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2021/3/5 2:36 下午, Yongji Xie wrote: > On Fri, Mar 5, 2021 at 11:42 AM Jason Wang wrote: >> >> On 2021/3/5 11:30 上午, Yongji Xie wrote: >>> On Fri, Mar 5, 2021 at 11:05 AM Jason Wang wrote: >>>> On 2021/3/4 4:58 下午, Yongji Xie wrote: >>>>> On Thu, Mar 4, 2021 at 2:59 PM Jason Wang wrote: >>>>>> On 2021/2/23 7:50 下午, Xie Yongji wrote: >>>>>>> This patch introduces a workqueue to support injecting >>>>>>> virtqueue's interrupt asynchronously. This is mainly >>>>>>> for performance considerations which makes sure the push() >>>>>>> and pop() for used vring can be asynchronous. >>>>>> Do you have pref numbers for this patch? >>>>>> >>>>> No, I can do some tests for it if needed. >>>>> >>>>> Another problem is the VIRTIO_RING_F_EVENT_IDX feature will be useless >>>>> if we call irq callback in ioctl context. Something like: >>>>> >>>>> virtqueue_push(); >>>>> virtio_notify(); >>>>> ioctl() >>>>> ------------------------------------------------- >>>>> irq_cb() >>>>> virtqueue_get_buf() >>>>> >>>>> The used vring is always empty each time we call virtqueue_push() in >>>>> userspace. Not sure if it is what we expected. >>>> I'm not sure I get the issue. >>>> >>>> THe used ring should be filled by virtqueue_push() which is done by >>>> userspace before? >>>> >>> After userspace call virtqueue_push(), it always call virtio_notify() >>> immediately. In traditional VM (vhost-vdpa) cases, virtio_notify() >>> will inject an irq to VM and return, then vcpu thread will call >>> interrupt handler. But in container (virtio-vdpa) cases, >>> virtio_notify() will call interrupt handler directly. So it looks like >>> we have to optimize the virtio-vdpa cases. But one problem is we don't >>> know whether we are in the VM user case or container user case. >> >> Yes, but I still don't get why used ring is empty after the ioctl()? >> Used ring does not use bounce page so it should be visible to the kernel >> driver. What did I miss :) ? >> > Sorry, I'm not saying the kernel can't see the correct used vring. I > mean the kernel will consume the used vring in the ioctl context > directly in the virtio-vdpa case. In userspace's view, that means > virtqueue_push() is used vring's producer and virtio_notify() is used > vring's consumer. They will be called one by one in one thread rather > than different threads, which looks odd and has a bad effect on > performance. Yes, that's why we need a workqueue (WQ_UNBOUND you used). Or do you want to squash this patch into patch 8? So I think we can see obvious difference when virtio-vdpa is used. Thanks > > Thanks, > Yongji > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93649C433E6 for ; Fri, 5 Mar 2021 07:01:59 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 32D3A64FD2 for ; Fri, 5 Mar 2021 07:01:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32D3A64FD2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E72726F569; Fri, 5 Mar 2021 07:01:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bzhGT3MJXWHf; Fri, 5 Mar 2021 07:01:58 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTP id 765BC6F510; Fri, 5 Mar 2021 07:01:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4CF69C000B; Fri, 5 Mar 2021 07:01:57 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48D1DC0001 for ; Fri, 5 Mar 2021 07:01:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3760C844D5 for ; Fri, 5 Mar 2021 07:01:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9MtMzvYVPzcc for ; Fri, 5 Mar 2021 07:01:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 5F0808442A for ; Fri, 5 Mar 2021 07:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614927714; 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=HQk/Exv1XbZRWS+o6Mxm1eVPkotVmEcyq/oY4rVGxAw=; b=ETa6PSIBga+CH9POgTaljlotUmxFv1sGzJhjOjQBKDhfqdoJBiKYk2oNWLZbH61bSd6AUc HW10rVn0lPMBZWjh4KJKdps2DzP+eROX3Etc73X6xQ11icySaK2JKushrPB7PnSlfaxo7g Ys2RlJBixnQVta4LGVeBJpMA1kL+fSA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-DC6JDHC-OBeLqxZYzHn40A-1; Fri, 05 Mar 2021 02:01:51 -0500 X-MC-Unique: DC6JDHC-OBeLqxZYzHn40A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 472E41937FDE; Fri, 5 Mar 2021 07:01:49 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-12-165.pek2.redhat.com [10.72.12.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FDEB5C1A1; Fri, 5 Mar 2021 07:01:34 +0000 (UTC) Subject: Re: [RFC v4 10/11] vduse: Introduce a workqueue for irq injection To: Yongji Xie References: <20210223115048.435-1-xieyongji@bytedance.com> <20210223115048.435-11-xieyongji@bytedance.com> <2d3418d9-856c-37ee-7614-af5b721becd7@redhat.com> From: Jason Wang Message-ID: Date: Fri, 5 Mar 2021 15:01:32 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Cc: Jens Axboe , Jonathan Corbet , kvm@vger.kernel.org, "Michael S. Tsirkin" , linux-aio@kvack.org, netdev@vger.kernel.org, Randy Dunlap , Matthew Wilcox , virtualization@lists.linux-foundation.org, Christoph Hellwig , Bob Liu , bcrl@kvack.org, viro@zeniv.linux.org.uk, Stefan Hajnoczi , linux-fsdevel@vger.kernel.org X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" Ck9uIDIwMjEvMy81IDI6MzYg5LiL5Y2ILCBZb25namkgWGllIHdyb3RlOgo+IE9uIEZyaSwgTWFy IDUsIDIwMjEgYXQgMTE6NDIgQU0gSmFzb24gV2FuZyA8amFzb3dhbmdAcmVkaGF0LmNvbT4gd3Jv dGU6Cj4+Cj4+IE9uIDIwMjEvMy81IDExOjMwIOS4iuWNiCwgWW9uZ2ppIFhpZSB3cm90ZToKPj4+ IE9uIEZyaSwgTWFyIDUsIDIwMjEgYXQgMTE6MDUgQU0gSmFzb24gV2FuZyA8amFzb3dhbmdAcmVk aGF0LmNvbT4gd3JvdGU6Cj4+Pj4gT24gMjAyMS8zLzQgNDo1OCDkuIvljYgsIFlvbmdqaSBYaWUg d3JvdGU6Cj4+Pj4+IE9uIFRodSwgTWFyIDQsIDIwMjEgYXQgMjo1OSBQTSBKYXNvbiBXYW5nIDxq YXNvd2FuZ0ByZWRoYXQuY29tPiB3cm90ZToKPj4+Pj4+IE9uIDIwMjEvMi8yMyA3OjUwIOS4i+WN iCwgWGllIFlvbmdqaSB3cm90ZToKPj4+Pj4+PiBUaGlzIHBhdGNoIGludHJvZHVjZXMgYSB3b3Jr cXVldWUgdG8gc3VwcG9ydCBpbmplY3RpbmcKPj4+Pj4+PiB2aXJ0cXVldWUncyBpbnRlcnJ1cHQg YXN5bmNocm9ub3VzbHkuIFRoaXMgaXMgbWFpbmx5Cj4+Pj4+Pj4gZm9yIHBlcmZvcm1hbmNlIGNv bnNpZGVyYXRpb25zIHdoaWNoIG1ha2VzIHN1cmUgdGhlIHB1c2goKQo+Pj4+Pj4+IGFuZCBwb3Ao KSBmb3IgdXNlZCB2cmluZyBjYW4gYmUgYXN5bmNocm9ub3VzLgo+Pj4+Pj4gRG8geW91IGhhdmUg cHJlZiBudW1iZXJzIGZvciB0aGlzIHBhdGNoP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