Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3190762rwi; Tue, 11 Oct 2022 20:48:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4WBtEozrOnnTIJI/TUWs+txqydmQE0o7zfSKqzsWphqIAzDIbeJ1A48WF55NtcQ9BemwSz X-Received: by 2002:a63:6b09:0:b0:453:b1f8:bb3b with SMTP id g9-20020a636b09000000b00453b1f8bb3bmr24456010pgc.36.1665546513172; Tue, 11 Oct 2022 20:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665546513; cv=none; d=google.com; s=arc-20160816; b=i43BArWJ7Nli9gWZIIsYYtChOoxxgCHclB+1EWMWkOU7y9zdrB1OsuE1V8WxdEjSP4 lNZH+/QQZqwlcqnTvfI9T99GolLu/mU4juPElFJChzutFG7M1RAdxdOzBO3v2rkO30po TxxhL6Qp4cVNow3l8MWdtGcITYQVx5B/YRCwTHagB39RWhghyMorzv+Kugjw4WDXle4x w1GFdQOyhrg+S9sNfsDeUskHLXTbtqbZ+obT+FXJ79kn+so+zXorrO8smTrg51xxGj0P cc+q4l5Bvd6ifKRukQxfCNcUPEto/JiPSED3ffCBRBWd9YeAKw759VAmAD+hn0h3Wyw4 AlzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=QOaaFXQ5HbQDaFq6CPpJibOKm0dV0yh95piJEg5lniE=; b=KLNHqQGPoPCCV8w/S9WctS2oVbd0AbiouJMpHZivsHuSj3s64DaxgkVfeq5XCnbCM6 zsjK9Qo/xSjPZcFEOgu3X2eLkr84uF/QXSb+nJZciBu6PcTXsXljn/W5PSXg5JdBMLzL DDoi2VPdIl+Ix5palXwqYwgcBCWPzup46Gua4uY4eaOJGp6h3UXHiDd/cp/u1k+HmVum TEGEbSylv2QDCldsNAhfe4leViYyHAKoJfPrx5zpBfPiW7jb253aCeV8tCOF7MHGyr4t TzZyC4KImDAOWdUVnCz1idoJ4Y0PXPoOoKmFV3jUCbxRJIlj4QT0r0M/+oCI53z3J3D7 Rmhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W2RWlf7j; 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 e13-20020a170902ef4d00b00179cf094dccsi17137779plx.526.2022.10.11.20.48.16; Tue, 11 Oct 2022 20:48:33 -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=W2RWlf7j; 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 S229567AbiJLDT5 (ORCPT + 99 others); Tue, 11 Oct 2022 23:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbiJLDTu (ORCPT ); Tue, 11 Oct 2022 23:19:50 -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 2152576543 for ; Tue, 11 Oct 2022 20:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665544772; 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=QOaaFXQ5HbQDaFq6CPpJibOKm0dV0yh95piJEg5lniE=; b=W2RWlf7jZIfr41WbgBtldpZrCUGiDHtdxvoT1LjZHreCFfB+7GcO3Jkn2w07kztkQSL9pc l0b3u2EIP/QlrxKP7WMuLr6AT4QE6y3Pwx/GIw83/HuaeIinpv/uN5Yg0ADEgj79Dib6R7 yuDsi1xefqq1xAstPnIQrmuI32mGX8Q= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-659-86hswxseMw6cU4SE0-k1WQ-1; Tue, 11 Oct 2022 23:19:23 -0400 X-MC-Unique: 86hswxseMw6cU4SE0-k1WQ-1 Received: by mail-oi1-f198.google.com with SMTP id x5-20020a544005000000b003545901f0deso5034413oie.23 for ; Tue, 11 Oct 2022 20:19:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QOaaFXQ5HbQDaFq6CPpJibOKm0dV0yh95piJEg5lniE=; b=a/w0b1dZIyxkzT5XTlVlRnG6dPYruz3r17jsS8TRMZaXjiIPHHAc7QIeLRFMalJBq4 mg+ZPYzm+hEc8axBvx8BAUG8WcLc6Yo7LW+PMdu/ctPqyXuYEwWmP24S5twfKItmgHqX 3sZRY0mgHs7MreGubA9TCZMlpQ6YSNmAgNvyYcUlOelf3oV0FcwjlmYLoF2O7rVwyPyQ 2/JaBzcbSV8Q+h6sPM9Nvn1Mjzceo+7iUeXudBkBUDrotMyZpEiJ0WnscOYCRjiYUC60 /6wBjkyR3F8qoNmbFVotN1tYGoBl5DPcP03MtzeqdmuREYQwBZ3toLlzVl4d8zAPxWV+ Y2Aw== X-Gm-Message-State: ACrzQf3MhwR5Bn7eW22U4CyfMnJ1N6BnSDlBcRE9pWkNI0yoLPZdIJG0 czg1mv3f26WF9GuZO8VbmviJTVsF/J/gjFuYaEsLFQ3xcEGI+nAtgQUPBlICVOqNY45Mp+LSu0n usjq201IIBTHYHqZ2gwvc0bRXbJG1oscvIvcuMMs7 X-Received: by 2002:a05:6870:eca8:b0:132:df46:5c66 with SMTP id eo40-20020a056870eca800b00132df465c66mr1244859oab.280.1665544763210; Tue, 11 Oct 2022 20:19:23 -0700 (PDT) X-Received: by 2002:a05:6870:eca8:b0:132:df46:5c66 with SMTP id eo40-20020a056870eca800b00132df465c66mr1244845oab.280.1665544762964; Tue, 11 Oct 2022 20:19:22 -0700 (PDT) MIME-Version: 1.0 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> <20221009160520-mutt-send-email-mst@kernel.org> In-Reply-To: <20221009160520-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Wed, 12 Oct 2022 11:19:12 +0800 Message-ID: Subject: Re: [PATCH net] virtio-net: add cond_resched() to the command waiting loop To: "Michael S. Tsirkin" Cc: Jakub Kicinski , Paolo Abeni , netdev , linux-kernel , virtualization , Eric Dumazet , Gautam Dawar , davem Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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, Oct 11, 2022 at 1:11 AM Michael S. Tsirkin wrote: > > On Sun, Oct 09, 2022 at 01:58:53PM +0800, Jason Wang wrote: > > > > =E5=9C=A8 2022/9/8 13:19, Michael S. Tsirkin =E5=86=99=E9=81=93: > > > On Thu, Sep 08, 2022 at 10:21:45AM +0800, Jason Wang wrote: > > > > =E5=9C=A8 2022/9/7 15:46, Michael S. Tsirkin =E5=86=99=E9=81=93: > > > > > 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 wr= ote: > > > > > > > > > > > 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 whe= n preemption is > > > > > > > > > > > not allowed. > > > > > > > > > > > > > > > > > > > > > > What's more important. This is a must for some vDPA p= arent to work > > > > > > > > > > > since control virtqueue is emulated via a workqueue f= or those parents. > > > > > > > > > > > > > > > > > > > > > > Fixes: bda324fd037a ("vdpasim: control virtqueue supp= ort") > > > > > > > > > > That's a weird commit to fix. so it fixes the simulator= ? > > > > > > > > > Yes, since the simulator is using a workqueue to handle c= ontrol virtueue. > > > > > > > > Uhmm... touching a driver for a simulator's sake looks a li= ttle 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 f= rom the > > > > > > > userspace, this means cond_resched() is probably a must for t= he 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 loo= ks like > > > > > > > > neither needs a process context, so perhaps you could rewor= k 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 t= he 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 > > Last question: do we want cpu_relax here now? Or is cond_resched > sufficient? (Have answered in another thread) I think we need cpu_relax() since there could be no high priority task in the current cpu so we still need to relax. Thanks > > > > > > >