All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Zhu, Lingshan" <lingshan.zhu@intel.com>
Cc: mst <mst@redhat.com>,
	virtualization <virtualization@lists.linux-foundation.org>,
	netdev <netdev@vger.kernel.org>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] vDPA/ifcvf: assign nr_vring to the MSI vector of config_intr by default
Date: Fri, 15 Apr 2022 13:51:16 +0800	[thread overview]
Message-ID: <CACGkMEuLW_PypyiPVcNz-B5FWNpkzLWwzC0eaZsCih+PbNt3Cg@mail.gmail.com> (raw)
In-Reply-To: <09a3613f-514b-c769-b8a0-25899b3d3159@intel.com>

On Wed, Apr 13, 2022 at 5:16 PM Zhu, Lingshan <lingshan.zhu@intel.com> wrote:
>
>
>
> On 4/13/2022 4:14 PM, Jason Wang wrote:
> >
> > 在 2022/4/8 下午8:10, Zhu Lingshan 写道:
> >> This commit assign struct ifcvf_hw.nr_vring to the MSIX vector of the
> >> config interrupt by default in ifcvf_request_config_irq().
> >> ifcvf_hw.nr_vring is the most likely and the ideal case for
> >> the device config interrupt handling, means every virtqueue has
> >> an individual MSIX vector(0 ~ nr_vring - 1), and the config interrupt
> >> has
> >> its own MSIX vector(number nr_vring).
> >>
> >> This change can also make GCC W = 2 happy, silence the
> >> "uninitialized" warning.
> >>
> >> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> >> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> >> ---
> >>   drivers/vdpa/ifcvf/ifcvf_main.c | 8 ++++----
> >>   1 file changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c
> >> b/drivers/vdpa/ifcvf/ifcvf_main.c
> >> index 4366320fb68d..b500fb941dab 100644
> >> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
> >> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
> >> @@ -290,13 +290,13 @@ static int ifcvf_request_config_irq(struct
> >> ifcvf_adapter *adapter)
> >>       struct ifcvf_hw *vf = &adapter->vf;
> >>       int config_vector, ret;
> >>   +    /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector
> >> for config interrupt */
> >
> >
> > The comment is right before this patch, but probably wrong for
> > MSIX_VECTOR_DEV_SHARED.
> This comment is for the case when every vq and config interrupt has its
> own vector, how
> about a better comment "The ideal the default case, vector 0 ~
> vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt"

Actually, I suggest to remove the comment since the code can explain itself.

> >
> >
> >> +    config_vector = vf->nr_vring;
> >> +
> >> +    /* re-use the vqs vector */
> >>       if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
> >>           return 0;
> >>   -    if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
> >> -        /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector
> >> for config interrupt */
> >> -        config_vector = vf->nr_vring;
> >> -
> >>       if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
> >>           /* vector 0 for vqs and 1 for config interrupt */
> >>           config_vector = 1;
> >
> >
> > Actually, I prefer to use if ... else ... here.
> IMHO, if else may lead to mistakes.
>
> The code:
>          /* The ideal the default case, vector 0 ~ vf->nr_vring for vqs,
> num vf->nr_vring vector for config interrupt */
>          config_vector = vf->nr_vring;
>
>          /* re-use the vqs vector */
>          if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
>                  return 0;
>
>          if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
>                  /* vector 0 for vqs and 1 for config interrupt */
>                  config_vector = 1;
>
>
> here by default config_vector = vf->nr_vring;
> If msix_vector_status == MSIX_VECTOR_DEV_SHARED, it will reuse the dev
> shared vector, means using the vector(value 0) for data-vqs.
> If msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG, it will use
> vector=1(vector 0 for data-vqs).
>
> If we use if...else, it will be:
>
>          /* re-use the vqs vector */
>          if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
>                  return 0;
>          else
>                  config_vector = 1;
>
> This looks like config_vector can only be 0(re-used vector for the
> data-vqs, which is 0) or 1. It shadows the ideal and default case
> config_vector = vf->nr_vring

I meant something like

if (DEV_SHARED)
    return 0;
else if  (SHARED_VQ_AND_CONFIG)
    config_vector = 1
else if (PER_VQ_AND_CONFIG)
    config_vector = vf->nr_vring
else
    return -EINVAL;

or using a switch here.

(We get the warning because there's no way for the checker to know
that msix_vector_status must be DEV_SHARED, SHARED_VQ_AND_CONFIG and
PER_VQ_AND_CONFIG).

Thanks

>
> Thanks,
> Zhu Lingshan
>
> >
> > Thanks
> >
> >
>


WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: "Zhu, Lingshan" <lingshan.zhu@intel.com>
Cc: netdev <netdev@vger.kernel.org>,
	virtualization <virtualization@lists.linux-foundation.org>,
	Dan Carpenter <dan.carpenter@oracle.com>, mst <mst@redhat.com>
Subject: Re: [PATCH] vDPA/ifcvf: assign nr_vring to the MSI vector of config_intr by default
Date: Fri, 15 Apr 2022 13:51:16 +0800	[thread overview]
Message-ID: <CACGkMEuLW_PypyiPVcNz-B5FWNpkzLWwzC0eaZsCih+PbNt3Cg@mail.gmail.com> (raw)
In-Reply-To: <09a3613f-514b-c769-b8a0-25899b3d3159@intel.com>

On Wed, Apr 13, 2022 at 5:16 PM Zhu, Lingshan <lingshan.zhu@intel.com> wrote:
>
>
>
> On 4/13/2022 4:14 PM, Jason Wang wrote:
> >
> > 在 2022/4/8 下午8:10, Zhu Lingshan 写道:
> >> This commit assign struct ifcvf_hw.nr_vring to the MSIX vector of the
> >> config interrupt by default in ifcvf_request_config_irq().
> >> ifcvf_hw.nr_vring is the most likely and the ideal case for
> >> the device config interrupt handling, means every virtqueue has
> >> an individual MSIX vector(0 ~ nr_vring - 1), and the config interrupt
> >> has
> >> its own MSIX vector(number nr_vring).
> >>
> >> This change can also make GCC W = 2 happy, silence the
> >> "uninitialized" warning.
> >>
> >> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> >> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> >> ---
> >>   drivers/vdpa/ifcvf/ifcvf_main.c | 8 ++++----
> >>   1 file changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c
> >> b/drivers/vdpa/ifcvf/ifcvf_main.c
> >> index 4366320fb68d..b500fb941dab 100644
> >> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
> >> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
> >> @@ -290,13 +290,13 @@ static int ifcvf_request_config_irq(struct
> >> ifcvf_adapter *adapter)
> >>       struct ifcvf_hw *vf = &adapter->vf;
> >>       int config_vector, ret;
> >>   +    /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector
> >> for config interrupt */
> >
> >
> > The comment is right before this patch, but probably wrong for
> > MSIX_VECTOR_DEV_SHARED.
> This comment is for the case when every vq and config interrupt has its
> own vector, how
> about a better comment "The ideal the default case, vector 0 ~
> vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt"

Actually, I suggest to remove the comment since the code can explain itself.

> >
> >
> >> +    config_vector = vf->nr_vring;
> >> +
> >> +    /* re-use the vqs vector */
> >>       if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
> >>           return 0;
> >>   -    if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
> >> -        /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector
> >> for config interrupt */
> >> -        config_vector = vf->nr_vring;
> >> -
> >>       if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
> >>           /* vector 0 for vqs and 1 for config interrupt */
> >>           config_vector = 1;
> >
> >
> > Actually, I prefer to use if ... else ... here.
> IMHO, if else may lead to mistakes.
>
> The code:
>          /* The ideal the default case, vector 0 ~ vf->nr_vring for vqs,
> num vf->nr_vring vector for config interrupt */
>          config_vector = vf->nr_vring;
>
>          /* re-use the vqs vector */
>          if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
>                  return 0;
>
>          if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
>                  /* vector 0 for vqs and 1 for config interrupt */
>                  config_vector = 1;
>
>
> here by default config_vector = vf->nr_vring;
> If msix_vector_status == MSIX_VECTOR_DEV_SHARED, it will reuse the dev
> shared vector, means using the vector(value 0) for data-vqs.
> If msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG, it will use
> vector=1(vector 0 for data-vqs).
>
> If we use if...else, it will be:
>
>          /* re-use the vqs vector */
>          if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
>                  return 0;
>          else
>                  config_vector = 1;
>
> This looks like config_vector can only be 0(re-used vector for the
> data-vqs, which is 0) or 1. It shadows the ideal and default case
> config_vector = vf->nr_vring

I meant something like

if (DEV_SHARED)
    return 0;
else if  (SHARED_VQ_AND_CONFIG)
    config_vector = 1
else if (PER_VQ_AND_CONFIG)
    config_vector = vf->nr_vring
else
    return -EINVAL;

or using a switch here.

(We get the warning because there's no way for the checker to know
that msix_vector_status must be DEV_SHARED, SHARED_VQ_AND_CONFIG and
PER_VQ_AND_CONFIG).

Thanks

>
> Thanks,
> Zhu Lingshan
>
> >
> > Thanks
> >
> >
>

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

  reply	other threads:[~2022-04-15  5:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 12:10 [PATCH] vDPA/ifcvf: assign nr_vring to the MSI vector of config_intr by default Zhu Lingshan
2022-04-13  8:14 ` Jason Wang
2022-04-13  8:14   ` Jason Wang
2022-04-13  9:16   ` Zhu, Lingshan
2022-04-15  5:51     ` Jason Wang [this message]
2022-04-15  5:51       ` 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=CACGkMEuLW_PypyiPVcNz-B5FWNpkzLWwzC0eaZsCih+PbNt3Cg@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=lingshan.zhu@intel.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --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.