-----Original Message----- From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf Of Jiri Pirko Sent: 30 January 2023 20:28 To: John Hickey <jjh@xxxxxxxxxxxx> Cc: Jesper Dangaard Brouer <hawk@xxxxxxxxxx>; Daniel Borkmann <daniel@xxxxxxxxxxxxx>; intel-wired-lan@xxxxxxxxxxxxxxxx; John Fastabend <john.fastabend@xxxxxxxxx>; Brandeburg, Jesse <jesse.brandeburg@xxxxxxxxx>; Alexei Starovoitov <ast@xxxxxxxxxx>; Eric Dumazet <edumazet@xxxxxxxxxx>; Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; Jakub Kicinski <kuba@xxxxxxxxxx>; bpf@xxxxxxxxxxxxxxx; Paolo Abeni <pabeni@xxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx Subject: Re: [Intel-wired-lan] [PATCH] ixgbe: Panic during XDP_TX with > 64 CPUs Sat, Jan 28, 2023 at 02:12:12AM CET, jjh@xxxxxxxxxxxx wrote: >In commit 'ixgbe: let the xdpdrv work with more than 64 cpus' >(4fe815850bdc8d4cc94e06fe1de069424a895826), support was added to allow >XDP programs to run on systems with more than 64 CPUs by locking the >XDP TX rings and indexing them using cpu % 64 (IXGBE_MAX_XDP_QS). > >Upon trying this out patch via the Intel 5.18.6 out of tree driver on a >system with more than 64 cores, the kernel paniced with an >array-index-out-of-bounds at the return in ixgbe_determine_xdp_ring in >ixgbe.h, which means ixgbe_determine_xdp_q_idx was just returning the >cpu instead of cpu % IXGBE_MAX_XDP_QS. > >I think this is how it happens: > >Upon loading the first XDP program on a system with more than 64 CPUs, >ixgbe_xdp_locking_key is incremented in ixgbe_xdp_setup. However, >immediately after this, the rings are reconfigured by ixgbe_setup_tc. >ixgbe_setup_tc calls ixgbe_clear_interrupt_scheme which calls >ixgbe_free_q_vectors which calls ixgbe_free_q_vector in a loop. >ixgbe_free_q_vector decrements ixgbe_xdp_locking_key once per call if >it is non-zero. Commenting out the decrement in ixgbe_free_q_vector >stopped my system from panicing. > >I suspect to make the original patch work, I would need to load an XDP >program and then replace it in order to get ixgbe_xdp_locking_key back >above 0 since ixgbe_setup_tc is only called when transitioning between >XDP and non-XDP ring configurations, while ixgbe_xdp_locking_key is >incremented every time ixgbe_xdp_setup is called. > >Also, ixgbe_setup_tc can be called via ethtool --set-channels, so this >becomes another path to decrement ixgbe_xdp_locking_key to 0 on systems >with greater than 64 CPUs. > >For this patch, I have changed static_branch_inc to >static_branch_enable in ixgbe_setup_xdp. We aren't counting references >and I don't see any reason to turn it off, since all the locking >appears to be in the XDP_TX path, which isn't run if a XDP program isn't loaded. > >Signed-off-by: John Hickey <jjh@xxxxxxxxxxxx> This is missing "Fixes" tag and "net" keyword in "[patch]" subject section. >--- > drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 3 --- >drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- > 2 files changed, 1 insertion(+), 4 deletions(-) > Tested-by: Chandan Kumar Rout <chandanx.rout@xxxxxxxxx> (A Contingent Worker at Intel)