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-prev] [day] [month] [year] [list]
Message-ID: <CACGkMEtEDpX6QdBtqwx=eu-KpWEGRUZY9zuCJk1U+4Ht1TY4ZQ@mail.gmail.com>
Date:   Tue, 5 Jul 2022 11:11:30 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Stefano Garzarella <sgarzare@...hat.com>
Cc:     virtualization <virtualization@...ts.linux-foundation.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Eugenio Pérez <eperezma@...hat.com>
Subject: Re: [PATCH v2 2/3] vdpa_sim_blk: limit the number of request handled
 per batch

On Thu, Jun 30, 2022 at 11:32 PM Stefano Garzarella <sgarzare@...hat.com> wrote:
>
> Limit the number of requests (4 per queue as for vdpa_sim_net) handled
> in a batch to prevent the worker from using the CPU for too long.
>
> Suggested-by: Eugenio Pérez <eperezma@...hat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@...hat.com>

Acked-by: Jason Wang <jasowang@...hat.com>

> ---
> v2:
> - restored previous behaviour, exiting the loop immediately if the
>   request is malformed [Jason]
> ---
>  drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
> index a83a5c76f620..b2d75efec63a 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
> @@ -197,6 +197,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,
>  static void vdpasim_blk_work(struct work_struct *work)
>  {
>         struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);
> +       bool reschedule = false;
>         int i;
>
>         spin_lock(&vdpasim->lock);
> @@ -206,6 +207,7 @@ static void vdpasim_blk_work(struct work_struct *work)
>
>         for (i = 0; i < VDPASIM_BLK_VQ_NUM; i++) {
>                 struct vdpasim_virtqueue *vq = &vdpasim->vqs[i];
> +               int reqs = 0;
>
>                 if (!vq->ready)
>                         continue;
> @@ -218,10 +220,18 @@ static void vdpasim_blk_work(struct work_struct *work)
>                         if (vringh_need_notify_iotlb(&vq->vring) > 0)
>                                 vringh_notify(&vq->vring);
>                         local_bh_enable();
> +
> +                       if (++reqs > 4) {
> +                               reschedule = true;
> +                               break;
> +                       }
>                 }
>         }
>  out:
>         spin_unlock(&vdpasim->lock);
> +
> +       if (reschedule)
> +               schedule_work(&vdpasim->work);
>  }
>
>  static void vdpasim_blk_get_config(struct vdpasim *vdpasim, void *config)
> --
> 2.36.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ