Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4418821rwl; Wed, 28 Dec 2022 04:01:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXuaQQbBka5uN+y06Nk5z1kruHE2HiM9SqwTsFL/aVG55bwkg18NH3Vq/aX7B8wtsgAbRULs X-Received: by 2002:a17:906:3bc7:b0:7c0:db61:dbd5 with SMTP id v7-20020a1709063bc700b007c0db61dbd5mr20021520ejf.62.1672228878684; Wed, 28 Dec 2022 04:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672228878; cv=none; d=google.com; s=arc-20160816; b=TbcXeWEoby0wUND4Z2Bd8uFV/bjveAauMrJ4wI9NB46WfU/3KQvVvP3WZcRKdYMHP+ bJ6mfRIJAccawN+JdFrz3LW/XjDDsMiaqDpb+pWOL9apvC+3ygnrcX9jUqt89ibe9yDn HWvTmkwvlKAuAcUfeK1yReKKvEPbLUijtI+Fc4LprmgWrWkdX1NPs3/fhshXu9X94FrS D7f1D/CeUxUJ64nF4yfTOrzAab2+ebTUA7L/smlzo+BMhLPPo6cRMTf73OQpAmr9Rlky qd6DQU8Gvv9AFT2g9OrwZaAhFYiJL9GKBRSz+UCl3F9h0AS4kFydWSB611I43EFwtfgm VF/g== 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=3hQKS1NwOrIIXUtr0/6kNG7P651iOA+L6EemF1Qhqo8=; b=ZtCSjhXnIlcHaG7/s95mWF/OtoYpCREtfLoXavfaKjHrhqK8/7Fda8ZGnhjv7V0f4q kze9GH/kYBqIoLbvhLnEUTt2+AXGEHi9un3i1vr7HhXLFXu58cF1UMJEYl29hA5xfSXI c3+mm+q4oTW3GeVXJM/26nDvr9G4ADmoMf6pn85p148lAdpzZOzpS3vraAZHMT4NuXoG KeuDAvgtWqsPU/Jn+eYB7Hog+kpv5BjFhdNL29k94boXGRi70sL1cV8fUz7ytLaG3/Gc Rs80ERx1VfhRaW2di2bs5Y7NaF8N/WTgIqmAvjDgricrA5v2WOwuomOBfpaJBEXLQ7fq fNoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="a3/ip11N"; 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 hc18-20020a170907169200b008379ac04127si15000470ejc.199.2022.12.28.04.01.03; Wed, 28 Dec 2022 04:01:18 -0800 (PST) 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="a3/ip11N"; 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 S232935AbiL1LyN (ORCPT + 64 others); Wed, 28 Dec 2022 06:54:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232250AbiL1LyK (ORCPT ); Wed, 28 Dec 2022 06:54:10 -0500 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 DA32A10FCB for ; Wed, 28 Dec 2022 03:53:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672228401; 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=3hQKS1NwOrIIXUtr0/6kNG7P651iOA+L6EemF1Qhqo8=; b=a3/ip11NJgo5ciZu+r1h09W/A1329peynAL+bUgFJfbFzb6V0h/xZieJGGi9Bh2HO+sGCm 295/1DMdVZTTyyDgO/AN1KZdIeiO5y0U33hQQOEy6pdFuNNtB8uCOCVIviF5d/sLAUd3Ia AeOp2ZZMih0j0m4upN1I7N8WE9TFbbs= Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-541-56w2p8oKN_-d6auElWJdVg-1; Wed, 28 Dec 2022 06:53:20 -0500 X-MC-Unique: 56w2p8oKN_-d6auElWJdVg-1 Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-1437fb9949bso7501715fac.5 for ; Wed, 28 Dec 2022 03:53:20 -0800 (PST) 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=3hQKS1NwOrIIXUtr0/6kNG7P651iOA+L6EemF1Qhqo8=; b=n00s+fy6yQfkM8mYzsZ0B2VBE5iQ4yIP6cP1n24wy30Ok6lHvB3wfKNENrHZ8pG7oD v5KeQmmML1N7OllP6/p5FuiSV+YUnwXHoRRQagH9+bs8KL3gn4pBAFUV1+8lm98bZzpm PpKXxC+sMWmpUEUkq3B2acJgEE1vP4SKdyxoOyWPFOj6aMX4Grz3QrVdGexoJEhap5AL DV/p6UFrP+oNTBqFbtXuTj0RdbFWhBNSUdVnfHmVUMM/w6hKqS/mILANsVRPo5QsU5wQ Zh9G18+N85vOmn0PzMfsNzNhGmC4pgVuw55JNXBvptK/fhmSWLwaUu6LRxRnAoiwh10R 8oHg== X-Gm-Message-State: AFqh2kpgz4J2Z7mR2S5y86N9p89ba9wdsV5XbgaVKr5hIfT83zoHc0oa ZH3uzcQrfvuT9IUEmpKfcmmWqgML5qesuDTNlBVcLHiwmzqS73NTGnoY6TDSLf2SR6pxAZUEOC6 fU7kTFP1oE5mpNiteLj8P72dRgGAadKLRYm9gCUFc X-Received: by 2002:a9d:7843:0:b0:678:1eb4:3406 with SMTP id c3-20020a9d7843000000b006781eb43406mr1573916otm.237.1672228399892; Wed, 28 Dec 2022 03:53:19 -0800 (PST) X-Received: by 2002:a9d:7843:0:b0:678:1eb4:3406 with SMTP id c3-20020a9d7843000000b006781eb43406mr1573914otm.237.1672228399502; Wed, 28 Dec 2022 03:53:19 -0800 (PST) MIME-Version: 1.0 References: <20221226074908.8154-1-jasowang@redhat.com> <20221226074908.8154-4-jasowang@redhat.com> <20221226183705-mutt-send-email-mst@kernel.org> <20221227022255-mutt-send-email-mst@kernel.org> <20221227043148-mutt-send-email-mst@kernel.org> <0d9f1b89-9374-747b-3fb0-b4b28ad0ace1@redhat.com> In-Reply-To: <0d9f1b89-9374-747b-3fb0-b4b28ad0ace1@redhat.com> From: Jason Wang Date: Wed, 28 Dec 2022 19:53:08 +0800 Message-ID: Subject: Re: [PATCH 3/4] virtio_ring: introduce a per virtqueue waitqueue To: "Michael S. Tsirkin" Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com, alvaro.karsz@solid-run.com, eperezma@redhat.com 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Wed, Dec 28, 2022 at 2:34 PM Jason Wang wrote: > > > =E5=9C=A8 2022/12/27 17:38, Michael S. Tsirkin =E5=86=99=E9=81=93: > > On Tue, Dec 27, 2022 at 05:12:58PM +0800, Jason Wang wrote: > >> =E5=9C=A8 2022/12/27 15:33, Michael S. Tsirkin =E5=86=99=E9=81=93: > >>> On Tue, Dec 27, 2022 at 12:30:35PM +0800, Jason Wang wrote: > >>>>> But device is still going and will later use the buffers. > >>>>> > >>>>> Same for timeout really. > >>>> Avoiding infinite wait/poll is one of the goals, another is to sleep= . > >>>> If we think the timeout is hard, we can start from the wait. > >>>> > >>>> Thanks > >>> If the goal is to avoid disrupting traffic while CVQ is in use, > >>> that sounds more reasonable. E.g. someone is turning on promisc, > >>> a spike in CPU usage might be unwelcome. > >> > >> Yes, this would be more obvious is UP is used. > >> > >> > >>> things we should be careful to address then: > >>> 1- debugging. Currently it's easy to see a warning if CPU is stuck > >>> in a loop for a while, and we also get a backtrace. > >>> E.g. with this - how do we know who has the RTNL? > >>> We need to integrate with kernel/watchdog.c for good results > >>> and to make sure policy is consistent. > >> > >> That's fine, will consider this. So after some investigation, it seems the watchdog.c doesn't help. The only export helper is touch_softlockup_watchdog() which tries to avoid triggering the lockups warning for the known slow path. And before the patch, we end up with a real infinite loop which could be caught by RCU stall detector which is not the case of the sleep. What we can do is probably do a periodic netdev_err(). Thanks > >> > >> > >>> 2- overhead. In a very common scenario when device is in hypervisor, > >>> programming timers etc has a very high overhead, at bootup > >>> lots of CVQ commands are run and slowing boot down is not nice. > >>> let's poll for a bit before waiting? > >> > >> Then we go back to the question of choosing a good timeout for poll. A= nd > >> poll seems problematic in the case of UP, scheduler might not have the > >> chance to run. > > Poll just a bit :) Seriously I don't know, but at least check once > > after kick. > > > I think it is what the current code did where the condition will be > check before trying to sleep in the wait_event(). > > > > > >>> 3- suprise removal. need to wake up thread in some way. what about > >>> other cases of device breakage - is there a chance this > >>> introduces new bugs around that? at least enumerate them please. > >> > >> The current code did: > >> > >> 1) check for vq->broken > >> 2) wakeup during BAD_RING() > >> > >> So we won't end up with a never woke up process which should be fine. > >> > >> Thanks > > > > BTW BAD_RING on removal will trigger dev_err. Not sure that is a good > > idea - can cause crashes if kernel panics on error. > > > Yes, it's better to use __virtqueue_break() instead. > > But consider we will start from a wait first, I will limit the changes > in virtio-net without bothering virtio core. > > Thanks > > > > > >>>