Skip to content

Commit 78e8b5a

Browse files
committed
Merge: ice: XDP memory leak and other problems
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4922 JIRA: https://issues.redhat.com/browse/RHEL-15670 Backport Intel ice XDP flow control link state fixes. Signed-off-by: Petr Oros <poros@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 3e45fbd + 231b9d4 commit 78e8b5a

File tree

6 files changed

+135
-90
lines changed

6 files changed

+135
-90
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,18 +765,17 @@ static inline struct xsk_buff_pool *ice_get_xp_from_qid(struct ice_vsi *vsi,
765765
}
766766

767767
/**
768-
* ice_xsk_pool - get XSK buffer pool bound to a ring
768+
* ice_rx_xsk_pool - assign XSK buff pool to Rx ring
769769
* @ring: Rx ring to use
770770
*
771-
* Returns a pointer to xsk_buff_pool structure if there is a buffer pool
772-
* present, NULL otherwise.
771+
* Sets XSK buff pool pointer on Rx ring.
773772
*/
774-
static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_rx_ring *ring)
773+
static inline void ice_rx_xsk_pool(struct ice_rx_ring *ring)
775774
{
776775
struct ice_vsi *vsi = ring->vsi;
777776
u16 qid = ring->q_index;
778777

779-
return ice_get_xp_from_qid(vsi, qid);
778+
WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
780779
}
781780

782781
/**
@@ -801,7 +800,7 @@ static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
801800
if (!ring)
802801
return;
803802

804-
ring->xsk_pool = ice_get_xp_from_qid(vsi, qid);
803+
WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
805804
}
806805

807806
/**

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
536536
return err;
537537
}
538538

539-
ring->xsk_pool = ice_xsk_pool(ring);
539+
ice_rx_xsk_pool(ring);
540540
if (ring->xsk_pool) {
541541
xdp_rxq_info_unreg(&ring->xdp_rxq);
542542

@@ -597,7 +597,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
597597
return 0;
598598
}
599599

600-
ok = ice_alloc_rx_bufs_zc(ring, num_bufs);
600+
ok = ice_alloc_rx_bufs_zc(ring, ring->xsk_pool, num_bufs);
601601
if (!ok) {
602602
u16 pf_q = ring->vsi->rxq_map[ring->q_index];
603603

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2962,7 +2962,7 @@ static void ice_vsi_rx_napi_schedule(struct ice_vsi *vsi)
29622962
ice_for_each_rxq(vsi, i) {
29632963
struct ice_rx_ring *rx_ring = vsi->rx_rings[i];
29642964

2965-
if (rx_ring->xsk_pool)
2965+
if (READ_ONCE(rx_ring->xsk_pool))
29662966
napi_schedule(&rx_ring->q_vector->napi);
29672967
}
29682968
}

drivers/net/ethernet/intel/ice/ice_txrx.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void ice_free_rx_ring(struct ice_rx_ring *rx_ring)
456456
if (rx_ring->vsi->type == ICE_VSI_PF)
457457
if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq))
458458
xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
459-
rx_ring->xdp_prog = NULL;
459+
WRITE_ONCE(rx_ring->xdp_prog, NULL);
460460
if (rx_ring->xsk_pool) {
461461
kfree(rx_ring->xdp_buf);
462462
rx_ring->xdp_buf = NULL;
@@ -1521,10 +1521,11 @@ int ice_napi_poll(struct napi_struct *napi, int budget)
15211521
* budget and be more aggressive about cleaning up the Tx descriptors.
15221522
*/
15231523
ice_for_each_tx_ring(tx_ring, q_vector->tx) {
1524+
struct xsk_buff_pool *xsk_pool = READ_ONCE(tx_ring->xsk_pool);
15241525
bool wd;
15251526

1526-
if (tx_ring->xsk_pool)
1527-
wd = ice_xmit_zc(tx_ring);
1527+
if (xsk_pool)
1528+
wd = ice_xmit_zc(tx_ring, xsk_pool);
15281529
else if (ice_ring_is_xdp(tx_ring))
15291530
wd = true;
15301531
else
@@ -1550,14 +1551,15 @@ int ice_napi_poll(struct napi_struct *napi, int budget)
15501551
budget_per_ring = budget;
15511552

15521553
ice_for_each_rx_ring(rx_ring, q_vector->rx) {
1554+
struct xsk_buff_pool *xsk_pool = READ_ONCE(rx_ring->xsk_pool);
15531555
int cleaned;
15541556

15551557
/* A dedicated path for zero-copy allows making a single
15561558
* comparison in the irq context instead of many inside the
15571559
* ice_clean_rx_irq function and makes the codebase cleaner.
15581560
*/
15591561
cleaned = rx_ring->xsk_pool ?
1560-
ice_clean_rx_irq_zc(rx_ring, budget_per_ring) :
1562+
ice_clean_rx_irq_zc(rx_ring, xsk_pool, budget_per_ring) :
15611563
ice_clean_rx_irq(rx_ring, budget_per_ring);
15621564
work_done += cleaned;
15631565
/* if we clean as many as budgeted, we must not be done */

0 commit comments

Comments
 (0)