On Thu, 25 Sep 2025 18:37:01 +0800
Jason Wang <[email protected]> wrote:

> Use u16 for last_used_idx in virtqueue_poll_split() to align with the
> spec.

If you care about performance you should pretty much never use 'u16' for
function parameters, return values or any arithmetic.
Just because the domain of the variable is [0..65535] doesn't mean that
'unsigned int' isn't the correct type.

> 
> Acked-by: Eugenio PĂ©rez <[email protected]>
> Reviewed-by: Xuan Zhuo <[email protected]>
> Signed-off-by: Jason Wang <[email protected]>
> ---
>  drivers/virtio/virtio_ring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 58c03a8aab85..4679a027dc53 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -806,7 +806,7 @@ static void detach_buf_split(struct vring_virtqueue *vq, 
> unsigned int head,
>  }
>  
>  static bool virtqueue_poll_split(const struct vring_virtqueue *vq,
> -                              unsigned int last_used_idx)
> +                              u16 last_used_idx)
>  {
>       return (u16)last_used_idx != virtio16_to_cpu(vq->vq.vdev,

You can't want that (u16) cast now, I doubt it was ever needed.
Note that the compiler promotes the value to 'signed int',
so the LHS of the comparison is actually (int)(u16)last_used_idx.

        David

>                       vq->split.vring.used->idx);


Reply via email to