Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4128350rwl; Tue, 27 Dec 2022 22:54:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyJeOkbttspCDnSByL/nCQ2JjVAXV9FDqAy94y6/k0y74Mq/sOxj2N1C6K16hnSy1PLHND X-Received: by 2002:a17:902:a98a:b0:189:cef2:88e3 with SMTP id bh10-20020a170902a98a00b00189cef288e3mr25922892plb.57.1672210458108; Tue, 27 Dec 2022 22:54:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672210458; cv=none; d=google.com; s=arc-20160816; b=FK+asws930Y8YTwKebVElzGRDzMUmOBOfdnFMSzQYq2a5EIEHtzAWoOgWqDKJUTSwB NxjCgP2KO+lr9Iei1ZVLIECD1qvfl2rNUY9F9LorqJr9wF7NPbspjS2O5OYKhGNHqT8z EPJPu7N/0KrJlQltnKDgmjCj93mnL7bkYPpLuPBVfKk2fwh46jJeX/F2t6W40FwRZqSE YEX4wMgS5BM2fvuwxqL/gtbK0jOMWiyPnEj5+wy2qiJVoC3Wfhorvr0eB4/KIsROLx3T yvXoy0qvuctpPPDsCTlMlbS7D8JC0svMXK/3FB9sCLbp4qEPUfM7WLdBYU6M34gpcAvQ hpyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=BKQnx3lqI8J/ywBQvDRlys+9FKkDR0+iinXdJ3yuVUY=; b=b/uv7K8uSRIDTP0/4Wd+6aGBXdc777muUqyJIAG7TD+mDGaQnPAf7nEZ0qiN/wkQVu SFdgFGOErOAJSvjAvUwgK7kcuXH3Mkd+eale+0ueGFzMn+XegVChxtJbSFNKqeYnVxuu RkHd58L+E3Fk3WBW0n27R4HP3ONRJ/gdr0HDkvQJ1UypjTDdfcPKXxuXRuS1jpiJzgma bYZJJ+2FyATQRG1jYgTjfjb3wT/SBy71HXsk6Te/4XbnMnu/o6szOZIAUYLGDdFJcTjK N5A8QOf8l2xi+1MG0EiRDl6YPZ7lYbw2RP/boc/j2AkjQUNJrbDrljo/Jzr0eMuobUvT YFHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MST+jMxm; 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 f6-20020a170902ce8600b0018938988ea9si18039618plg.520.2022.12.27.22.54.08; Tue, 27 Dec 2022 22:54: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=MST+jMxm; 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 S229806AbiL1GfV (ORCPT + 66 others); Wed, 28 Dec 2022 01:35:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiL1GfQ (ORCPT ); Wed, 28 Dec 2022 01:35:16 -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 C7AB7DF52 for ; Tue, 27 Dec 2022 22:34:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672209268; 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=BKQnx3lqI8J/ywBQvDRlys+9FKkDR0+iinXdJ3yuVUY=; b=MST+jMxmAbTPXxkmxmTNUklqACHsml94KWyypx2iAB1BruRWIJR26ohq/t85R6E70OhDJl MJ+89FJa0lrHSSh7rJ8QkrAMpsgMN/Zt8EMoQ0vRLXMHVrM4bVwYtngAVFnl87IgwrdR99 RLxGTGmtJqNs+Za3NVquI4wOd4EQGBs= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-178-hkBZy_9FMU6XQa665BjFMg-1; Wed, 28 Dec 2022 01:34:26 -0500 X-MC-Unique: hkBZy_9FMU6XQa665BjFMg-1 Received: by mail-pf1-f197.google.com with SMTP id n22-20020a62e516000000b005817b3a197aso1384719pff.14 for ; Tue, 27 Dec 2022 22:34:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BKQnx3lqI8J/ywBQvDRlys+9FKkDR0+iinXdJ3yuVUY=; b=vT0UZj0YLw2t/TMCVD+8xDcP47ILmicfm3dcnV/Ho3J6TWH2vQmgCCBT5toY19aJbx tCo+iYa/DBvyK+GfjGg/j6BUO78fUnT+GerRgMGayoXT/KendxhI3BIjgFs0eBtlMeyG ld6DPEw5WcVG2+gH4CdBdzZqPyiOeyUFnRvW5hHFFsiOYNHJVppxSgjntl9bWWUABxR3 pxYdkmhvBjBChRY74PuJCvGjxsjsmoPViB4Nn4hD25kuoWZPqVclOrTczjVCcN4G5RAZ /mJt4Zdudl0BZ9b8/SBE7zK7Ds3P6F7og38SG/SEh0GyQvqHc1/NE6taPQSVOPlA8th5 mnVA== X-Gm-Message-State: AFqh2kqIZ3zypgA7Z/HAx675jIVovFnDyj93Bj62wSDuS1TroqkOTKOB fXcZYGyCGW85JIjkDVw8Ttw1yqERgg8rvlBAbJHCzQnC3tmOjfykkRAdocVLnkMprS9Hf9ZTiC+ C2fUMtmQsJCQInz8LFb1jyWYJ X-Received: by 2002:a17:903:228a:b0:191:217f:b2ea with SMTP id b10-20020a170903228a00b00191217fb2eamr37690872plh.40.1672209265595; Tue, 27 Dec 2022 22:34:25 -0800 (PST) X-Received: by 2002:a17:903:228a:b0:191:217f:b2ea with SMTP id b10-20020a170903228a00b00191217fb2eamr37690862plh.40.1672209265370; Tue, 27 Dec 2022 22:34:25 -0800 (PST) Received: from [10.72.13.7] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y7-20020a17090322c700b00188a7bce192sm10157311plg.264.2022.12.27.22.34.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Dec 2022 22:34:25 -0800 (PST) Message-ID: <0d9f1b89-9374-747b-3fb0-b4b28ad0ace1@redhat.com> Date: Wed, 28 Dec 2022 14:34:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH 3/4] virtio_ring: introduce a per virtqueue waitqueue Content-Language: en-US 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 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> From: Jason Wang In-Reply-To: <20221227043148-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 在 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. >> >> >>> 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 > >>>