Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3102AC433EF for ; Thu, 9 Dec 2021 08:19:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234626AbhLIIX3 (ORCPT ); Thu, 9 Dec 2021 03:23:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48091 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234617AbhLIIX1 (ORCPT ); Thu, 9 Dec 2021 03:23:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639037994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rEpawBZHKqDeDQKo/yN12N0IK537hgmoTf00FptBiYQ=; b=jWRwL24iXXXjNCIZ/8165HENs8a/z8hQXVjyn0ZAqlbeFo94lvsywdvRFgHDvk7g13j7Lp IsENhxznay+dGVhuJzGrK3Cm7+aXD+/3kjEWjFzBhNndOmRxvDlKOSl+iEwd0mJo0SW1CC wMde50UuzIHP3+H/2JG5Sb/PiOtKOZE= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-175-cvRBpPgROg2TRlUDQglaaA-1; Thu, 09 Dec 2021 03:19:51 -0500 X-MC-Unique: cvRBpPgROg2TRlUDQglaaA-1 Received: by mail-lf1-f70.google.com with SMTP id s11-20020a195e0b000000b0041c0a47fb77so2316624lfb.20 for ; Thu, 09 Dec 2021 00:19:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:date:mime-version:user-agent:cc :subject:content-language:to:references:in-reply-to :content-transfer-encoding; bh=rEpawBZHKqDeDQKo/yN12N0IK537hgmoTf00FptBiYQ=; b=R6R9X7xa9vAcO/Bi2IgFSOOJyvCkmG04XpP1qyZD7yz0IrI3Sj9c7LSWpmqwsNGNmh fGuUalTY96gedPSN+QFBZXdhuyAPl+wwbvnJb5zEkBALp9i08M2LTEujVXm/cdtFaQJi fiQ6q69tU0pBAKhwo+PyGdoQkNN3av9Cn0zSNbjBiiT1IuPWTKXJAPdhDVF66o1tZnIO XOXdAMQeVSLUufYowtnpsX9G7Ynqj55q98WhaUk6whaUGjv897VI8pqn4xtJouSgyLiF zsPKUd9JCuQaPkV9ZfbDXIATZoOkS3q+ddX6gn7taNbyaz+lSlxUQM+wgy4yGDRSP9NQ vPFA== X-Gm-Message-State: AOAM5329Z47sL+9n89f72xaNTQZ8m23rCX/wa0f1+yYgaj7t7JAvxhgP pKcSgr18yMtnQ39pnWlwHQhzNjA0wc9m8S0ANawjDXWsgCRyrFmwF1IcziQmIImW/0FUSgkFw1D ktrcvFj3QruMT/Ppukx7tPfTc X-Received: by 2002:a05:6512:3081:: with SMTP id z1mr4632981lfd.583.1639037989633; Thu, 09 Dec 2021 00:19:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS/NhDYClzEMqPHgcZJoc8Qn3jO1V0yHANyUzHNzpfzXYHvvQ5/cG/fdFk6UVQADSQjn3bhg== X-Received: by 2002:a05:6512:3081:: with SMTP id z1mr4632963lfd.583.1639037989444; Thu, 09 Dec 2021 00:19:49 -0800 (PST) Received: from [192.168.0.50] (87-59-106-155-cable.dk.customer.tdc.net. [87.59.106.155]) by smtp.gmail.com with ESMTPSA id m10sm527889lji.11.2021.12.09.00.19.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 00:19:48 -0800 (PST) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: Date: Thu, 9 Dec 2021 09:19:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Cc: brouer@redhat.com, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Maciej Fijalkowski , Michal Swiatkowski , Jithu Joseph , Martin KaFai Lau , Song Liu , KP Singh , Yonghong Song , Andrii Nakryiko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v4 net-next 1/9] i40e: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb Content-Language: en-US To: Alexander Lobakin , intel-wired-lan@lists.osuosl.org References: <20211208140702.642741-1-alexandr.lobakin@intel.com> <20211208140702.642741-2-alexandr.lobakin@intel.com> In-Reply-To: <20211208140702.642741-2-alexandr.lobakin@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/12/2021 15.06, Alexander Lobakin wrote: > {__,}napi_alloc_skb() allocates and reserves additional NET_SKB_PAD > + NET_IP_ALIGN for any skb. > OTOH, i40e_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. I disagree with this assumption, that headroom is not needed by netstack. Why "no need for that at all" for netstack? Having headroom is important for netstack in general. When packet will grow we avoid realloc of SKB. Use-case could also be cpumap or veth redirect, or XDP-generic, that expect this headroom. > 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: 0a714186d3c0 ("i40e: add AF_XDP zero-copy Rx support") > Signed-off-by: Alexander Lobakin > Reviewed-by: Michal Swiatkowski > --- > drivers/net/ethernet/intel/i40e/i40e_xsk.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c > index f08d19b8c554..9564906b7da8 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c > @@ -245,13 +245,11 @@ static struct sk_buff *i40e_construct_skb_zc(struct i40e_ring *rx_ring, > struct sk_buff *skb; > > /* allocate a skb to store the frags */ > - skb = __napi_alloc_skb(&rx_ring->q_vector->napi, > - xdp->data_end - xdp->data_hard_start, > + skb = __napi_alloc_skb(&rx_ring->q_vector->napi, datasize, > GFP_ATOMIC | __GFP_NOWARN); > if (unlikely(!skb)) > goto out; > > - skb_reserve(skb, xdp->data - xdp->data_hard_start); > memcpy(__skb_put(skb, datasize), xdp->data, datasize); > if (metasize) > skb_metadata_set(skb, metasize); >