Skip to content

Commit c7030d1

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: ethernet: enetc: do not always access skb_shared_info in the XDP path
Move XDP skb_shared_info structure initialization in from enetc_map_rx_buff_to_xdp() to enetc_add_rx_buff_to_xdp() and do not always access skb_shared_info in the xdp_buff/xdp_frame since it is located in a different cacheline with respect to hard_start and data xdp pointers. Rely on XDP_FLAGS_HAS_FRAGS flag to check if it really necessary to access non-linear part of the xdp_buff/xdp_frame. Reviewed-by: Vladimir Oltean <[email protected]> Tested-by: Vladimir Oltean <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 59cc773 commit c7030d1

File tree

1 file changed

+8
-6
lines changed
  • drivers/net/ethernet/freescale/enetc

1 file changed

+8
-6
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,10 @@ static int enetc_xdp_frame_to_xdp_tx_swbd(struct enetc_bdr *tx_ring,
13051305
xdp_tx_swbd->xdp_frame = NULL;
13061306

13071307
n++;
1308+
1309+
if (!xdp_frame_has_frags(xdp_frame))
1310+
goto out;
1311+
13081312
xdp_tx_swbd = &xdp_tx_arr[n];
13091313

13101314
shinfo = xdp_get_shared_info_from_frame(xdp_frame);
@@ -1334,7 +1338,7 @@ static int enetc_xdp_frame_to_xdp_tx_swbd(struct enetc_bdr *tx_ring,
13341338
n++;
13351339
xdp_tx_swbd = &xdp_tx_arr[n];
13361340
}
1337-
1341+
out:
13381342
xdp_tx_arr[n - 1].is_eof = true;
13391343
xdp_tx_arr[n - 1].xdp_frame = xdp_frame;
13401344

@@ -1390,38 +1394,36 @@ static void enetc_map_rx_buff_to_xdp(struct enetc_bdr *rx_ring, int i,
13901394
{
13911395
struct enetc_rx_swbd *rx_swbd = enetc_get_rx_buff(rx_ring, i, size);
13921396
void *hard_start = page_address(rx_swbd->page) + rx_swbd->page_offset;
1393-
struct skb_shared_info *shinfo;
13941397

13951398
/* To be used for XDP_TX */
13961399
rx_swbd->len = size;
13971400

13981401
xdp_prepare_buff(xdp_buff, hard_start - rx_ring->buffer_offset,
13991402
rx_ring->buffer_offset, size, false);
1400-
1401-
shinfo = xdp_get_shared_info_from_buff(xdp_buff);
1402-
shinfo->nr_frags = 0;
14031403
}
14041404

14051405
static void enetc_add_rx_buff_to_xdp(struct enetc_bdr *rx_ring, int i,
14061406
u16 size, struct xdp_buff *xdp_buff)
14071407
{
14081408
struct skb_shared_info *shinfo = xdp_get_shared_info_from_buff(xdp_buff);
14091409
struct enetc_rx_swbd *rx_swbd = enetc_get_rx_buff(rx_ring, i, size);
1410-
skb_frag_t *frag = &shinfo->frags[shinfo->nr_frags];
1410+
skb_frag_t *frag;
14111411

14121412
/* To be used for XDP_TX */
14131413
rx_swbd->len = size;
14141414

14151415
if (!xdp_buff_has_frags(xdp_buff)) {
14161416
xdp_buff_set_frags_flag(xdp_buff);
14171417
shinfo->xdp_frags_size = size;
1418+
shinfo->nr_frags = 0;
14181419
} else {
14191420
shinfo->xdp_frags_size += size;
14201421
}
14211422

14221423
if (page_is_pfmemalloc(rx_swbd->page))
14231424
xdp_buff_set_frag_pfmemalloc(xdp_buff);
14241425

1426+
frag = &shinfo->frags[shinfo->nr_frags];
14251427
skb_frag_off_set(frag, rx_swbd->page_offset);
14261428
skb_frag_size_set(frag, size);
14271429
__skb_frag_set_page(frag, rx_swbd->page);

0 commit comments

Comments
 (0)