Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1955892pxb; Fri, 25 Mar 2022 08:35:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXPiRI5ackDqUYaLk6OJuRC1mc1LvMZGfGBGu4pcJYOypzVZpGVf68O6G6Kzs5czr/ZX9q X-Received: by 2002:aa7:d74d:0:b0:419:1d7:adcc with SMTP id a13-20020aa7d74d000000b0041901d7adccmr13801435eds.407.1648222516716; Fri, 25 Mar 2022 08:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648222516; cv=none; d=google.com; s=arc-20160816; b=guxp3/RYflaNTFyXbGtAHP5YZKV+Ow9ntDEA24pQYfaL5JA2FBVQ7tyI66MfNkWOjd E1wJNsk+yiICJrDa2LC6E3DQaVw7gQEPSBYmkLabL+RRUwedIBZpZSYFS9j/M/Qd4PPI 8xvnCQ219gGiG9a20lzmW+1wWoySpg5n1HDcgvqtwmIiqNmPxopDiS9nXIui0oTfy3Bh Gcy0H7EIwXB/ZiIzgUIwgpHabjd48Y2QyTHJ7BHYvRjJCOaY+2G+Tp9e3p4UFO2hc/1u 7ypXNz6CMpvEUp2KOCy26ynyCF5CGREhSWJSWb2jDw39+uIGahn5hXGeTXVo7vU3NLSI nzHA== 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=wZgZoSoq2Ajh3ptSZyqEaLy0ew178lVliWAwMQIyGhQ=; b=gb7mVe5ErqqUNNHpqlooAHSx2vP7pcchXDbZEnYPqarSGZ8On3yr3GckjYZMpVrFc5 p9RoCXhuA7dJprwaS3qdnSh2e9UZe0dhCQPAn+DqR4Uyo8JTTcpL2XffX8dtJ6oCNl4G VRu/Iu4IH0R+L6bac9kMqRe++clWpIc92jSH5dx8iZ2lth4MKdxeip5THRoTtTaoVRcY nFyhebg/dstsWKaszJtLiAJb6BIFXL5rc9J9VUwOU4fyPW9DDCNJOPMUJz9n0DLEpRY4 2hKx0Py4cCuMoRvjSolpESlaLa6kgEmTx4psjelu2tfgSSAbG+gRfr3bkYoKhFRYYnMG wecA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cXjVBGwM; 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 f12-20020a170906390c00b006df76385e65si2495952eje.773.2022.03.25.08.34.50; Fri, 25 Mar 2022 08:35:16 -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=cXjVBGwM; 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 S1347772AbiCXCf5 (ORCPT + 99 others); Wed, 23 Mar 2022 22:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234745AbiCXCfz (ORCPT ); Wed, 23 Mar 2022 22:35:55 -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 0C2305F59 for ; Wed, 23 Mar 2022 19:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648089263; 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=wZgZoSoq2Ajh3ptSZyqEaLy0ew178lVliWAwMQIyGhQ=; b=cXjVBGwMv7vKbb3zUtHISghkILdKHR7FrkbyJWDLcBeZSaLMy2R88ODB9ofC+AtkbaEUyM kWZ1R79NhMu3mlfEMbDw3eEseBd8JlJmhrQRDNAXWwylPoxLqIl9LCDaBE6JQ0tXnAJMMV kRSXpgtLTNKTnk2w+1kVTOMjuUGY4JU= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-kEzCe9IWM5S_tY8L5S4Igw-1; Wed, 23 Mar 2022 22:34:22 -0400 X-MC-Unique: kEzCe9IWM5S_tY8L5S4Igw-1 Received: by mail-lf1-f69.google.com with SMTP id w13-20020ac25d4d000000b004488cf80eb1so1206015lfd.23 for ; Wed, 23 Mar 2022 19:34:22 -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=wZgZoSoq2Ajh3ptSZyqEaLy0ew178lVliWAwMQIyGhQ=; b=nyFjb/3mTYbPhvqrW8J4z05UU+QfEpLlCbqlXyHkEKCtMGpedxSGHghKq+P/oCLlbP MHx5n3/KSDVFXllT5izSB4AeuGE9O4Ro9uVyWjP3xQsI+27y9XVWxrhz/Qw/BqL0fkk2 aUmIdC+Ypgs8T7QaL6EzPNimVpVvxnBtV1ILlICQtvXf/WjuKAU8TkWsXfIcIDIR6/u/ f8x309b0ETsD2XPhOuHI5b1uG14x4G27FdCoR23kysRjJpWURUy/AockOZPzUKU6zRm3 E3Cbzj5TRcRX9OmaUeLbz42iUGmT7AszASXtk3Ci46Y1diF4EKUsKf2BvQYcZEYKBkWG rbzQ== X-Gm-Message-State: AOAM530AzhDSIYdauE5v0652Amu7z5yTVQHMpfNOV/1sNOg+uddOT1JO ubEYFkGDjOErWqBDc/jTjD5eW5rApGepfZwGnmRZ5dtsPkSFZLQo0JNUMhRBU140BzRHlZml+CQ qf+0XKcWT99Vn/mi+KHP0xjH3c/polhYeWzOQFgmu X-Received: by 2002:a05:6512:3341:b0:433:b033:bd22 with SMTP id y1-20020a056512334100b00433b033bd22mr2163467lfd.190.1648089260746; Wed, 23 Mar 2022 19:34:20 -0700 (PDT) X-Received: by 2002:a05:6512:3341:b0:433:b033:bd22 with SMTP id y1-20020a056512334100b00433b033bd22mr2163460lfd.190.1648089260578; Wed, 23 Mar 2022 19:34:20 -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> In-Reply-To: <20220324005345.3623-1-hdanton@sina.com> From: Jason Wang Date: Thu, 24 Mar 2022 10:34:09 +0800 Message-ID: Subject: Re: [PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU To: Hillf Danton Cc: mst , 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 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. Thanks