All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtualization <virtualization@lists.linux-foundation.org>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] vdpa_sim_blk: limit the number of request handled per batch
Date: Thu, 23 Jun 2022 10:58:30 +0200	[thread overview]
Message-ID: <20220623085830.voi6gixpikz64nm2@sgarzare-redhat> (raw)
In-Reply-To: <CACGkMEsk-O=dVwKoEHRY-nL3XEQktPWiBot2NfOUYNdkoL-s=Q@mail.gmail.com>

On Thu, Jun 23, 2022 at 11:50:22AM +0800, Jason Wang wrote:
>On Wed, Jun 22, 2022 at 12:09 AM Stefano Garzarella <sgarzare@redhat.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@redhat.com>
>> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
>> ---
>>  drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 15 ++++++++++++++-
>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
>> index a83a5c76f620..ac86478845b6 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,11 +207,15 @@ 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];
>> +               bool vq_work = true;
>> +               int reqs = 0;
>>
>>                 if (!vq->ready)
>>                         continue;
>>
>> -               while (vdpasim_blk_handle_req(vdpasim, vq)) {
>> +               while (vq_work) {
>> +                       vq_work = vdpasim_blk_handle_req(vdpasim, vq);
>> +
>
>Is it better to check and exit the loop early here?

Maybe, but I'm not sure.

In vdpa_sim_net we call vringh_complete_iotlb() and send notification 
also in the error path, so I thought was better to send notification 
also when vdpasim_blk_handle_req() return false, since we will update 
the used.idx.

However, I don't think it's a common path, so if you think it's better 
to exit the loop early, I can do it.

Thanks,
Stefano


WARNING: multiple messages have this Message-ID (diff)
From: Stefano Garzarella <sgarzare@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: "Eugenio Pérez" <eperezma@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	virtualization <virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH 2/3] vdpa_sim_blk: limit the number of request handled per batch
Date: Thu, 23 Jun 2022 10:58:30 +0200	[thread overview]
Message-ID: <20220623085830.voi6gixpikz64nm2@sgarzare-redhat> (raw)
In-Reply-To: <CACGkMEsk-O=dVwKoEHRY-nL3XEQktPWiBot2NfOUYNdkoL-s=Q@mail.gmail.com>

On Thu, Jun 23, 2022 at 11:50:22AM +0800, Jason Wang wrote:
>On Wed, Jun 22, 2022 at 12:09 AM Stefano Garzarella <sgarzare@redhat.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@redhat.com>
>> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
>> ---
>>  drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 15 ++++++++++++++-
>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
>> index a83a5c76f620..ac86478845b6 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,11 +207,15 @@ 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];
>> +               bool vq_work = true;
>> +               int reqs = 0;
>>
>>                 if (!vq->ready)
>>                         continue;
>>
>> -               while (vdpasim_blk_handle_req(vdpasim, vq)) {
>> +               while (vq_work) {
>> +                       vq_work = vdpasim_blk_handle_req(vdpasim, vq);
>> +
>
>Is it better to check and exit the loop early here?

Maybe, but I'm not sure.

In vdpa_sim_net we call vringh_complete_iotlb() and send notification 
also in the error path, so I thought was better to send notification 
also when vdpasim_blk_handle_req() return false, since we will update 
the used.idx.

However, I don't think it's a common path, so if you think it's better 
to exit the loop early, I can do it.

Thanks,
Stefano

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2022-06-23  8:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 16:08 [PATCH 0/3] vdpa_sim_blk: several fixes for the vDPA block simulator Stefano Garzarella
2022-06-21 16:08 ` Stefano Garzarella
2022-06-21 16:08 ` [PATCH 1/3] vdpa_sim_blk: use dev_dbg() to print errors Stefano Garzarella
2022-06-21 16:08   ` Stefano Garzarella
2022-06-23  3:40   ` Jason Wang
2022-06-23  3:40     ` Jason Wang
2022-06-21 16:08 ` [PATCH 2/3] vdpa_sim_blk: limit the number of request handled per batch Stefano Garzarella
2022-06-21 16:08   ` Stefano Garzarella
2022-06-23  3:50   ` Jason Wang
2022-06-23  3:50     ` Jason Wang
2022-06-23  8:58     ` Stefano Garzarella [this message]
2022-06-23  8:58       ` Stefano Garzarella
2022-06-28  4:01       ` Jason Wang
2022-06-28  4:01         ` Jason Wang
2022-06-28  7:55         ` Stefano Garzarella
2022-06-28  7:55           ` Stefano Garzarella
2022-06-21 16:12 ` [PATCH 3/3] vdpa_sim_blk: call vringh_complete_iotlb() also in the error path Stefano Garzarella
2022-06-21 16:12   ` Stefano Garzarella
2022-06-23  3:52   ` Jason Wang
2022-06-23  3:52     ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220623085830.voi6gixpikz64nm2@sgarzare-redhat \
    --to=sgarzare@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.