Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02F2DC05027 for ; Sun, 29 Jan 2023 05:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbjA2Ftz (ORCPT ); Sun, 29 Jan 2023 00:49:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjA2Ftw (ORCPT ); Sun, 29 Jan 2023 00:49:52 -0500 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 8784821977 for ; Sat, 28 Jan 2023 21:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674971349; 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=v/JqQvkfYmpECZlGXQBcNM/6Zavf+3AMGSMqsORLXLY=; b=BHZZW/5F/hqUgvpVS5ljYT/d2fFzS5vNXoqw6PS39lOB9rbdXlR1hA8iqYDnu/5tmIZ6f7 osZDwG2u3IOg4jfau9tK1qgSpZRmvpF9vp3qTDeI/M0QxC5TamNRyITLj2S8cbXk7iQqWv 3hlzC2Y2888cKfMVxxcnmHNOcuMTFTI= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-656-TX3J1eUCM4CkN24wesyz1g-1; Sun, 29 Jan 2023 00:49:01 -0500 X-MC-Unique: TX3J1eUCM4CkN24wesyz1g-1 Received: by mail-oo1-f71.google.com with SMTP id l17-20020a4a94d1000000b00512d6351a8dso1860714ooi.8 for ; Sat, 28 Jan 2023 21:49:01 -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=v/JqQvkfYmpECZlGXQBcNM/6Zavf+3AMGSMqsORLXLY=; b=aCMFMx+y4dZFBkS8aJLKMi4bnX5EvLEXCLrG0y7uHBxBA3SIkfYIbB0odaqmMRqfvy +cK8t1XNc6UD0+pP9+urWBHZ6g8LZvfEPFuqCgg0IClnCRhlxoDvjvn5rroyZ+6HScrp E60GZ/U9JBrKDWvB1VWHZm6eMRR+zgbJnIPyP/GITACJpobSe4WQfwg2mxDefsXflrl1 UF473JK2g017ePbv6gerDecFxpmqGO5f/PtqNuLygTawW/5qREsRrZ8RrP9IJXhRVqah H+ejL4Dbc27NSfNwb+GfQ2PRXe6oASQlg9AExnFqxmbrCASJrA5e9iPK6Z2lO1ShlW1V t1bA== X-Gm-Message-State: AFqh2koziHdRoE7Ta25asfiNGXqGLY/KC0NQq2hAXpdwyJs5PCKdk7Ol c06ddzN5IgtvLvAfTm4UlHQyS9MZybjzj3PlqFTCSBclKhhhpiI+7tQ0YLgIrzMDH0jI0b4Vbu5 ejOiiRTQCMrRgc9iimkSByMbsqqFJtKEBbIgpAi0J X-Received: by 2002:a05:6871:10e:b0:15b:96b5:9916 with SMTP id y14-20020a056871010e00b0015b96b59916mr3701892oab.280.1674971340709; Sat, 28 Jan 2023 21:49:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXsY8GrgffCnTLZZkxvDGxQQI39DxhaTkYBL757UooQVj0vRieclaFLm0dBs/b3Ed5SX/SbZEXdYdiLyT5qVIfA= X-Received: by 2002:a05:6871:10e:b0:15b:96b5:9916 with SMTP id y14-20020a056871010e00b0015b96b59916mr3701888oab.280.1674971340445; Sat, 28 Jan 2023 21:49:00 -0800 (PST) MIME-Version: 1.0 References: <20221227022255-mutt-send-email-mst@kernel.org> <20221227043148-mutt-send-email-mst@kernel.org> <0d9f1b89-9374-747b-3fb0-b4b28ad0ace1@redhat.com> <20221229020553-mutt-send-email-mst@kernel.org> <20221229030633-mutt-send-email-mst@kernel.org> <20230127053112-mutt-send-email-mst@kernel.org> In-Reply-To: <20230127053112-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Sun, 29 Jan 2023 13:48:49 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 27, 2023 at 6:35 PM Michael S. Tsirkin wrote: > > On Fri, Dec 30, 2022 at 11:43:08AM +0800, Jason Wang wrote: > > On Thu, Dec 29, 2022 at 4:10 PM Michael S. Tsirkin wro= te: > > > > > > On Thu, Dec 29, 2022 at 04:04:13PM +0800, Jason Wang wrote: > > > > On Thu, Dec 29, 2022 at 3:07 PM Michael S. Tsirkin = wrote: > > > > > > > > > > On Wed, Dec 28, 2022 at 07:53:08PM +0800, Jason Wang wrote: > > > > > > 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 wrot= e: > > > > > > > >>>>> But device is still going and will later use the buffer= s. > > > > > > > >>>>> > > > > > > > >>>>> 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 w= ait. > > > > > > > >>>> > > > > > > > >>>> Thanks > > > > > > > >>> If the goal is to avoid disrupting traffic while CVQ is i= n use, > > > > > > > >>> that sounds more reasonable. E.g. someone is turning on p= romisc, > > > > > > > >>> 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 he= lp. The > > > > > > only export helper is touch_softlockup_watchdog() which tries t= o avoid > > > > > > triggering the lockups warning for the known slow path. > > > > > > > > > > I never said you can just use existing exporting APIs. You'll hav= e to > > > > > write new ones :) > > > > > > > > Ok, I thought you wanted to trigger similar warnings as a watchdog. > > > > > > > > Btw, I wonder what kind of logic you want here. If we switch to usi= ng > > > > sleep, there won't be soft lockup anymore. A simple wait + timeout = + > > > > warning seems sufficient? > > > > > > > > Thanks > > > > > > I'd like to avoid need to teach users new APIs. So watchdog setup to = apply > > > to this driver. The warning can be different. > > > > Right, so it looks to me the only possible setup is the > > watchdog_thres. I plan to trigger the warning every watchdog_thres * 2 > > second (as softlockup did). > > > > And I think it would still make sense to fail, we can start with a > > very long timeout like 1 minutes and break the device. Does this make > > sense? > > > > Thanks > > I'd say we need to make this manageable then. Did you mean something like sysfs or module parameters? > Can't we do it normally > e.g. react to an interrupt to return to userspace? I didn't get the meaning of this. Sorry. Thanks > > > > > > > > > > > > > > > > > > > > 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 sl= eep. > > > > > > What we can do is probably do a periodic netdev_err(). > > > > > > > > > > > > Thanks > > > > > > > > > > Only with a bad device. > > > > > > > > > > > > >> > > > > > > > >> > > > > > > > >>> 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 i= s not nice. > > > > > > > >>> let's poll for a bit before waiting? > > > > > > > >> > > > > > > > >> Then we go back to the question of choosing a good timeout= for poll. And > > > > > > > >> 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 che= ck once > > > > > > > > after kick. > > > > > > > > > > > > > > > > > > > > > I think it is what the current code did where the condition w= ill be > > > > > > > check before trying to sleep in the wait_event(). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >>> 3- suprise removal. need to wake up thread in some way. w= hat about > > > > > > > >>> other cases of device breakage - is there a chance t= his > > > > > > > >>> 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 shou= ld 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 th= e changes > > > > > > > in virtio-net without bothering virtio core. > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >>> > > > > > > > > >