Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1252181lqs; Sat, 15 Jun 2024 00:35:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW71UaIIj9ISQkXFA/sV1MyRqZxI8XPu2Q29ppNF3gPwfX3fla8qfyHkjs/gK3uWjdl/aizdDd4/mML4w2cr2ZCbyL2XO07rXYu6JPkaA== X-Google-Smtp-Source: AGHT+IE+5NjHYTa3xhibX5cwvemI2INfBnsFkxtKHGdwPGz4OXl2bl43QE9I1EYIAgdrHOYICocw X-Received: by 2002:a05:6602:2d8a:b0:7eb:4926:f66 with SMTP id ca18e2360f4ac-7ebeb4b677emr511166539f.7.1718436957657; Sat, 15 Jun 2024 00:35:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718436957; cv=pass; d=google.com; s=arc-20160816; b=oquEMuaq3EavGuFazl3OCJrkXnRtQlC/IgkcXkcj78jvbg4XmkciD10AesEYafCzcS XkH8pH8E49jNPGXaQAqxyK4KlpGxm8oOAEvDTp2v1+AQS5ktQi7X2r7c0vVhr6dn5u+f 7JeGy9YRpURZv37E5Mcu2TpMiyV7Z7AiDH9WBqYHsAd+7soTnK6JeA460ZJIrgTSTEOS Rokdr9RbMpUGXBEhYOpkKBpvoY7VRSKSF1DJlu67VIVWW5SfFiSFOh/SS7D6cL8ox7NB aui57jkoXzrbfV063LqBaleS60uPzv1bqA8GA60jgnNkqZF+nY3+WAUKWI8ONhh5x5oC CdOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YSGrvwhV9EykiHptoImmLVet3+K9lnCCUivP7LC9nCQ=; fh=DgmPBOqxfGsYzr51ghNvawng7Aj1spTz/f7Wg4/F2JI=; b=tmaVhb9v9VI9beMHC2+AayJEfvdvTgZ4sXr7NTwnT0J+PI64afarHDgQgsClM1EjWi MDQrcrMpAIzLkWD4FpnxDj9kw9FN2NRg3N8AhewLbpcEEvLJkQoZ6CvumMvHNtkWnZCk tMrufHJ+wuFSApP55l/ur9TVWQQT800nHTCOeQpX430zvezdO9dsNzrpcDoKahxe0/VZ njF/5vxIQOSYobUH1atwCTXzsY9ZNtdCPcpyqHZnDzp8IGbwlpBG81HQO0XnbDDEutJT YgH4WQTWY90Fcr5eLURNjnMM5W82Uixna6fxCxWSOwGAL7yMpfWZZi6gRmFV7l7Km3ru wqIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PdlVeB4S; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-705cc961d33si3892622b3a.99.2024.06.15.00.35.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 00:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PdlVeB4S; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 867B8B22837 for ; Sat, 15 Jun 2024 07:35:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB69E17BCD; Sat, 15 Jun 2024 07:35:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PdlVeB4S" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2E6C182A0; Sat, 15 Jun 2024 07:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718436915; cv=none; b=CeprZS0B4yfxlMLbNhzzz39Uavqq8k+iAetf274qcfd1UJWL4j6naVlq1qEF3N89ElzVYcKbGCbPke2CQXnq/I32W53mOETgvvvdDYXSq46sUKwaCTnm0k4JIKQaIlsR8m53ky1TMKRcPUUHLp2VX0ATQo988IBTTWybuz7SMXE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718436915; c=relaxed/simple; bh=WN8+1EL5UU20JLPnEmj/YfX8PA8TXVtuZSlPbt7LRgU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tSRMpBgmgxXKKvtOzr4OwFQZVYg/xlEOi5qMcD/wgFjKyOaINROGd95P5VGZRvokTJvr2vcTUxNx5wnXlJtiFgPeyweUTzBs5IzDJ7zGaumAoKA+i6+YNMoarx7Ho2NepixiUCWlczn5lG0lSrFPBEli4lMltxWO1GNWWyghYmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PdlVeB4S; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EDAEC116B1; Sat, 15 Jun 2024 07:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718436914; bh=WN8+1EL5UU20JLPnEmj/YfX8PA8TXVtuZSlPbt7LRgU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PdlVeB4ShSbOhokm7RlReaIj/d08///o7evtBquGRbIY93rvTR3IUon38wSe2V/pa dBeBksMfLaotA+C/FuEzEvOzTQyk9vqfVVjRRtE0SNl02ehowuEtXKsrPEYAUutOZD Xc7tCTL1gVVg/NpEqTVScaYozOEb9mEZu9ruis3CG10FkjJFLW0C0BwONaLHTPszuF VwK7tvR68yWoL6bMZf8ekl2EEgUTaLSj2qnJMbeye/WCk3JLeS5CJV5zAs5E9HQRaf /soQUXs7CN5kOPxHJ1hCFIIf+VdnNKMC3ymnkYlioY1S/HO7ABxLB1DlNvb7o3OxS1 kUS+qGBkKYFTQ== Date: Sat, 15 Jun 2024 08:35:09 +0100 From: Simon Horman To: Alexander Lobakin Cc: intel-wired-lan@lists.osuosl.org, Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mina Almasry , nex.sw.ncis.osdt.itp.upstreaming@intel.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH iwl-next 12/12] idpf: use libeth Rx buffer management for payload buffer Message-ID: <20240615073509.GA8447@kernel.org> References: <20240528134846.148890-1-aleksander.lobakin@intel.com> <20240528134846.148890-13-aleksander.lobakin@intel.com> <20240601090842.GZ491852@kernel.org> <2c22ba85-2338-4f16-b3c2-70c4270cd96b@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2c22ba85-2338-4f16-b3c2-70c4270cd96b@intel.com> On Thu, Jun 13, 2024 at 01:05:58PM +0200, Alexander Lobakin wrote: > From: Simon Horman > Date: Sat, 1 Jun 2024 10:08:42 +0100 > > > + Dan Carpenter > > > > On Tue, May 28, 2024 at 03:48:46PM +0200, Alexander Lobakin wrote: > >> idpf uses Page Pool for data buffers with hardcoded buffer lengths of > >> 4k for "classic" buffers and 2k for "short" ones. This is not flexible > >> and does not ensure optimal memory usage. Why would you need 4k buffers > >> when the MTU is 1500? > >> Use libeth for the data buffers and don't hardcode any buffer sizes. Let > >> them be calculated from the MTU for "classics" and then divide the > >> truesize by 2 for "short" ones. The memory usage is now greatly reduced > >> and 2 buffer queues starts make sense: on frames <= 1024, you'll recycle > >> (and resync) a page only after 4 HW writes rather than two. > >> > >> Signed-off-by: Alexander Lobakin > > > > ... > > > >> diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c > > > > ... > > > > Hi Alexander, > > > > The code above the hunk below, starting at line 3321, is: > > > > if (unlikely(!hdr_len && !skb)) { > > hdr_len = idpf_rx_hsplit_wa(hdr, rx_buf, pkt_len); > > pkt_len -= hdr_len; > > u64_stats_update_begin(&rxq->stats_sync); > > u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf); > > u64_stats_update_end(&rxq->stats_sync); > > } > > if (libeth_rx_sync_for_cpu(hdr, hdr_len)) { > > skb = idpf_rx_build_skb(hdr, hdr_len); > > if (!skb) > > break; > > u64_stats_update_begin(&rxq->stats_sync); > > u64_stats_inc(&rxq->q_stats.hsplit_pkts); > > u64_stats_update_end(&rxq->stats_sync); > > } > > > >> @@ -3413,24 +3340,24 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) > >> hdr->page = NULL; > >> > >> payload: > >> - if (pkt_len) { > >> - idpf_rx_sync_for_cpu(rx_buf, pkt_len); > >> - if (skb) > >> - idpf_rx_add_frag(rx_buf, skb, pkt_len); > >> - else > >> - skb = idpf_rx_construct_skb(rxq, rx_buf, > >> - pkt_len); > >> - } else { > >> - idpf_rx_put_page(rx_buf); > >> - } > >> + if (!libeth_rx_sync_for_cpu(rx_buf, pkt_len)) > >> + goto skip_data; > >> + > >> + if (skb) > >> + idpf_rx_add_frag(rx_buf, skb, pkt_len); > >> + else > >> + skb = idpf_rx_build_skb(rx_buf, pkt_len); > >> > >> /* exit if we failed to retrieve a buffer */ > >> if (!skb) > >> break; > >> > >> - idpf_rx_post_buf_refill(refillq, buf_id); > >> +skip_data: > >> + rx_buf->page = NULL; > >> > >> + idpf_rx_post_buf_refill(refillq, buf_id); > >> IDPF_RX_BUMP_NTC(rxq, ntc); > >> + > >> /* skip if it is non EOP desc */ > >> if (!idpf_rx_splitq_is_eop(rx_desc)) > >> continue; > > > > The code following this hunk, ending at line 3372, looks like this: > > > > /* pad skb if needed (to make valid ethernet frame) */ > > if (eth_skb_pad(skb)) { > > skb = NULL; > > continue; > > } > > /* probably a little skewed due to removing CRC */ > > total_rx_bytes += skb->len; > > > > Smatch warns that: > > .../idpf_txrx.c:3372 idpf_rx_splitq_clean() error: we previously assumed 'skb' could be null (see line 3321) > > > > I think, but am not sure, this is because it thinks skb might > > be NULL at the point where "goto skip_data;" is now called above. > > > > Could you look into this? > > This is actually a good catch. skb indeed could be NULL and we needed to > check that in the same condition where !eop is checked. > Fixed already in my tree, so it will be fixed in v2. Thanks for catching! > > (BTW I fixed that in iavf when submitting the libeth series, but forgot > to fix that here lol >_<) > (Also, it was implicitly fixed in the later commits where I convert skb > to xdp_buff here, so I didn't catch this one) Thanks, much appreciated. As I mentioned above, I wasn't sure about this one.