Hillf Danton
2022-Mar-21 12:34 UTC
[PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU
On Mon, 21 Mar 2022 17:00:09 +0800 Jason Wang wrote:> > Ok, speak too fast.Frankly I have fun running faster five days a week.> So you meant to add a cond_resched() in the loop?Yes, it is one liner. Hillf
Jason Wang
2022-Mar-22 01:59 UTC
[PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU
On Mon, Mar 21, 2022 at 8:34 PM Hillf Danton <hdanton at sina.com> wrote:> > On Mon, 21 Mar 2022 17:00:09 +0800 Jason Wang wrote: > > > > Ok, speak too fast. > > Frankly I have fun running faster five days a week.:)> > > So you meant to add a cond_resched() in the loop? > > Yes, it is one liner.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. Thanks> > Hillf >
Hillf Danton
2022-Mar-24 00:53 UTC
[PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU
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; }