Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp950145pxb; Wed, 6 Apr 2022 05:08:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJot1l6NKML/MkRUTU8Qs/5o58yvYoOMgc6n/ltbYWMYiJmHoOUS6cNfPwP37/HaNJ0rkB X-Received: by 2002:a17:902:ef43:b0:156:9c5d:b0fe with SMTP id e3-20020a170902ef4300b001569c5db0femr8332579plx.158.1649246883944; Wed, 06 Apr 2022 05:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649246883; cv=none; d=google.com; s=arc-20160816; b=zFB3qxpkSsI1OandlLm7xzfvTteOPq+IFmDiworRTJ8MaHuc9BYY48A3dLMbi94jl/ jkj9TtAXMdZUD4eOofnjz926uE9Earx5B9WUzpWqqBe2VodquGSI7DSxNZl0xYsPN7q1 e2u7R9RYzwZQND32QRZ6N9LyFJget59fuxOOJWVKwBlPgC3ep1PEffJglUpZWiIuhqiv AXFX9zr5dy3OMik5LjL09ihT7FDh66b7Dh8sCSIMdCBcs7+Ag+TtFsYLxLoUlsXaY3hU ylyzDlXaOzHCbz2hfW5Nvgv6U4qx+PB61Q0acrpoar68ZErORjV1vtdJSPsWVxOmS1p3 rjpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Se7hC6WcTmjR751RjRJGmnZaAfDDXeUmhOUNIs6mtKU=; b=aemtN7RX/N20ay0zs1WAIh2b3AgfMV8UGsE8HcxdRYhO+PBtdTW0D7Sv83Ki0wRuBX 55VC5nsf8kOsUEKJBZMLmrqCetODB7uplo/WK2dlKaPFm9OHrvrygYAdN/U4fKlbEWJi oFFmicyM66eKOAKQOo0XnWljCVSAcMFqbfyIAaOkCEerwwkzWo/LDHV2XoqvKjYl4ecE 5Tfw99V+dfKHKjfBQ8bmw3Col4b2HoY29E//dkXLUb7ycPv5oq/T9aL3xHU4vEgks5v4 7C06V6xaDDVcAtHG5moMiUAd0ZYZKUHLy9rXxNr1UHgfK9S8oPXgzC5YYnCbW7YEdM6Y WpUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JZf3aA9/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o23-20020a63fb17000000b00382b21d82a2si17417722pgh.366.2022.04.06.05.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:08:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JZf3aA9/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50D27692ADB; Wed, 6 Apr 2022 03:39:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385460AbiDEVto (ORCPT + 99 others); Tue, 5 Apr 2022 17:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348932AbiDEJst (ORCPT ); Tue, 5 Apr 2022 05:48:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE89798F76; Tue, 5 Apr 2022 02:37:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 90006B818F3; Tue, 5 Apr 2022 09:37:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D441FC385A2; Tue, 5 Apr 2022 09:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151477; bh=jqWhiNEuxzqJJdkO6Zr2C7vC3Glh0GLN0fChM3HRWgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZf3aA9/OljTrt1OQRe5gQ7aAVF+juJUuenxLn/IZFEW+nXmCOAXtk0g6HDx6lfV4 iSTPqXIdteZcrmU8sn23FW4w5lIaw/9gCGYP4dLjeLj49idlZYpPRbl/E3G/EEFhku Y7QzYjp2HZhbL5sisjkqQPstBzAPTrGd1WLI2n00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Lobakin , Michal Swiatkowski , Nechama Kraus , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 412/913] igc: dont reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Date: Tue, 5 Apr 2022 09:24:34 +0200 Message-Id: <20220405070352.195960180@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Lobakin [ Upstream commit f9e61d365bafdee40fe2586fc6be490c3e824dad ] {__,}napi_alloc_skb() allocates and reserves additional NET_SKB_PAD + NET_IP_ALIGN for any skb. OTOH, igc_construct_skb_zc() currently allocates and reserves additional `xdp->data_meta - xdp->data_hard_start`, which is about 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 (+ meta) to __napi_alloc_skb() and don't reserve anything. This will give enough headroom for stack processing. Also, net_prefetch() xdp->data_meta and align the copy size to speed-up memcpy() a little and better match igc_construct_skb(). Fixes: fc9df2a0b520 ("igc: Enable RX via AF_XDP zero-copy") Signed-off-by: Alexander Lobakin Reviewed-by: Michal Swiatkowski Tested-by: Nechama Kraus Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index c7fa978cdf02..a514cfc6c8a0 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2434,19 +2434,20 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring, struct xdp_buff *xdp) { + unsigned int totalsize = xdp->data_end - xdp->data_meta; unsigned int metasize = xdp->data - xdp->data_meta; - unsigned int datasize = xdp->data_end - xdp->data; - unsigned int totalsize = metasize + datasize; struct sk_buff *skb; - skb = __napi_alloc_skb(&ring->q_vector->napi, - xdp->data_end - xdp->data_hard_start, + net_prefetch(xdp->data_meta); + + skb = __napi_alloc_skb(&ring->q_vector->napi, totalsize, GFP_ATOMIC | __GFP_NOWARN); if (unlikely(!skb)) return NULL; - skb_reserve(skb, xdp->data_meta - xdp->data_hard_start); - memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize); + memcpy(__skb_put(skb, totalsize), xdp->data_meta, + ALIGN(totalsize, sizeof(long))); + if (metasize) { skb_metadata_set(skb, metasize); __skb_pull(skb, metasize); -- 2.34.1