ice: fix Rx data path for PAGE_SIZE >= 8192
Subsystems (3)
cover ice: fix Rx data path for PAGE_SIZE >= 8192
Hi,
These three small fixes addres the following panic reported by Luiz
(https://lore.kernel.org/netdev/[email protected]/):
[ 225.715759] Unable to handle kernel paging request at virtual address 0075e625f68aa42c [ 225.723669] Mem abort info: [ 225.726487] ESR = 0x0000000096000004 [ 225.730223] EC = 0x25: DABT (current EL), IL = 32 bits [ 225.735526] SET = 0, FnV = 0 [ 225.738568] EA = 0, S1PTW = 0 [ 225.741695] FSC = 0x04: level 0 translation fault [ 225.746564] Data abort info: [ 225.749431] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 225.754906] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 225.759944] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 225.765250] [0075e625f68aa42c] address between user and kernel address ranges [ 225.772373] Internal error: Oops: 0000000096000004 [#1] SMP [ 225.777932] Modules linked in: xfs(E) crct10dif_ce(E) ghash_ce(E) sha2_ce(E) sha256_arm64(E) sha1_ce(E) sbsa_gwdt(E) ice(E) nvme(E) libie(E) dimlib(E) nvme_core(E) gnss(E) nvme_auth(E) ixgbe(E) igb(E) mdio(E) i2c_algo_bit(E) i2c_designware_platform(E) xgene_hwmon(E) i2c_designware_core(E) dm_mirror(E) dm_region_hash(E) dm_log(E) dm_mod(E) [ 225.807902] CPU: 61 PID: 7794 Comm: iperf3 Kdump: loaded Tainted: G E 6.10.0-rc4+ #1 [ 225.817021] Hardware name: LTHPC GR2134/MP32-AR2-LT, BIOS F31j (SCP: 2.10.20220531) 08/01/2022 [ 225.825618] pstate: 00400009 (nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 225.832566] pc : __arch_copy_to_user+0x4c/0x240 [ 225.837088] lr : _copy_to_iter+0x104/0x518 [ 225.841173] sp : ffff80010978f6e0 [ 225.844474] x29: ffff80010978f730 x28: 0000000000007388 x27: 4775e625f68aa42c [ 225.851597] x26: 0000000000000001 x25: 00000000000005a8 x24: 00000000000005a8 [ 225.858720] x23: 0000000000007388 x22: ffff80010978fa60 x21: ffff80010978fa60 [ 225.865842] x20: 4775e625f68aa42c x19: 0000000000007388 x18: 0000000000000000 [ 225.872964] x17: 0000000000000000 x16: 0000000000000000 x15: 4775e625f68aa42c [ 225.880087] x14: aaa03e61c262c44f x13: 5fb01a5ebded22da x12: 415feff815830f22 [ 225.887209] x11: 7411a8ffaab6d3d7 x10: 95af4645d12e6d70 x9 : ffffba83c2faddac [ 225.894332] x8 : c1cbcc6e9552ed64 x7 : dfcefe933cdc57ae x6 : 0000fffde5aa9e80 [ 225.901454] x5 : 0000fffde5ab1208 x4 : 0000000000000004 x3 : 0000000000016180 [ 225.908576] x2 : 0000000000007384 x1 : 4775e625f68aa42c x0 : 0000fffde5aa9e80 [ 225.915699] Call trace: [ 225.918132] __arch_copy_to_user+0x4c/0x240 [ 225.922304] simple_copy_to_iter+0x4c/0x78 [ 225.926389] __skb_datagram_iter+0x18c/0x270 [ 225.930647] skb_copy_datagram_iter+0x4c/0xe0 [ 225.934991] tcp_recvmsg_locked+0x59c/0x9a0 [ 225.939162] tcp_recvmsg+0x78/0x1d0 [ 225.942638] inet6_recvmsg+0x54/0x128 [ 225.946289] sock_recvmsg+0x78/0xd0 [ 225.949766] sock_read_iter+0x98/0x108 [ 225.953502] vfs_read+0x2a4/0x318 [ 225.956806] ksys_read+0xec/0x110 [ 225.960108] __arm64_sys_read+0x24/0x38 [ 225.963932] invoke_syscall.constprop.0+0x80/0xe0 [ 225.968624] do_el0_svc+0xc0/0xe0 [ 225.971926] el0_svc+0x48/0x1b0 [ 225.975056] el0t_64_sync_handler+0x13c/0x158 [ 225.979400] el0t_64_sync+0x1a4/0x1a8 [ 225.983051] Code: 78402423 780008c3 910008c6 36100084 (b8404423) [ 225.989132] SMP: stopping secondary CPUs [ 225.995919] Starting crashdump kernel... [ 225.999829] Bye!
Third patch contains the root cause description. I suppose that i40e would break as well for arm64 and multi-buffer traffic as when we update the skb shared info we assume that xdp_buff::frame_sz is constant but it should be accounted per each buffer.
Thanks,
Maciej
Maciej Fijalkowski (3):
ice: fix page reuse when PAGE_SIZE is over 8k
ice: fix ICE_LAST_OFFSET formula
ice: fix truesize operations for PAGE_SIZE >= 8192
drivers/net/ethernet/intel/ice/ice_base.c | 21 +++++++++- drivers/net/ethernet/intel/ice/ice_txrx.c | 47 ++--------------------- 2 files changed, 24 insertions(+), 44 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 ice: fix page reuse when PAGE_SIZE is over 8k
Architectures that have PAGE_SIZE >= 8192 such as arm64 should act the same as x86 currently, meaning reuse of a page should only take place when no one else is busy with it.
Do two things independently of underlying PAGE_SIZE:
- store the page count under ice_rx_buf::pgcnt
- then act upon its value vs ice_rx_buf::pagecnt_bias when making the decision regarding page reuse
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +3 -9
@@ -837,16 +837,15 @@ ice_can_reuse_rx_page(struct ice_rx_buf *rx_buf)if (!dev_page_is_reusable (page))return false; -#if (PAGE_SIZE <8192 )/* if we are only owner of page we can reuse it */ if (unlikely (rx_buf->pgcnt - pagecnt_bias >1 ))return false; -#else +#if (PAGE_SIZE >=8192 )#define ICE_LAST_OFFSET \ (SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_2048)if (rx_buf->page_offset >ICE_LAST_OFFSET )return false; -#endif /* PAGE_SIZE < 8192) */ +#endif /* PAGE_SIZE >= 8192) */ /* If we have drained the page fragment pool we need to update * the pagecnt_bias and page count so that we fully restock the
@@ -949,12 +948,7 @@ ice_get_rx_buf(struct ice_rx_ring *rx_ring, const unsigned int size,struct ice_rx_buf *rx_buf; rx_buf = &rx_ring->rx_buf[ntc]; - rx_buf->pgcnt = -#if (PAGE_SIZE <8192 ) -page_count (rx_buf->page); -#else -0 ; -#endif + rx_buf->pgcnt =page_count (rx_buf->page);prefetchw (rx_buf->page);if (!size)
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH iwl-net 1/3] ice: fix page reuse when PAGE_SIZE is over 8k
Quoted 23 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Fijalkowski, Maciej
Sent: Wednesday, August 7, 2024 4:23 PM
To: [email protected]
Cc: Fijalkowski, Maciej <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Karlsson, Magnus <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net 1/3] ice: fix page reuse whenPAGE_SIZEis over 8kArchitectures that have
PAGE_SIZE>= 8192 such as arm64 should act the same as x86 currently, meaning reuse of a page should only take place when no one else is busy with it.Do two things independently of underlying
PAGE_SIZE:
- store the page count underice_rx_buf::pgcnt
- then act upon its value vsice_rx_buf::pagecnt_biaswhen making the decision regarding page reuse
Quoted 6 lines
Fixes 2b245cb29421 ("ice: Implement transmit and NAPI support")Signed-off-by Maciej Fijalkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_txrx.c| 12 +++---------1 file changed, 3 insertions(+), 9 deletions(-)
PATCH 2/3 ice: fix ICE_LAST_OFFSET formula
In reply to Maciej FijalkowskiFor bigger PAGE_SIZE archs, ice driver works on 3k Rx buffers. Therefore, ICE_LAST_OFFSET should take into account ICE_RXBUF_3072, not ICE_RXBUF_2048.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -842,7 +842,7 @@ ice_can_reuse_rx_page(struct ice_rx_buf *rx_buf)return false;#if (PAGE_SIZE >=8192 )#define ICE_LAST_OFFSET \ - (SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_2048) + (SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_3072)if (rx_buf->page_offset >ICE_LAST_OFFSET )return false;#endif /* PAGE_SIZE >= 8192) */
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH iwl-net 2/3] ice: fix ICE_LAST_OFFSET formula
Quoted 17 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Fijalkowski, Maciej
Sent: Wednesday, August 7, 2024 4:23 PM
To: [email protected]
Cc: Fijalkowski, Maciej <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Karlsson, Magnus <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net 2/3] ice: fixICE_LAST_OFFSETformulaFor bigger
PAGE_SIZEarchs, ice driver works on 3k Rx buffers. Therefore,ICE_LAST_OFFSETshould take into accountICE_RXBUF_3072, notICE_RXBUF_2048.
Quoted 7 lines
Fixes 7237f5b0dba4 ("ice: introduce legacy Rx flag")Suggested-by Luiz Capitulino <[email protected]>Signed-off-by Maciej Fijalkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_txrx.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 3/3 ice: fix truesize operations for PAGE_SIZE >= 8192
In reply to Maciej FijalkowskiWhen working on multi-buffer packet on arch that has PAGE_SIZE >= 8192, truesize is calculated and stored in xdp_buff::frame_sz per each processed Rx buffer. This means that frame_sz will contain the truesize based on last received buffer, but commit 1dc1a7e7f410 ("ice:
Centrallize Rx buffer recycling") assumed this value will be constant for each buffer, which breaks the page recycling scheme and mess up the way we update the page::page_offset.
To fix this, let us work on constant truesize when PAGE_SIZE >= 8192 instead of basing this on size of a packet read from Rx descriptor. This way we can simplify the code and avoid calculating truesize per each received frame and on top of that when using xdp_update_skb_shared_info(), current formula for truesize update will be valid.
This means ice_rx_frame_truesize() can be removed altogether. Furthermore, first call to it within ice_clean_rx_irq() for 4k PAGE_SIZE was redundant as xdp_buff::frame_sz is initialized via xdp_init_buff() in ice_vsi_cfg_rxq(). This should have been removed at the point where xdp_buff struct started to be a member of ice_rx_ring and it was no longer a stack based variable.
There are two fixes tags as my understanding is that the first one exposed us to broken truesize and page_offset handling and then second introduced broken skb_shared_info update in ice_{construct,build}_skb().
--- drivers/net/ethernet/intel/ice/ice_base.c | 21 ++++++++++++++- drivers/net/ethernet/intel/ice/ice_txrx.c | 33 ----------------------- 2 files changed, 20 insertions(+), 34 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +20 -1
@@ -512,6 +512,25 @@ static void ice_xsk_pool_fill_cb(struct ice_rx_ring *ring)xsk_pool_fill_cb (ring->xsk_pool, &desc); } +/** +* ice_get_frame_sz - calculate xdp_buff::frame_sz +* @rx_ring: the ring being configured +* +* Return frame size based on underlying PAGE_SIZE +*/ +static unsigned int ice_get_frame_sz (struct ice_rx_ring *rx_ring) +{ +unsigned int frame_sz; + +#if (PAGE_SIZE >=8192 ) + frame_sz = rx_ring->rx_buf_len; +#else + frame_sz =ice_rx_pg_size (rx_ring) /2 ; +#endif + +return frame_sz; +} +/** * ice_vsi_cfg_rxq - Configure an Rx queue * @ring: the ring being configured
@@ -576,7 +595,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring) } } -xdp_init_buff (&ring->xdp,ice_rx_pg_size (ring) /2 , &ring->xdp_rxq); +xdp_init_buff (&ring->xdp,ice_get_frame_sz (ring), &ring->xdp_rxq); ring->xdp.data =NULL ; ring->xdp_ext.pkt_ctx = &ring->pkt_ctx; err =ice_setup_rx_ctx (ring);
drivers/net/ethernet/intel/ice/ice_txrx.c +0 -33
@@ -521,30 +521,6 @@ int ice_setup_rx_ring(struct ice_rx_ring *rx_ring)return -ENOMEM ; } -/** -* ice_rx_frame_truesize -* @rx_ring: ptr to Rx ring -* @size: size -* -* calculate the truesize with taking into the account PAGE_SIZE of -* underlying arch -*/ -static unsigned int -ice_rx_frame_truesize (struct ice_rx_ring *rx_ring,const unsigned int size) -{ -unsigned int truesize; - -#if (PAGE_SIZE <8192 ) - truesize =ice_rx_pg_size (rx_ring) /2 ;/* Must be power-of-2 */ -#else - truesize = rx_ring->rx_offset ? -SKB_DATA_ALIGN (rx_ring->rx_offset + size) + -SKB_DATA_ALIGN (sizeof (struct skb_shared_info )) : -SKB_DATA_ALIGN (size); -#endif -return truesize; -} -/** * ice_run_xdp - Executes an XDP program on initialized xdp_buff * @rx_ring: Rx ring
@@ -1154,11 +1130,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)bool failure;u32 first; -/* Frame size depend on rx_ring setup when PAGE_SIZE=4K */ -#if (PAGE_SIZE <8192 ) - xdp->frame_sz =ice_rx_frame_truesize (rx_ring,0 ); -#endif - xdp_prog =READ_ONCE (rx_ring->xdp_prog);if (xdp_prog) { xdp_ring = rx_ring->xdp_ring;
@@ -1217,10 +1188,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget) hard_start =page_address (rx_buf->page) + rx_buf->page_offset - offset;xdp_prepare_buff (xdp, hard_start, offset, size, !!offset); -#if (PAGE_SIZE >4096 ) -/* At larger PAGE_SIZE, frame_sz depend on len size */ - xdp->frame_sz =ice_rx_frame_truesize (rx_ring, size); -#endif xdp_buff_clear_frags_flag (xdp); }else if (ice_add_xdp_frag (rx_ring, xdp, rx_buf, size)) {break ;
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH iwl-net 3/3] ice: fix truesize operations for PAGE_SIZE >= 8192
Quoted 41 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Fijalkowski, Maciej
Sent: Wednesday, August 7, 2024 4:23 PM
To: [email protected]
Cc: Fijalkowski, Maciej <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Karlsson, Magnus <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net 3/3] ice: fix truesize operations forPAGE_SIZE>= 8192When working on multi-buffer packet on arch that has
PAGE_SIZE>= 8192, truesize is calculated and stored inxdp_buff::frame_szper each processed Rx buffer. This means thatframe_szwill contain the truesize based on last received buffer, but commit1dc1a7e7f410("ice:
Centrallize Rx buffer recycling") assumed this value will be constant for each buffer, which breaks the page recycling scheme and mess up the way we update thepage::page_offset.To fix this, let us work on constant truesize when
PAGE_SIZE>= 8192 instead of basing this on size of a packet read from Rx descriptor. This way we can simplify the code and avoid calculating truesize per each received frame and on top of that when usingxdp_update_skb_shared_info(), current formula for truesize update will be valid.This means
ice_rx_frame_truesize()can be removed altogether. Furthermore, first call to it withinice_clean_rx_irq()for 4kPAGE_SIZEwas redundant asxdp_buff::frame_szis initialized viaxdp_init_buff()inice_vsi_cfg_rxq(). This should have been removed at the point wherexdp_buffstruct started to be a member ofice_rx_ringand it was no longer a stack based variable.There are two fixes tags as my understanding is that the first one exposed us to broken truesize and
page_offsethandling and then second introduced brokenskb_shared_infoupdate in ice_{construct,build}_skb().Reported-and-tested-by Luiz Capitulino <[email protected]>
Quoted 9 lines
Fixes 1dc1a7e7f410 ("ice: Centrallize Rx buffer recycling")Fixes 2fba7dc5157b ("ice: Add support for XDP multi-buffer on Rx side")Signed-off-by Maciej Fijalkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_base.c| 21 ++++++++++++++-drivers/net/ethernet/intel/ice/ice_txrx.c| 33 -----------------------2 files changed, 20 insertions(+), 34 deletions(-)
Quoted 4 lines · Maciej Fijalkowski
Hi,
These three small fixes addres the following panic reported by Luiz
(https://lore.kernel.org/netdev/[email protected]/):
Thank you one more time for getting this fixed!
I had to return the testbed so I won't be able to do a final testing on this series, but I tested the fix as indicated in the last patch.
- Luiz
Quoted 71 lines
[ 225.715759] Unable to handle kernel paging request at virtual address 0075e625f68aa42c [ 225.723669] Mem abort info: [ 225.726487] ESR = 0x0000000096000004 [ 225.730223] EC = 0x25: DABT (current EL), IL = 32 bits [ 225.735526] SET = 0, FnV = 0 [ 225.738568] EA = 0, S1PTW = 0 [ 225.741695] FSC = 0x04: level 0 translation fault [ 225.746564] Data abort info: [ 225.749431] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 225.754906] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 225.759944] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 225.765250] [0075e625f68aa42c] address between user and kernel address ranges [ 225.772373] Internal error: Oops: 0000000096000004 [#1] SMP [ 225.777932] Modules linked in: xfs(E) crct10dif_ce(E) ghash_ce(E) sha2_ce(E) sha256_arm64(E) sha1_ce(E) sbsa_gwdt(E) ice(E) nvme(E) libie(E) dimlib(E) nvme_core(E) gnss(E) nvme_auth(E) ixgbe(E) igb(E) mdio(E) i2c_algo_bit(E) i2c_designware_platform(E) xgene_hwmon(E) i2c_designware_core(E) dm_mirror(E) dm_region_hash(E) dm_log(E) dm_mod(E) [ 225.807902] CPU: 61 PID: 7794 Comm: iperf3 Kdump: loaded Tainted: G E 6.10.0-rc4+ #1 [ 225.817021] Hardware name: LTHPC GR2134/MP32-AR2-LT, BIOS F31j (SCP: 2.10.20220531) 08/01/2022 [ 225.825618] pstate: 00400009 (nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 225.832566] pc : __arch_copy_to_user+0x4c/0x240 [ 225.837088] lr : _copy_to_iter+0x104/0x518 [ 225.841173] sp : ffff80010978f6e0 [ 225.844474] x29: ffff80010978f730 x28: 0000000000007388 x27: 4775e625f68aa42c [ 225.851597] x26: 0000000000000001 x25: 00000000000005a8 x24: 00000000000005a8 [ 225.858720] x23: 0000000000007388 x22: ffff80010978fa60 x21: ffff80010978fa60 [ 225.865842] x20: 4775e625f68aa42c x19: 0000000000007388 x18: 0000000000000000 [ 225.872964] x17: 0000000000000000 x16: 0000000000000000 x15: 4775e625f68aa42c [ 225.880087] x14: aaa03e61c262c44f x13: 5fb01a5ebded22da x12: 415feff815830f22 [ 225.887209] x11: 7411a8ffaab6d3d7 x10: 95af4645d12e6d70 x9 : ffffba83c2faddac [ 225.894332] x8 : c1cbcc6e9552ed64 x7 : dfcefe933cdc57ae x6 : 0000fffde5aa9e80 [ 225.901454] x5 : 0000fffde5ab1208 x4 : 0000000000000004 x3 : 0000000000016180 [ 225.908576] x2 : 0000000000007384 x1 : 4775e625f68aa42c x0 : 0000fffde5aa9e80 [ 225.915699] Call trace: [ 225.918132] __arch_copy_to_user+0x4c/0x240 [ 225.922304] simple_copy_to_iter+0x4c/0x78 [ 225.926389] __skb_datagram_iter+0x18c/0x270 [ 225.930647] skb_copy_datagram_iter+0x4c/0xe0 [ 225.934991] tcp_recvmsg_locked+0x59c/0x9a0 [ 225.939162] tcp_recvmsg+0x78/0x1d0 [ 225.942638] inet6_recvmsg+0x54/0x128 [ 225.946289] sock_recvmsg+0x78/0xd0 [ 225.949766] sock_read_iter+0x98/0x108 [ 225.953502] vfs_read+0x2a4/0x318 [ 225.956806] ksys_read+0xec/0x110 [ 225.960108] __arm64_sys_read+0x24/0x38 [ 225.963932] invoke_syscall.constprop.0+0x80/0xe0 [ 225.968624] do_el0_svc+0xc0/0xe0 [ 225.971926] el0_svc+0x48/0x1b0 [ 225.975056] el0t_64_sync_handler+0x13c/0x158 [ 225.979400] el0t_64_sync+0x1a4/0x1a8 [ 225.983051] Code: 78402423 780008c3 910008c6 36100084 (b8404423) [ 225.989132] SMP: stopping secondary CPUs [ 225.995919] Starting crashdump kernel... [ 225.999829] Bye!Third patch contains the root cause description. I suppose that i40e would break as well for arm64 and multi-buffer traffic as when we update the skb shared info we assume that
xdp_buff::frame_szis constant but it should be accounted per each buffer.Thanks,
MaciejMaciej Fijalkowski (3):
ice: fix page reuse whenPAGE_SIZEis over 8k
ice: fixICE_LAST_OFFSETformula
ice: fix truesize operations forPAGE_SIZE>= 8192drivers/net/ethernet/intel/ice/ice_base.c | 21 +++++++++- drivers/net/ethernet/intel/ice/ice_txrx.c | 47 ++--------------------- 2 files changed, 24 insertions(+), 44 deletions(-)