Skip to content

Commit

Permalink
vdpa/snet: use likely/unlikely macros in hot functions
Browse files Browse the repository at this point in the history
- kick callback: most likely that the VQ is ready.
- interrupt handlers: most likely that the callback is not NULL.

Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
Message-Id: <20230409120242.3460074-1-alvaro.karsz@solid-run.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Alvaro Karsz authored and Michael S. Tsirkin committed Apr 21, 2023
1 parent 51b6e6c commit 5b250fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/vdpa/solidrun/snet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static irqreturn_t snet_cfg_irq_hndlr(int irq, void *data)
{
struct snet *snet = data;
/* Call callback if any */
if (snet->cb.callback)
if (likely(snet->cb.callback))
return snet->cb.callback(snet->cb.private);

return IRQ_HANDLED;
Expand All @@ -49,7 +49,7 @@ static irqreturn_t snet_vq_irq_hndlr(int irq, void *data)
{
struct snet_vq *vq = data;
/* Call callback if any */
if (vq->cb.callback)
if (likely(vq->cb.callback))
return vq->cb.callback(vq->cb.private);

return IRQ_HANDLED;
Expand Down Expand Up @@ -106,7 +106,7 @@ static void snet_kick_vq(struct vdpa_device *vdev, u16 idx)
{
struct snet *snet = vdpa_to_snet(vdev);
/* not ready - ignore */
if (!snet->vqs[idx]->ready)
if (unlikely(!snet->vqs[idx]->ready))
return;

iowrite32(SNET_KICK_VAL, snet->vqs[idx]->kick_ptr);
Expand Down

0 comments on commit 5b250fa

Please sign in to comment.