Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp53625rwn; Wed, 7 Sep 2022 19:55:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR595nqgLPnh8oKpoo7JAqUuHcVMzc0utPEXhVnNR24KCVNRoeBLW0mUeR5NiNyHUfRZ7Nv8 X-Received: by 2002:a05:6402:2989:b0:44e:90d0:b9ff with SMTP id eq9-20020a056402298900b0044e90d0b9ffmr5254468edb.110.1662605752040; Wed, 07 Sep 2022 19:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662605752; cv=none; d=google.com; s=arc-20160816; b=eMXbQCrvcuPkpHWBcDO9BXByadsoa/7CKuXDMUd1aQ/qzasjuG2H7nj6NFl7tm59wy WHF/lLjGCIzDJ2BdLcO3MRy20bmi3LtyV45r101SLFusI/nKaAR7AKltW0YvYGUeYt8G XDlXw7AbgdS9VM5xtjWyOYHN9xBQJyREFqDZl8huGhICov5QgVlBqwRzHKklJ7StFYQT bx9DTn3wnZD95xzm3PrK5WsxYQkt+tN4V8k052N9HgMJVmGJUrPZFQdq5fvTTaWrBFBH bSizUH1pfZobNWT7BcQDDD97l8uT5mRScCI/Ft8SssmHWuD7CzqQgMB5b4OvOWb5mKgZ eh8g== 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=iT5k9dnvMqT2ZKkMTuSIzNcN6Xuwb0rz4A/0JhBTSpk=; b=Tb3OBazlaYVUmEJ+MH+mcu4b+ppApMEAaXE4SXq8zY6at7TS9uov1SzKUwcyYWcGtT 8dFO5aVJvXKWEo1C1eLUA/s//hr5j4n8THBgQZHxFhB/MdLy7iRYiMu8zbS/Je67rAp+ VpHHKULzXpY533BQ1k/JZ0HI6jXwj5bCMU28UgwppdA9RJslFMGuAilSA4D7lztHwEdH FYZ/iDgo+0AyGGPBFIZT+U5bF35569f3aStOqqzC2YPcAYFePtcHeYWIoW/64dyMMkkr dW8E613EZ++IqGLBEfDoTRYfYVKrUp3z6uAkXHQGF/Czwe1LCRsvUeWEnv2f8MwRf50e BJsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LD1XTlH6; 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 rh2-20020a17090720e200b0073d543f0ca7si847374ejb.404.2022.09.07.19.55.02; Wed, 07 Sep 2022 19:55:52 -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=LD1XTlH6; 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 S229536AbiIHCV5 (ORCPT + 99 others); Wed, 7 Sep 2022 22:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbiIHCV4 (ORCPT ); Wed, 7 Sep 2022 22:21:56 -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 0D8B3AB045 for ; Wed, 7 Sep 2022 19:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662603714; 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=iT5k9dnvMqT2ZKkMTuSIzNcN6Xuwb0rz4A/0JhBTSpk=; b=LD1XTlH6xG7R+OFttH9IqoH3J14DrHmR+l9wgJ5AqhFJTv5VBKn8M6KX9DdE6KHEN0/fTn MMFm8SIxcT/CH8T/aIW8VsGPtI22gqoSLmAE3xweP6G35mmpn3hCCcjZDXMrsVH+wHpbqi P9CRamAMyjuYUQ2l6rgqxn23bUKb5gQ= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-73-d8t2JWohMXCm43Fgb2tghg-1; Wed, 07 Sep 2022 22:21:53 -0400 X-MC-Unique: d8t2JWohMXCm43Fgb2tghg-1 Received: by mail-pl1-f197.google.com with SMTP id f1-20020a170902ce8100b001731029cd6bso10897125plg.1 for ; Wed, 07 Sep 2022 19:21:52 -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; bh=iT5k9dnvMqT2ZKkMTuSIzNcN6Xuwb0rz4A/0JhBTSpk=; b=5JshzEb3DpERKo1SN5eDTTSVILH3xmeh3j1sexm6nV18kGTeaRe8DSD6Ae6uMdsZVP 1VutsdAFfYqT0nhi+35qH8NGNa2G1N420K/LxK4OYHwqaFBtkifBSTOmDaM693v8eSrj 4CvU4eWwW+rnn38i7fFUCzASNLvtCvIUaoYIM4e6L3qDMDrSi9yStMN5wjtIOD/7Bp8f IKeYzG02XQcOAjFYeHYW5nRV3bAp/32sf/gu794zMeP6uaUCi6DFydAtnWIss/pbm6AD ut+T4CEz0RlcI5pht+lJ+yIxbr6SuGRR0aRC3WZdk16NvGuo8VIbDUxoP1nO1ycGtHmT IdVg== X-Gm-Message-State: ACgBeo1dbyZZ9Yv5RSMsuy2pRkdgSsn1+yQnxIubQuJoyJlsqQBGBcCu tFeZ/MYV/4ROphIijsg24p3FlEHxIKOegXgZ9292SgH5LM9Od5dWjErnNMq4rXlE22G4czv4b7U 99wS2ZksJh4gmysZ+ifDzMTWB X-Received: by 2002:a05:6a00:1354:b0:53a:80d6:6f61 with SMTP id k20-20020a056a00135400b0053a80d66f61mr6754057pfu.69.1662603712090; Wed, 07 Sep 2022 19:21:52 -0700 (PDT) X-Received: by 2002:a05:6a00:1354:b0:53a:80d6:6f61 with SMTP id k20-20020a056a00135400b0053a80d66f61mr6754042pfu.69.1662603711816; Wed, 07 Sep 2022 19:21:51 -0700 (PDT) Received: from [10.72.13.192] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id x9-20020a17090a294900b002005114fbf5sm401322pjf.22.2022.09.07.19.21.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Sep 2022 19:21:50 -0700 (PDT) Message-ID: Date: Thu, 8 Sep 2022 10:21:45 +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.0 Subject: Re: [PATCH net] virtio-net: add cond_resched() to the command waiting loop Content-Language: en-US To: "Michael S. Tsirkin" , Paolo Abeni Cc: netdev , linux-kernel , virtualization , Eric Dumazet , Jakub Kicinski , 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> From: Jason Wang In-Reply-To: <20220907034407-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 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,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/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 >