Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5341093rwb; Wed, 7 Sep 2022 00:58:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Uw8ewh9auDpp5sFwXCsm6GFVyV8dkYDetOiO4EqudY2hu8pM6YfWihYLROFmvMSK4S6PD X-Received: by 2002:a17:902:da8d:b0:175:512d:35ef with SMTP id j13-20020a170902da8d00b00175512d35efmr2653720plx.75.1662537488644; Wed, 07 Sep 2022 00:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662537488; cv=none; d=google.com; s=arc-20160816; b=mg+2s8DaGKXyDjXkdGxm0y+l5OYawmPx2v/NH/AT0y4vkctwjB5MBW4VD/huyDm77X Nhv9ioLI/6k6ewWGpetMx9i4DWOthKjwFivw+3TqhhZ1107qZo+k5u2ByA3yIqHumPRf bWNhfcDeWmyshhpcWimjldAo5h5ZdJS33bqHb5tr1yHwqMn+J4EipQXEBGqyh7iLIu+R eFuPwK8UwrZCZURQcPkJplumLu2RSIv897G7ddrxE/Gc3jtAWG7jsD8cueKkpUpJnXjd CiSkRPt/ruslfrYPZFUQF63yHzcjpdtOO66kTlrRxhlQ3GgMEpCvsBinAmR9sazggH+U y63w== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nsmvzDdU873IEoh1AjpLdUk0IkH22pk9o0ERO+Ke0Qs=; b=mW8eAOUm9mRxztODV7hVD4ZJPxQ02Mx9gesvFYdKNcXAfcmVFhao9BfNCNlIWHNroQ MMBhPzM8vHI8EAl4svR0GcioFcdaXg7Qrv1ni5Sxm0PqYwofaAxmkPw68S/c5/H01w45 hqj4BIYE6jJXSQuTVuI33HK5u81KjnGq1B+BC2ixcQnm2ZNCcmCY4ttx6ycQTgL9Z373 uC8D6A1OnelyilANlYYEr906uND8t4kkAI/to2UF2YQM2TePMWiE3oQzQDfd6Ap03Gp+ 1Uc/Lc0uinTKUTRu5rzXLkwz4RUuR3v93ZxVW0Y+aO42n9SCg/GOUJLTbDjMOH3bM55B J8Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OaqBFTGE; 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 n8-20020a170903110800b00172f1cf5ba7si18133635plh.38.2022.09.07.00.57.56; Wed, 07 Sep 2022 00:58:08 -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=OaqBFTGE; 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 S230132AbiIGHrh (ORCPT + 99 others); Wed, 7 Sep 2022 03:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbiIGHrT (ORCPT ); Wed, 7 Sep 2022 03:47:19 -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 4CA6EA7A8F for ; Wed, 7 Sep 2022 00:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662536824; 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: in-reply-to:in-reply-to:references:references; bh=nsmvzDdU873IEoh1AjpLdUk0IkH22pk9o0ERO+Ke0Qs=; b=OaqBFTGE871PslXddGnEnYnLUuK0/M8zyYgmuSQRInea1FdXWYYiifSHNgt4Mls9KRMAvx qUmvt9z3FFheh39EH+S2O3+GImjGOkEosa9tAg8Us8/Q0s49mLW+ZqFDrXSv0J8bn5xUOV zgHMicCuZcD/rsMKaD61M3XIh8ztdRU= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-346-NkyXR1TlOha4CNLR5_X1Bg-1; Wed, 07 Sep 2022 03:47:01 -0400 X-MC-Unique: NkyXR1TlOha4CNLR5_X1Bg-1 Received: by mail-ej1-f70.google.com with SMTP id hp14-20020a1709073e0e00b00741a2093c4aso4622219ejc.20 for ; Wed, 07 Sep 2022 00:47:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=nsmvzDdU873IEoh1AjpLdUk0IkH22pk9o0ERO+Ke0Qs=; b=Qu0KXEFWMw6OmnwbiysdVcgWqfgk9YBVK4zoLqyE7Yx4VkU+j1+nBBsQ1eocLbdM3U 5DuLqPbSqFIGMAin9Hz8jjj320pVc6B83yCVQOgmfUr1rba95s6fhGmokeJ39j6MiRny KyuWDl3yLULyDr+kSL6+D8yKrmTHCjEu7h02cWGVlui9h1Rjw4o+vwPQXqEbOpiS1KKe XM5wVJM7FNDsRvrZrBxaoXmecAZZ90J8XWcZDeeHSmPNQfAA6RNQTdV4rpFVG/lsk54d upzqX4+dpN0MfnP1D8Oc3y6SjP9TBPMkd0BFfw3DmUDZotdV4Ixf3gpVlmTaMdf1/oYV 4duA== X-Gm-Message-State: ACgBeo10BEp54qTjxvS8ijA7IXoI+EwUNn80ZO0Mb9BkyxhojfWIem1I ej3Qxt+2ecK4GoaDST0TfX4606qVm9HxJ/lxtHY3spwXzxVFkYk+dvqbyfe4mSrx4Wm9xITB5M2 Te5ZrAPiP2nhgAh03iXSLrilh X-Received: by 2002:a17:907:75ea:b0:73d:daa0:3cbe with SMTP id jz10-20020a17090775ea00b0073ddaa03cbemr1456175ejc.662.1662536820005; Wed, 07 Sep 2022 00:47:00 -0700 (PDT) X-Received: by 2002:a17:907:75ea:b0:73d:daa0:3cbe with SMTP id jz10-20020a17090775ea00b0073ddaa03cbemr1456158ejc.662.1662536819797; Wed, 07 Sep 2022 00:46:59 -0700 (PDT) Received: from redhat.com ([2.52.135.118]) by smtp.gmail.com with ESMTPSA id b9-20020a1709063ca900b0073c82539183sm8022689ejh.91.2022.09.07.00.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 00:46:59 -0700 (PDT) Date: Wed, 7 Sep 2022 03:46:55 -0400 From: "Michael S. Tsirkin" To: Paolo Abeni Cc: Jason Wang , 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: <20220907034407-mutt-send-email-mst@kernel.org> References: <20220905045341.66191-1-jasowang@redhat.com> <20220905031405-mutt-send-email-mst@kernel.org> <056ba905a2579903a372258383afdf6579767ad0.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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=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 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. -- MST