Jakub Sitnicki
2023-Oct-19 10:16 UTC
[PATCH 1/2] virtio_pci: Don't make an extra copy of cpu affinity mask
Since commit 19e226e8cc5d ("virtio: Make vp_set_vq_affinity() take a mask.") it is actually not needed to have a local copy of the cpu mask. Pass the cpu mask we got as argument to set the irq affinity hint. Cc: Caleb Raitto <caraitto at google.com> Signed-off-by: Jakub Sitnicki <jakub at cloudflare.com> --- drivers/virtio/virtio_pci_common.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index c2524a7207cf..8927bc338f06 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -433,21 +433,14 @@ int vp_set_vq_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask) struct virtio_device *vdev = vq->vdev; struct virtio_pci_device *vp_dev = to_vp_device(vdev); struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index]; - struct cpumask *mask; unsigned int irq; if (!vq->callback) return -EINVAL; if (vp_dev->msix_enabled) { - mask = vp_dev->msix_affinity_masks[info->msix_vector]; irq = pci_irq_vector(vp_dev->pci_dev, info->msix_vector); - if (!cpu_mask) - irq_set_affinity_hint(irq, NULL); - else { - cpumask_copy(mask, cpu_mask); - irq_set_affinity_hint(irq, mask); - } + irq_set_affinity_hint(irq, cpu_mask); } return 0; } -- 2.41.0
Jakub Sitnicki
2023-Oct-19 10:16 UTC
[PATCH 2/2] virtio_pci: Switch away from deprecated irq_set_affinity_hint
Since commit 65c7cdedeb30 ("genirq: Provide new interfaces for affinity hints") irq_set_affinity_hint is being phased out. Switch to new interfaces for setting and applying irq affinity hints. Signed-off-by: Jakub Sitnicki <jakub at cloudflare.com> --- drivers/virtio/virtio_pci_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 8927bc338f06..9fab99b540f1 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -242,7 +242,7 @@ void vp_del_vqs(struct virtio_device *vdev) if (v != VIRTIO_MSI_NO_VECTOR) { int irq = pci_irq_vector(vp_dev->pci_dev, v); - irq_set_affinity_hint(irq, NULL); + irq_update_affinity_hint(irq, NULL); free_irq(irq, vq); } } @@ -440,7 +440,7 @@ int vp_set_vq_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask) if (vp_dev->msix_enabled) { irq = pci_irq_vector(vp_dev->pci_dev, info->msix_vector); - irq_set_affinity_hint(irq, cpu_mask); + irq_set_affinity_and_hint(irq, cpu_mask); } return 0; } -- 2.41.0
Xuan Zhuo
2023-Oct-19 12:55 UTC
[PATCH 1/2] virtio_pci: Don't make an extra copy of cpu affinity mask
On Thu, 19 Oct 2023 12:16:24 +0200, Jakub Sitnicki <jakub at cloudflare.com> wrote:> Since commit 19e226e8cc5d ("virtio: Make vp_set_vq_affinity() take a > mask.") it is actually not needed to have a local copy of the cpu mask.Could you give more info to prove this? If you are right, I think you should delete all code about msix_affinity_masks? Thanks.> > Pass the cpu mask we got as argument to set the irq affinity hint. > > Cc: Caleb Raitto <caraitto at google.com> > Signed-off-by: Jakub Sitnicki <jakub at cloudflare.com> > --- > drivers/virtio/virtio_pci_common.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c > index c2524a7207cf..8927bc338f06 100644 > --- a/drivers/virtio/virtio_pci_common.c > +++ b/drivers/virtio/virtio_pci_common.c > @@ -433,21 +433,14 @@ int vp_set_vq_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask) > struct virtio_device *vdev = vq->vdev; > struct virtio_pci_device *vp_dev = to_vp_device(vdev); > struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index]; > - struct cpumask *mask; > unsigned int irq; > > if (!vq->callback) > return -EINVAL; > > if (vp_dev->msix_enabled) { > - mask = vp_dev->msix_affinity_masks[info->msix_vector]; > irq = pci_irq_vector(vp_dev->pci_dev, info->msix_vector); > - if (!cpu_mask) > - irq_set_affinity_hint(irq, NULL); > - else { > - cpumask_copy(mask, cpu_mask); > - irq_set_affinity_hint(irq, mask); > - } > + irq_set_affinity_hint(irq, cpu_mask); > } > return 0; > } > -- > 2.41.0 >