Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp167955rwn; Wed, 7 Sep 2022 22:43:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR6b2xAfqfyAERvX5ZtbIg2GpPKUPxyE4U7MYVoNovMqu2lRaLqFTxG5t27gYGSTOn9QcrXK X-Received: by 2002:a17:906:9bf6:b0:76f:55a3:9579 with SMTP id de54-20020a1709069bf600b0076f55a39579mr4891865ejc.222.1662615834439; Wed, 07 Sep 2022 22:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662615834; cv=none; d=google.com; s=arc-20160816; b=X/azU9QFeMGa01a7KxkUf+JpFXWvLMbG7aTFKjamG3R3oWssrhgCCDQEHp60NNo4cp IVukFlHQUkU3EG8egAo9JQUzwLMzGhStJtIe8HC9EHyPNKIrQE5GNn4Jt9Db3IgZLx1Z Yu62RzEALvex5wfNjBeEbJNLUYO2GmFJCh7T2SACC25Hwh36HiJNd7jIKKoxGH/sPqmk nq8w6A5sy/cUedUbBxiVAznqPI6PIToXpR3rL6bBjGI2fBUtJoUgCeW5xOXhLNHrz9xf j6jlB3RdAwYYeRm2qS/QBHVHK3PcTjPNc1PCRqbLcGG5mNtd5S2vT1ZS6F8wtl4Gclpu 8nXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=B1eDsyH0NCED46aCkehmhrnDxVmlGdOirQ4ogyDejUk=; b=wRokHRmF0cTArDEkhCFDWMZ3xe1Y7Vwl1rOZe2maPXb/6Y5D4i4iaqjyVUitU9jj0e IsitXWcQCz2qOWci24uyZf9JenZjc/eGDUs92c4bNDll1bIKW3+j36+fYsPfZvKgHwtU dVSuUVWwoN1gEZUq9T0cBT5qcPPhRBls6jtMcDemYFUVYx5LbFj4mj6FRIlHYZ7dH9xy c1pY8pA4R0dWcrNwulXezFsP89tagAe0rfgg5UneFbglLJvo/ueUf2m1ea1JTKdgu+wy VCbC47GwbqgHG7okoRhtSQuV/YkrsK+ZEHwU1sRsja9i+YkrD8YaabgrORxh/jBqIoyn JLKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fDnsrOHQ; 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 n3-20020a1709065e0300b0073d6590a430si1090303eju.382.2022.09.07.22.43.29; Wed, 07 Sep 2022 22:43:54 -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=fDnsrOHQ; 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 S229866AbiIHFTf (ORCPT + 99 others); Thu, 8 Sep 2022 01:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbiIHFTb (ORCPT ); Thu, 8 Sep 2022 01:19:31 -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 ESMTPS id 56FA16437 for ; Wed, 7 Sep 2022 22:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662614368; 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=B1eDsyH0NCED46aCkehmhrnDxVmlGdOirQ4ogyDejUk=; b=fDnsrOHQxdFuZMm90vLxW+L2256a2SGdsONildFxUkvS8r/5SXatzGAT2rw0iZeUbGlb2M JV3Jx7GGw8/Nn0VOG4/63qYCZWakCO3h4rHxS0sQ6qCta5YjzA5JXlmpYjGOIYIa5ICBjx rOODsMgED2uLqzhGcqKBc4cv+aqdQHk= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-433-fdLznIvYMWmgacb5ig_X7w-1; Thu, 08 Sep 2022 01:19:27 -0400 X-MC-Unique: fdLznIvYMWmgacb5ig_X7w-1 Received: by mail-qk1-f200.google.com with SMTP id h20-20020a05620a245400b006bb0c6074baso13628475qkn.6 for ; Wed, 07 Sep 2022 22:19:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=B1eDsyH0NCED46aCkehmhrnDxVmlGdOirQ4ogyDejUk=; b=K83nJgfvHn4CFmTCA/kK58GIIJnq0U1YAPrOv+P5IPlOiXVG/RD7e2SImSppMQE95R 6jLdBzqrfcbh6e6Gv1CiS/06O0Z1U6M+m6ozFRqPinOYWIsl+PCu/JvKzYxkweVilzT7 1uNyjVlmje7/3pQDkzgHe9jJFyOyt6Qt8Sr/k7a78/j96GSHF2HPsilnfZNTj1BY1Cqh qCibmZvwEVkEIpE60M6sjEobCO9Zn5eBnYgw5CfLjA235iSuO6nWoeUhv9cZFtTaPsHe uYJSzirQv5/MTM75+jGn4NjF805cpnHQuYDEvekvzlDbk9EGrRNF4k5wxbLqTa9crUF2 SnHg== X-Gm-Message-State: ACgBeo1ZKk0TB4X1oDSdHn4ipqnERi2kBatOT29D5OclpPetxfKE7K2z XxNIEvDmRSVk3mFhf3xR75VezdM242QxJdbFS/E4/78C+5h9hZGQ+3OiWWl31KiNYFmu9d36voJ UTaL0WLqj5foq6Uw7wNgVWhPR X-Received: by 2002:ad4:5aad:0:b0:4aa:a266:d1a7 with SMTP id u13-20020ad45aad000000b004aaa266d1a7mr6185325qvg.70.1662614366714; Wed, 07 Sep 2022 22:19:26 -0700 (PDT) X-Received: by 2002:ad4:5aad:0:b0:4aa:a266:d1a7 with SMTP id u13-20020ad45aad000000b004aaa266d1a7mr6185310qvg.70.1662614366505; Wed, 07 Sep 2022 22:19:26 -0700 (PDT) Received: from redhat.com ([45.144.113.243]) by smtp.gmail.com with ESMTPSA id a9-20020ac844a9000000b0034305a91aaesm13189404qto.83.2022.09.07.22.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 22:19:25 -0700 (PDT) Date: Thu, 8 Sep 2022 01:19:20 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: Paolo Abeni , netdev , linux-kernel , virtualization , Eric Dumazet , Jakub Kicinski , Gautam Dawar , davem Subject: Re: [PATCH net] virtio-net: add cond_resched() to the command waiting loop Message-ID: <20220908011858-mutt-send-email-mst@kernel.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 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. -- MST