Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3195803rwb; Sun, 9 Oct 2022 00:12:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CI8SGt18vwksRCfiqAWmwIUg1f7sv0QlePUzw890e6eQGg8PUjZIk+TCWqD86v3esh0KP X-Received: by 2002:a50:cc07:0:b0:453:4427:a918 with SMTP id m7-20020a50cc07000000b004534427a918mr12110939edi.121.1665299537940; Sun, 09 Oct 2022 00:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665299537; cv=none; d=google.com; s=arc-20160816; b=Prw8V1tjQuRYmJhlq+OFEqcYzGFllQhMqDfIa+m64tAgBDg4u2fh7BIFsZ6eBXgWIG 0QuyL6oqY8WrRKPHDnUz/8LdccdJKi9Z0JXUWRzFuwjX2YGIjG0FmbP/4Pn+ngWRP084 OLqEPjtrUOoEn2kdmLTbqTabSl043OcPr251h6A1BY1EYMa2vxJb7VUu2lssy4itss2J 7739dJjqY/iTRxrs5ErQnSE5hd2U3hwX+j5nzL05mNE2iKRLRPYDt8+7wOAF6dwjCI72 lbArnBKGw0Vy/8NMFjuryLaf1q4l+gk0I39EabxcqsvIk36To7z27KGtEWzOjkfVMRGI BWUg== 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=XyL4XgZY3fE78rf1t1J98tuq3HEa3BcmqHdSW/YDE7Y=; b=nCTZQm4CUnxbrA3VLHR0k08MCb07osgZK4/4iYT7uXL2H8zZ/wtyZYjkHA74juXl5r c6aRElytkpLQZW8Vh3VL8i7B6B7jKxckkAZpkTDrQolMAyyRXBhnJXEpDZzg+C0ZgLSM /cCNtKB3xAGFuwl7TISebiQCEFZ81dicnev02uSHqEQ5jQ2JNBzRKh9zNnkv3lKP7Z7Z CV8jkyS941WCL421TQRQRESJ3YsvR1829ClnHx7kUC6E2NT3+y1vtS89fsem0tERpjQ4 lfv4FgEBlT7N+jpDg53UNxuOgUYbkx+HT5JpfRFdxQcdQxsOn7WwgA5bdLsxOyZSXQPR HaGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZtFMWHBW; 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 ne35-20020a1709077ba300b00780e022dfb8si7892039ejc.494.2022.10.09.00.11.52; Sun, 09 Oct 2022 00:12:17 -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=ZtFMWHBW; 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 S229874AbiJIF7J (ORCPT + 99 others); Sun, 9 Oct 2022 01:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiJIF7H (ORCPT ); Sun, 9 Oct 2022 01:59:07 -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 ESMTPS id 6FD6E2F3A3 for ; Sat, 8 Oct 2022 22:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665295145; 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=XyL4XgZY3fE78rf1t1J98tuq3HEa3BcmqHdSW/YDE7Y=; b=ZtFMWHBWnqNjqog3k0z9BaBsNKKC3WYYHQb1YiMSR0xyKpre1F8JIUNjAhx9/UiTSlbthU jC73DhZBJuXwTMYX9pOkiCH9HvUiUXd4nyk7H4cpT+G5stYUsnndFP5hbxnnJoYIFjC4C8 hIShn3T2qLGnQtequZyR5FpzSSIORqE= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-354-lTxyy_FNPMm1D-zJJP44zQ-1; Sun, 09 Oct 2022 01:59:03 -0400 X-MC-Unique: lTxyy_FNPMm1D-zJJP44zQ-1 Received: by mail-pj1-f70.google.com with SMTP id a20-20020a17090acb9400b0020aff595f9eso4010669pju.5 for ; Sat, 08 Oct 2022 22:59:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XyL4XgZY3fE78rf1t1J98tuq3HEa3BcmqHdSW/YDE7Y=; b=4QstIahGDQkjZmhr2n4s1S6TK17ClT1pSlzVWB+ZE3TDTmPJqhZ8F05NxFYcMIgQ3+ fODYxLpjPZM0Bu6j8wGFpy6Z2X6a/7uFHBFNMSZYSckkXY1cIc3WqTvTs/qGrwRMMtPc 1ehn+hzmQHyw11l3xRPtm3mTNxcTKySfOoWjLw7wkz/TZqJSPQspYyYcg7O5QrZ90Kyc LeFvd/j4/BBP9OZC5v9ELO0/mM9DBQ9b+E2YtGw/tDhvBLBbeOLjjshrn7Sxx5WJxjgU 7ZLiZGW41I7BBYCy0Mn4I4ztwGTnkt+YyDiRwKwxPOMrPuP4gAHsoyHx4b1JzaONjgI/ EtYw== X-Gm-Message-State: ACrzQf0+IFpkIeDFclns183nmprNS0bPHUNCX4EeF63XykLisk8fFWcc xvU+8EiuVwi4ZgEoaiUmhnQuwbC3h/aY0srMXf0EUsj0pG5kxTFgqJQxTXoKcQIh7sxe9OE16j6 loH4BX8K60p2VWvyP6umQisUh X-Received: by 2002:a17:90a:1347:b0:20b:ffd:66b9 with SMTP id y7-20020a17090a134700b0020b0ffd66b9mr16351258pjf.15.1665295142929; Sat, 08 Oct 2022 22:59:02 -0700 (PDT) X-Received: by 2002:a17:90a:1347:b0:20b:ffd:66b9 with SMTP id y7-20020a17090a134700b0020b0ffd66b9mr16351239pjf.15.1665295142628; Sat, 08 Oct 2022 22:59:02 -0700 (PDT) Received: from [10.72.12.61] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 67-20020a620446000000b0054ee4b632dasm4350688pfe.169.2022.10.08.22.58.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Oct 2022 22:59:02 -0700 (PDT) Message-ID: Date: Sun, 9 Oct 2022 13:58:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH net] virtio-net: add cond_resched() to the command waiting loop Content-Language: en-US To: "Michael S. Tsirkin" , Jakub Kicinski Cc: Paolo Abeni , netdev , linux-kernel , virtualization , Eric Dumazet , Gautam Dawar , davem References: <20220905045341.66191-1-jasowang@redhat.com> <20220905031405-mutt-send-email-mst@kernel.org> <056ba905a2579903a372258383afdf6579767ad0.camel@redhat.com> <20220907034407-mutt-send-email-mst@kernel.org> <20220908011858-mutt-send-email-mst@kernel.org> From: Jason Wang In-Reply-To: <20220908011858-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_NONE,SPF_HELO_NONE,SPF_NONE 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/9/8 13:19, Michael S. Tsirkin 写道: > On Thu, Sep 08, 2022 at 10:21:45AM +0800, Jason Wang wrote: >> 在 2022/9/7 15:46, Michael S. Tsirkin 写道: >>> On Wed, Sep 07, 2022 at 09:07:20AM +0200, Paolo Abeni wrote: >>>> On Wed, 2022-09-07 at 10:09 +0800, Jason Wang wrote: >>>>> On Tue, Sep 6, 2022 at 6:56 PM Paolo Abeni wrote: >>>>>> On Mon, 2022-09-05 at 15:49 +0800, Jason Wang wrote: >>>>>>> On Mon, Sep 5, 2022 at 3:15 PM Michael S. Tsirkin wrote: >>>>>>>> On Mon, Sep 05, 2022 at 12:53:41PM +0800, Jason Wang wrote: >>>>>>>>> Adding cond_resched() to the command waiting loop for a better >>>>>>>>> co-operation with the scheduler. This allows to give CPU a breath to >>>>>>>>> run other task(workqueue) instead of busy looping when preemption is >>>>>>>>> not allowed. >>>>>>>>> >>>>>>>>> What's more important. This is a must for some vDPA parent to work >>>>>>>>> since control virtqueue is emulated via a workqueue for those parents. >>>>>>>>> >>>>>>>>> Fixes: bda324fd037a ("vdpasim: control virtqueue support") >>>>>>>> That's a weird commit to fix. so it fixes the simulator? >>>>>>> Yes, since the simulator is using a workqueue to handle control virtueue. >>>>>> Uhmm... touching a driver for a simulator's sake looks a little weird. >>>>> Simulator is not the only one that is using a workqueue (but should be >>>>> the first). >>>>> >>>>> I can see that the mlx5 vDPA driver is using a workqueue as well (see >>>>> mlx5_vdpa_kick_vq()). >>>>> >>>>> And in the case of VDUSE, it needs to wait for the response from the >>>>> userspace, this means cond_resched() is probably a must for the case >>>>> like UP. >>>>> >>>>>> Additionally, if the bug is vdpasim, I think it's better to try to >>>>>> solve it there, if possible. >>>>>> >>>>>> Looking at vdpasim_net_work() and vdpasim_blk_work() it looks like >>>>>> neither needs a process context, so perhaps you could rework it to run >>>>>> the work_fn() directly from vdpasim_kick_vq(), at least for the control >>>>>> virtqueue? >>>>> It's possible (but require some rework on the simulator core). But >>>>> considering we have other similar use cases, it looks better to solve >>>>> it in the virtio-net driver. >>>> I see. >>>> >>>>> Additionally, this may have better behaviour when using for the buggy >>>>> hardware (e.g the control virtqueue takes too long to respond). We may >>>>> consider switching to use interrupt/sleep in the future (but not >>>>> suitable for -net). >>>> Agreed. Possibly a timeout could be useful, too. >>>> >>>> Cheers, >>>> >>>> Paolo >>> Hmm timeouts are kind of arbitrary. >>> regular drivers basically derive them from hardware >>> behaviour but with a generic driver like virtio it's harder. >>> I guess we could add timeout as a config field, have >>> device make a promise to the driver. >>> >>> Making the wait interruptible seems more reasonable. >> >> Yes, but I think we still need this patch for -net and -stable. >> >> Thanks > I was referring to Paolo's idea of having a timeout. Ok, I think we're fine with this patch. Any chance to merge this or do I need to resend? Thanks >