Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5618987rwl; Wed, 28 Dec 2022 23:32:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXt7bhJGd+EZF406dhndkd0fRKw8o+4106JwqcBVKBwcIC4Otgt5GgCXpb6J5+3iLzV0oS2T X-Received: by 2002:a17:90a:bc8:b0:219:967c:95c3 with SMTP id x8-20020a17090a0bc800b00219967c95c3mr30136763pjd.1.1672299136731; Wed, 28 Dec 2022 23:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672299136; cv=none; d=google.com; s=arc-20160816; b=OMgtpgTPQNjRxsW0WYEaTTiFu4fCZj0ITSTB5/GexHh2fAKkEVO6WDmRbkb+IZnCNh MXZoYFDVURY4qhTSdmkMbjW4VTxPTCIk4bsiPYY6RWDiId9yCAF6jbOU9uvbL4r2JFaH dhPmNA/5/TeZ+2nH52zCtoHJ/Fq5Ew63Pm4TFxNwBs7xPN+tez+ZKWVtJQ62FVJimiVV aY3QRx5qvBMP6ysJHmvZZ7GV1Kxen4p7IziDsTNjdhuZaYmkmUJUBe85lIXQhDa+5WM3 sak/NayO/YaUHQ0Rbh+AW+WToO+Wpl1ejGUM5k7mzNrmozfRe2d0gJW8vPw5FpbjI/1m H27Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bPu20pS/DdT91F8IydmlqqU8a82kyRMHKQeQqC1iCsQ=; b=K9WVUHB8kGJkExrXa1RB4gXfWvqfPgh0QYUOVng+olAFGti79aLD0tVh6iHe/+hmfa Xf+gexYiR+wWePmg6dz495V0QljlXgH0T2xrksvdradxZVS3emKQG1k+hXeOlMHD6KRS zeBki+cbfxF020ZWr0XFDwSUnwPXDPugtWhRBV9RWVVbIBDjShZwtLn+PGWzX4xF6999 y0rc1dcMNW1ghIJU/OukMH3lZq+85N0W4vA+8Q7Ywx2Cc4Mvuz9pzpCGHH4+QCgrX8oq q9PcRRHCJPj5kUt/CwXiUrb1iMvfZxqLk17VBibSoR3qacD32P7Yb62a1YfWsXYVqGi8 g8bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q2eWVX4b; 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 192-20020a6301c9000000b0047769403088si18352838pgb.627.2022.12.28.23.32.08; Wed, 28 Dec 2022 23:32:16 -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=Q2eWVX4b; 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 S230488AbiL2HI1 (ORCPT + 62 others); Thu, 29 Dec 2022 02:08:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiL2HIZ (ORCPT ); Thu, 29 Dec 2022 02:08:25 -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 E349C9FFE for ; Wed, 28 Dec 2022 23:07:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672297663; 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=bPu20pS/DdT91F8IydmlqqU8a82kyRMHKQeQqC1iCsQ=; b=Q2eWVX4bIRTfWJLwEVQ86gpvcCoSyotdfY843I0aYGKpou+O0ABsqcDHZTjTqsL+1tpeyZ QBlE/5bhcVVuGnBCbGItTr7UctZ9TIZCEFZHATjc4emg1JAvNtfdIMmx00dJ4QzttPrtSt uE15yGRys7H9gKZ9I+nqtk0YsqZs7DA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-651-IuEapzSwOCa7Kt5jKxwwJw-1; Thu, 29 Dec 2022 02:07:42 -0500 X-MC-Unique: IuEapzSwOCa7Kt5jKxwwJw-1 Received: by mail-ed1-f72.google.com with SMTP id z20-20020a05640240d400b0047028edd264so12472055edb.20 for ; Wed, 28 Dec 2022 23:07:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bPu20pS/DdT91F8IydmlqqU8a82kyRMHKQeQqC1iCsQ=; b=0SmBD5GJCq9Ms/iTgPZ1MjEhy8+CCA2QPBloeBhbh189x4nG8pKIg/L2dc/S3HwOdK f7goFJNU1vIJkerWsoaeurJCfhmjsWCJcMtnISEbi0jS8NwGm/C3Z7qvo5NDnFInmYLZ /a581h7tTLvqqJf4AGZVfUsalL6y6/MFnuypeVp7GK9aR7CEM2F1jowPU5I34WnTwhoP ClFsU7lktBFbOw6U0fDY4H4eXmNHSpFrIk/l6As/Y9/RWve9RDuU/hwZz+w2FjLZr7/O VWYgXEQxO4bCtSftRTi0f/ayxhNnmijkuhQRA59T/gZRcrOVfkHgqToyfgTHW49pFnBI 5VoQ== X-Gm-Message-State: AFqh2kqt73nXLfMst9HUz9UNnMyF7jSEN+bx8VPcfEhxTx0qmlzU88sz u7Um1Gv7iEF4UblUeHCanyJSYC3RonLFZEnkEnf8UTiPp2EC8fz5QkHPb5w6RZrR8hFnjjC76Pj zplvgbTZC2Ih205jdcXTQ7g9q X-Received: by 2002:a17:906:298f:b0:7c0:fa2c:fc9b with SMTP id x15-20020a170906298f00b007c0fa2cfc9bmr25411320eje.55.1672297661225; Wed, 28 Dec 2022 23:07:41 -0800 (PST) X-Received: by 2002:a17:906:298f:b0:7c0:fa2c:fc9b with SMTP id x15-20020a170906298f00b007c0fa2cfc9bmr25411307eje.55.1672297660951; Wed, 28 Dec 2022 23:07:40 -0800 (PST) Received: from redhat.com ([2.52.151.85]) by smtp.gmail.com with ESMTPSA id b11-20020a17090630cb00b007c0f5d6f754sm8249151ejb.79.2022.12.28.23.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 23:07:40 -0800 (PST) Date: Thu, 29 Dec 2022 02:07:36 -0500 From: "Michael S. Tsirkin" To: Jason Wang 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 Subject: Re: [PATCH 3/4] virtio_ring: introduce a per virtqueue waitqueue Message-ID: <20221229020553-mutt-send-email-mst@kernel.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 07:53:08PM +0800, Jason Wang wrote: > On Wed, Dec 28, 2022 at 2:34 PM Jason Wang wrote: > > > > > > 在 2022/12/27 17:38, Michael S. Tsirkin 写道: > > > On Tue, Dec 27, 2022 at 05:12:58PM +0800, Jason Wang wrote: > > >> 在 2022/12/27 15:33, Michael S. Tsirkin 写道: > > >>> 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. I never said you can just use existing exporting APIs. You'll have to write new ones :) > 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 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 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. 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 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 > > > > > > > > > >>>