Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1101950pxb; Thu, 24 Mar 2022 12:45:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdrF0PdIIUmsXUuzrdLmzZRtFZm1w4EDHQEmsFaCJaxEcyTJ0juOM4CPiCY6niEvIJjWA7 X-Received: by 2002:a17:907:6d9b:b0:6db:8eab:94e0 with SMTP id sb27-20020a1709076d9b00b006db8eab94e0mr7378648ejc.687.1648151156438; Thu, 24 Mar 2022 12:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648151156; cv=none; d=google.com; s=arc-20160816; b=FY5+zmsqZKDGmtEauVyVr1mOrTmKyCXRzs6JGA9Vhw9/2c31TWdkqJSFrZSZ3/H7GX /YkbYa8iaSMMm61Dd64LvFrSD09f/NU1R1rAPGqUu5xAsRy+D3sJNI5I+JoFis5hnw2P 3fxv5TzeUx43yvm4kDH9tQUUJcuNqx5qhjEExhB7J1R0CUKwZcrPRQoKNuCab1HkyHO1 Q+uHrYslcFZ/Kb8JjjTIn+QS6Pssp/m7uegD3T6n+a8Q7AFneP84jAEcjzNy2XGMwi9N O/msnCcE1RYckSqnpQdQ90b2B/VRtbzOPuXaTxqHqOJturzF/Ahd0ZTowlPe5vspCFSK ZlsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WqYtQSBegGxeYkN/lgul0x/vukAzbn7E8fW29poebx4=; b=gfdRKF+nY31QBABFxHFgyaaBxc6r4R0ZiGM4KPidju2/wYpoTMfc9cneJk8xZjXwH5 Y4FxzUIlytzFo1YhrIHTaXdsZ3CVpNLS7yKVSJUEy1xL4nB3B0Mgzg6rD2ykELVJEGry l8Ip9get2VBWMi4mHGzs+Adq/60dCEq0NrUjGpbuhmKKDFYPKrvq6fx9/5WT1TBu/CN4 5K3cvRT4P69nQxrOF6jfuUOoSEswyzSTTk0kfUoScANPpGB1mMODj5XELnLdcMr9fncp /vEGzuO8y5yuXzwmecMBADxGvUvcCz+rJgLuuxByKojkX9Wv2wtvU6DG2vP3bcDvzqoH cUow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PguHiOGv; 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 j22-20020a056402239600b004190569130dsi741991eda.167.2022.03.24.12.45.30; Thu, 24 Mar 2022 12:45:56 -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=PguHiOGv; 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 S1348872AbiCXIWX (ORCPT + 99 others); Thu, 24 Mar 2022 04:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240325AbiCXIWV (ORCPT ); Thu, 24 Mar 2022 04:22:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 514F09284B for ; Thu, 24 Mar 2022 01:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648110049; 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: in-reply-to:in-reply-to:references:references; bh=WqYtQSBegGxeYkN/lgul0x/vukAzbn7E8fW29poebx4=; b=PguHiOGvxWhcuQjup2jN0A2xmzWb3mTXV4zlW/VpGD8RLwe7ECoraSDos/gnEzOV67CB3r a0r10xHXq3+bOUIoPP8Gv1MG9mCkg7BVXrCeXKi/x+RKGj2t2DBzuqsWAe/nvVrth7QRSZ I0EsdS9feZNzV3Mo9C4xgT5QXJwRnoI= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-jSCATG8cPkWXfhy8-bBTCg-1; Thu, 24 Mar 2022 04:20:48 -0400 X-MC-Unique: jSCATG8cPkWXfhy8-bBTCg-1 Received: by mail-lf1-f72.google.com with SMTP id bt40-20020a056512262800b004481fbe2d29so1473882lfb.16 for ; Thu, 24 Mar 2022 01:20:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WqYtQSBegGxeYkN/lgul0x/vukAzbn7E8fW29poebx4=; b=SOHBk5iNpB2yx8MfTvgf0K7EGHf9rXViQPJPwZgwHP1ZgMoIqtHUTM39XV1gIykSOt +UYn0lxQhkGgxQaUZrSA+zlnLIsjhCbk0+UPVXOrGA5hyf9w/kXIIAuYf8PH9NvbataV jQWIz4w1WpONMSq0ULaApzkqhNkyRrc8wM1gjr2jsJxqZ9lgG8ol0hD9+2sntyUzvo/7 dERBnCW409G+Qr83bdllRPHI+sbZ8Mq1U6MLA9N+gOISV23HNiGYtUL3grbzfVISA4q8 CJU9IptplaD08nw9a6ORmBCszd54Wu5GDXyOTl6xBxPkoo2wk1hQPbQ+OtEV6BioTmek vXJA== X-Gm-Message-State: AOAM533u1pWO5x7MDKPUehAtoUW4mm2nqjw8nBmiJlNabrqTlRDGp2c2 oiWD5XABiLaIbBImRGqXoONC4yG3wK9DFpd2DDMfLwwEk6taeL/h/wN9RH3thJ8Apbj6ahPTH+Q 8F+ildIDvhaMLRb5Ul39TzxV4z0bY/nCXerTXB9Uv X-Received: by 2002:a05:6512:108a:b0:448:756a:f5fb with SMTP id j10-20020a056512108a00b00448756af5fbmr3005740lfg.587.1648110046271; Thu, 24 Mar 2022 01:20:46 -0700 (PDT) X-Received: by 2002:a05:6512:108a:b0:448:756a:f5fb with SMTP id j10-20020a056512108a00b00448756af5fbmr3005727lfg.587.1648110046028; Thu, 24 Mar 2022 01:20:46 -0700 (PDT) MIME-Version: 1.0 References: <20220321060429.10457-1-jasowang@redhat.com> <20220321085317.3148-1-hdanton@sina.com> <20220321123420.3207-1-hdanton@sina.com> <20220324005345.3623-1-hdanton@sina.com> <20220324060419.3682-1-hdanton@sina.com> <20220324021428-mutt-send-email-mst@kernel.org> In-Reply-To: <20220324021428-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Thu, 24 Mar 2022 16:20:34 +0800 Message-ID: Subject: Re: [PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU To: "Michael S. Tsirkin" Cc: Hillf Danton , Eli Cohen , virtualization , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.3 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Thu, Mar 24, 2022 at 2:17 PM Michael S. Tsirkin wrote: > > On Thu, Mar 24, 2022 at 02:04:19PM +0800, Hillf Danton wrote: > > On Thu, 24 Mar 2022 10:34:09 +0800 Jason Wang wrote: > > > On Thu, Mar 24, 2022 at 8:54 AM Hillf Danton wrote: > > > > > > > > On Tue, 22 Mar 2022 09:59:14 +0800 Jason Wang wrote: > > > > > > > > > > Yes, there will be no "infinite" loop, but since the loop is triggered > > > > > by userspace. It looks to me it will delay the flush/drain of the > > > > > workqueue forever which is still suboptimal. > > > > > > > > Usually it is barely possible to shoot two birds using a stone. > > > > > > > > Given the "forever", I am inclined to not running faster, hehe, though > > > > another cobble is to add another line in the loop checking if mvdev is > > > > unregistered, and for example make mvdev->cvq unready before destroying > > > > workqueue. > > > > > > > > static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *dev) > > > > { > > > > struct mlx5_vdpa_mgmtdev *mgtdev = container_of(v_mdev, struct mlx5_vdpa_mgmtdev, mgtdev); > > > > struct mlx5_vdpa_dev *mvdev = to_mvdev(dev); > > > > struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); > > > > > > > > mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); > > > > destroy_workqueue(mvdev->wq); > > > > _vdpa_unregister_device(dev); > > > > mgtdev->ndev = NULL; > > > > } > > > > > > > > > > Yes, so we had > > > > > > 1) using a quota for re-requeue > > > 2) using something like > > > > > > while (READ_ONCE(cvq->ready)) { > > > ... > > > cond_resched(); > > > } > > > > > > There should not be too much difference except we need to use > > > cancel_work_sync() instead of flush_work for 1). > > > > > > I would keep the code as is but if you stick I can change. > > > > No Sir I would not - I am simply not a fan of work requeue. > > > > Hillf > > I think I agree - requeue adds latency spikes under heavy load - > unfortunately, not measured by netperf but still important > for latency sensitive workloads. Checking a flag is cheaper. Just spot another possible issue. The workqueue will be used by another work to update the carrier (event_handler()). Using cond_resched() may still have unfair issue which blocks the carrier update for infinite time, Thanks > > -- > MST >