From: Alexander Lobakin <alexandr.lobakin@intel.com> To: intel-wired-lan@lists.osuosl.org Cc: "Alexander Lobakin" <alexandr.lobakin@intel.com>, "Jesse Brandeburg" <jesse.brandeburg@intel.com>, "Tony Nguyen" <anthony.l.nguyen@intel.com>, "David S. Miller" <davem@davemloft.net>, "Jakub Kicinski" <kuba@kernel.org>, "Alexei Starovoitov" <ast@kernel.org>, "Daniel Borkmann" <daniel@iogearbox.net>, "Jesper Dangaard Brouer" <hawk@kernel.org>, "John Fastabend" <john.fastabend@gmail.com>, "Björn Töpel" <bjorn@kernel.org>, "Maciej Fijalkowski" <maciej.fijalkowski@intel.com>, "Michal Swiatkowski" <michal.swiatkowski@linux.intel.com>, "Jeff Kirsher" <jeffrey.t.kirsher@intel.com>, "Krzysztof Kazimierczak" <krzysztof.kazimierczak@intel.com>, "Jithu Joseph" <jithu.joseph@intel.com>, "Andre Guedes" <andre.guedes@intel.com>, "Vedang Patel" <vedang.patel@intel.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v3 net-next 4/9] ice: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Date: Tue, 7 Dec 2021 21:55:31 +0100 [thread overview] Message-ID: <20211207205536.563550-5-alexandr.lobakin@intel.com> (raw) In-Reply-To: <20211207205536.563550-1-alexandr.lobakin@intel.com> {__,}napi_alloc_skb() allocates and reserves additional NET_SKB_PAD + NET_IP_ALIGN for any skb. OTOH, ice_construct_skb_zc() currently allocates and reserves additional `xdp->data - xdp->data_hard_start`, which is XDP_PACKET_HEADROOM for XSK frames. There's no need for that at all as the frame is post-XDP and will go only to the networking stack core. Pass the size of the actual data only to __napi_alloc_skb() and don't reserve anything. This will give enough headroom for stack processing. Fixes: 2d4238f55697 ("ice: Add support for AF_XDP") Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> --- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index f8ea6b0633eb..f0bd8e1953bf 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -430,15 +430,13 @@ ice_construct_skb_zc(struct ice_rx_ring *rx_ring, struct xdp_buff **xdp_arr) struct xdp_buff *xdp = *xdp_arr; unsigned int metasize = xdp->data - xdp->data_meta; unsigned int datasize = xdp->data_end - xdp->data; - unsigned int datasize_hard = xdp->data_end - xdp->data_hard_start; struct sk_buff *skb; - skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize_hard, + skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize, GFP_ATOMIC | __GFP_NOWARN); if (unlikely(!skb)) return NULL; - skb_reserve(skb, xdp->data - xdp->data_hard_start); memcpy(__skb_put(skb, datasize), xdp->data, datasize); if (metasize) skb_metadata_set(skb, metasize); -- 2.33.1
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Lobakin <alexandr.lobakin@intel.com> To: intel-wired-lan@osuosl.org Subject: [Intel-wired-lan] [PATCH v3 net-next 4/9] ice: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Date: Tue, 7 Dec 2021 21:55:31 +0100 [thread overview] Message-ID: <20211207205536.563550-5-alexandr.lobakin@intel.com> (raw) In-Reply-To: <20211207205536.563550-1-alexandr.lobakin@intel.com> {__,}napi_alloc_skb() allocates and reserves additional NET_SKB_PAD + NET_IP_ALIGN for any skb. OTOH, ice_construct_skb_zc() currently allocates and reserves additional `xdp->data - xdp->data_hard_start`, which is XDP_PACKET_HEADROOM for XSK frames. There's no need for that at all as the frame is post-XDP and will go only to the networking stack core. Pass the size of the actual data only to __napi_alloc_skb() and don't reserve anything. This will give enough headroom for stack processing. Fixes: 2d4238f55697 ("ice: Add support for AF_XDP") Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> --- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index f8ea6b0633eb..f0bd8e1953bf 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -430,15 +430,13 @@ ice_construct_skb_zc(struct ice_rx_ring *rx_ring, struct xdp_buff **xdp_arr) struct xdp_buff *xdp = *xdp_arr; unsigned int metasize = xdp->data - xdp->data_meta; unsigned int datasize = xdp->data_end - xdp->data; - unsigned int datasize_hard = xdp->data_end - xdp->data_hard_start; struct sk_buff *skb; - skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize_hard, + skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize, GFP_ATOMIC | __GFP_NOWARN); if (unlikely(!skb)) return NULL; - skb_reserve(skb, xdp->data - xdp->data_hard_start); memcpy(__skb_put(skb, datasize), xdp->data, datasize); if (metasize) skb_metadata_set(skb, metasize); -- 2.33.1
next prev parent reply other threads:[~2021-12-07 20:57 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-07 20:55 [PATCH v3 net-next 0/9] net: intel: napi_alloc_skb() vs metadata Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 1/9] i40e: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 2/9] i40e: respect metadata " Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2022-01-10 10:31 ` Bhandare, KiranX 2022-01-10 10:31 ` Bhandare, KiranX 2021-12-07 20:55 ` [PATCH v3 net-next 3/9] ice: respect metadata in legacy-rx/ice_construct_skb() Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` Alexander Lobakin [this message] 2021-12-07 20:55 ` [Intel-wired-lan] [PATCH v3 net-next 4/9] ice: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 5/9] ice: respect metadata " Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 6/9] igc: don't reserve excessive XDP_PACKET_HEADROOM " Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 7/9] ixgbe: pass bi->xdp to ixgbe_construct_skb_zc() directly Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 8/9] ixgbe: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-07 20:55 ` [PATCH v3 net-next 9/9] i40e: respect metadata " Alexander Lobakin 2021-12-07 20:55 ` [Intel-wired-lan] " Alexander Lobakin 2021-12-08 13:47 ` Jesper Dangaard Brouer 2021-12-08 13:47 ` [Intel-wired-lan] " Jesper Dangaard Brouer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211207205536.563550-5-alexandr.lobakin@intel.com \ --to=alexandr.lobakin@intel.com \ --cc=andre.guedes@intel.com \ --cc=anthony.l.nguyen@intel.com \ --cc=ast@kernel.org \ --cc=bjorn@kernel.org \ --cc=bpf@vger.kernel.org \ --cc=daniel@iogearbox.net \ --cc=davem@davemloft.net \ --cc=hawk@kernel.org \ --cc=intel-wired-lan@lists.osuosl.org \ --cc=jeffrey.t.kirsher@intel.com \ --cc=jesse.brandeburg@intel.com \ --cc=jithu.joseph@intel.com \ --cc=john.fastabend@gmail.com \ --cc=krzysztof.kazimierczak@intel.com \ --cc=kuba@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maciej.fijalkowski@intel.com \ --cc=michal.swiatkowski@linux.intel.com \ --cc=netdev@vger.kernel.org \ --cc=vedang.patel@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.