Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5140903rwb; Tue, 6 Sep 2022 20:02:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5IfaIooshAj+axyT0FAW9hQ7EJ0o0SKZvFBXQsYLKDC6NXoy5i28gxMFkcecNSSEY+bAd0 X-Received: by 2002:a17:90b:4b8f:b0:1fb:10e2:5c99 with SMTP id lr15-20020a17090b4b8f00b001fb10e25c99mr28318545pjb.194.1662519778395; Tue, 06 Sep 2022 20:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662519778; cv=none; d=google.com; s=arc-20160816; b=qvLYtsM15jfiO53aOPV/Wvcx3WhsP+j+vMMJ0VHMd4qctp+we4iOsbjmyJvzrsgIS/ Ux6xzW7o/9EFTRYMF6+dv4l/zxpwwj4YpiGc9q99SeJqwQWIo8/kczUirrfRphgXxMNK ic9AXOc+XNsxAI2lVqhRHz+cpmMuAgfrQ7sKs51D56HonSsQng25wnSsWLZmRsr2LLnO r/eJ93qYMaZnZMe0pyVWEE+xRNsKM0JjIg9Pohg2PhbY4KnIS80LPsCGPNCZ+yTUzr1O H887xJ2AdoPb46Yj975m2J+zvYaHD+u2uAyvg4zlFNLTQCrC0vu5GTvtfXWS5/V7bLvc N8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Vx8aKJ5u7qXrqUODw8TKz6yxmbl8ogDCyc6Iz97sTBo=; b=yqpvka1t5RdXqdBUGpcEV1oPeekWSWbpjP2wzNDH/mF7ZMwTRyJ73QOegh6/Zn/U+R VpKIIG9wqIcucAr6XMybyNwSPv3ptcr57ngFtAFXB2emAnRuCWADhvCQFStwCFWuckUH 5NGh5w1ybTk0Onmp1NY5yH0lCQSJ/sD91UspZYs/cWjSFO3hIYWKVC6XWwASSeG/cMIr e9v54i62bey4hV7cFLOF010Q0WZDwr5rE9/gJm0jHAFmxpofXHQWK+k+wFvH8eYEXQoU KF4OpCC3IKvQk+nJ35JpLjLQHfs/P7RZCyhymWdJDP5eAmy9q0qaMtoDyqawoymDd17M qFbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LZLDIrQI; 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 134-20020a63028c000000b004344395bde6si9211637pgc.547.2022.09.06.20.02.46; Tue, 06 Sep 2022 20:02:58 -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=LZLDIrQI; 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 S229713AbiIGCKN (ORCPT + 99 others); Tue, 6 Sep 2022 22:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiIGCKJ (ORCPT ); Tue, 6 Sep 2022 22:10:09 -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 C3E5D46228 for ; Tue, 6 Sep 2022 19:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662516606; 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=Vx8aKJ5u7qXrqUODw8TKz6yxmbl8ogDCyc6Iz97sTBo=; b=LZLDIrQIh5TuK5gKFT2orXbBL+wv1/XbJcucX2/nrCTc1UBo1N10+dfEj4kjdQxnpwmJPl Zm0jtLUvgTow8xcKxAKAH4ft9OXuNVmYzS5kJpdkETBuCWmrdcy29XRy/haQ2iQvTqG6uY 2IBnT7bc6PcRh6+/XNLmQbdEJ193nts= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-513-E9r6vMOgMoqJe7um0pjNhA-1; Tue, 06 Sep 2022 22:10:03 -0400 X-MC-Unique: E9r6vMOgMoqJe7um0pjNhA-1 Received: by mail-ua1-f72.google.com with SMTP id o43-20020ab0596e000000b0038421e4c7deso2375041uad.19 for ; Tue, 06 Sep 2022 19:10:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=Vx8aKJ5u7qXrqUODw8TKz6yxmbl8ogDCyc6Iz97sTBo=; b=eUqoB9Y3Suc/7Bfx0Ojr5/eC15M/Mp3gd+nq+NZ2E/J6zrgaLHHmVKqrY0y9KNRuv2 40qiQ/lwG6ICV2cLPdF4KiriR21tfVmkMRTFd8Igt2Di1MAxoCnj+x4p/x2J+PF9I2pM eTjYQYx8PFF/EVYHhof1+CDZWoj9IOXQAjyYUt91HzaGz25qxyOjsFqhKCcWjg/o+Zgx 5SoFZEQrnCDvwsnTHDZ9dCrtMsjHd8BfRZ/cFOcGtenrVVhSmW+QrwMsqAATq4VdSOpE 7POdmTfcPrU6DfmgLOFG3XkZ+UaykaFSDCRyqozN1Fvhwq6gbT0as6211pPuSJ6Xp6lM 1kNQ== X-Gm-Message-State: ACgBeo0POoLSbG+EoqTSNt8FMdBh0oyE4aV85KN25yBz+Z/V2Wf4Tufw Ken3JUVmE8KA926SiLRfeqJb6+P6TE7AZtyqmiOOYyNaGglCxxsBDVP4ou1aRTGBFL8RTfdIog3 lNGJ/Qy1DOjfrqgzrX2+MmUE/kIRCIP6AM62AXB4+ X-Received: by 2002:a1f:ac83:0:b0:388:9d97:b5a9 with SMTP id v125-20020a1fac83000000b003889d97b5a9mr372668vke.22.1662516603315; Tue, 06 Sep 2022 19:10:03 -0700 (PDT) X-Received: by 2002:a1f:ac83:0:b0:388:9d97:b5a9 with SMTP id v125-20020a1fac83000000b003889d97b5a9mr372663vke.22.1662516603081; Tue, 06 Sep 2022 19:10:03 -0700 (PDT) MIME-Version: 1.0 References: <20220905045341.66191-1-jasowang@redhat.com> <20220905031405-mutt-send-email-mst@kernel.org> <056ba905a2579903a372258383afdf6579767ad0.camel@redhat.com> In-Reply-To: <056ba905a2579903a372258383afdf6579767ad0.camel@redhat.com> From: Jason Wang Date: Wed, 7 Sep 2022 10:09:52 +0800 Message-ID: Subject: Re: [PATCH net] virtio-net: add cond_resched() to the command waiting loop To: Paolo Abeni Cc: "Michael S. Tsirkin" , netdev , linux-kernel , virtualization , Eric Dumazet , Jakub Kicinski , Gautam Dawar , davem Content-Type: text/plain; charset="UTF-8" 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 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. 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). Thanks > > Thanks! > > Paolo >