lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 24 Mar 2022 12:24:19 +0000
From:   Eli Cohen <elic@...dia.com>
To:     Hillf Danton <hdanton@...a.com>, Jason Wang <jasowang@...hat.com>
CC:     "Michael S. Tsirkin" <mst@...hat.com>,
        virtualization <virtualization@...ts.linux-foundation.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU



> -----Original Message-----
> From: Hillf Danton <hdanton@...a.com>
> Sent: Thursday, March 24, 2022 2:02 PM
> To: Jason Wang <jasowang@...hat.com>
> Cc: Eli Cohen <elic@...dia.com>; Michael S. Tsirkin <mst@...hat.com>; virtualization <virtualization@...ts.linux-foundation.org>; linux-
> kernel <linux-kernel@...r.kernel.org>
> Subject: Re: [PATCH 1/2] vdpa: mlx5: prevent cvq work from hogging CPU
> 
> On Thu, 24 Mar 2022 16:20:34 +0800 Jason Wang wrote:
> > On Thu, Mar 24, 2022 at 2:17 PM Michael S. Tsirkin <mst@...hat.com> 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 <hdanton@...a.com> 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,
> 
> Then would you please specify the reason why mvdev->wq is single
> threaded? Given requeue, the serialization of the two works is not
> strong. Otherwise unbound WQ that can process works in parallel is
> a cure to the unfairness above.
> 

I think the proposed patch can still be used with quota equal to one.
That would guarantee fairness.
This is not performance critical and a single workqueue should be enough.

> Thanks
> Hillf

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ