| 497 | */ |
| 498 | #ifdef RTE_LIBRTE_VHOST_NUMA |
| 499 | static void |
| 500 | numa_realloc(struct virtio_net **pdev, struct vhost_virtqueue **pvq) |
| 501 | { |
| 502 | int node, dev_node; |
| 503 | struct virtio_net *dev; |
| 504 | struct vhost_virtqueue *vq; |
| 505 | struct batch_copy_elem *bce; |
| 506 | struct guest_page *gp; |
| 507 | struct rte_vhost_memory *mem; |
| 508 | size_t mem_size; |
| 509 | int ret; |
| 510 | |
| 511 | dev = *pdev; |
| 512 | vq = *pvq; |
| 513 | |
| 514 | /* |
| 515 | * If VQ is ready, it is too late to reallocate, it certainly already |
| 516 | * happened anyway on VHOST_USER_SET_VRING_ADRR. |
| 517 | */ |
| 518 | if (vq->ready) |
| 519 | return; |
| 520 | |
| 521 | ret = get_mempolicy(&node, NULL, 0, vq->desc, MPOL_F_NODE | MPOL_F_ADDR); |
| 522 | if (ret) { |
| 523 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 524 | "unable to get virtqueue %d numa information.\n", |
| 525 | vq->index); |
| 526 | return; |
| 527 | } |
| 528 | |
| 529 | if (node == vq->numa_node) |
| 530 | goto out_dev_realloc; |
| 531 | |
| 532 | vq = rte_realloc_socket(*pvq, sizeof(**pvq), 0, node); |
| 533 | if (!vq) { |
| 534 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 535 | "failed to realloc virtqueue %d on node %d\n", |
| 536 | (*pvq)->index, node); |
| 537 | return; |
| 538 | } |
| 539 | *pvq = vq; |
| 540 | |
| 541 | if (vq != dev->virtqueue[vq->index]) { |
| 542 | VHOST_LOG_CONFIG(dev->ifname, INFO, "reallocated virtqueue on node %d\n", node); |
| 543 | dev->virtqueue[vq->index] = vq; |
| 544 | } |
| 545 | |
| 546 | if (vq_is_packed(dev)) { |
| 547 | struct vring_used_elem_packed *sup; |
| 548 | |
| 549 | sup = rte_realloc_socket(vq->shadow_used_packed, vq->size * sizeof(*sup), |
| 550 | RTE_CACHE_LINE_SIZE, node); |
| 551 | if (!sup) { |
| 552 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 553 | "failed to realloc shadow packed on node %d\n", |
| 554 | node); |
| 555 | return; |
| 556 | } |
no test coverage detected