Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp928661lqh; Sat, 1 Jun 2024 02:08:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkc9VVtyyb7MqqMvEO+Bb6nlW0YaoAq0tObnIvpdDtYHHaHLojiEIUPpI91d8ZiqOBnc19Z8qFs6OKYvI8VUZReLJum/hI/AhnOmvt1Q== X-Google-Smtp-Source: AGHT+IGW1uebm7G1NDgRHvbJJoUANRkVxqjLfDMBfhMwyyuy3y6SBCGooL7DPgar24KVJ62jwDCc X-Received: by 2002:a50:871d:0:b0:57a:3273:e646 with SMTP id 4fb4d7f45d1cf-57a3644a330mr2863935a12.26.1717232939626; Sat, 01 Jun 2024 02:08:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717232939; cv=pass; d=google.com; s=arc-20160816; b=EGlYPFXjDGY7oHEF+o6i9GGAwPJdxWydJUYdhGGqTv9Q5oM6t1/bpH9x0CMhw3MyLP KA7aMjS+yXdW/pqtrgdvRqNM1LYzrtwNOQzVC3mJ4i/UpsGeHgjary5uGpb3lt4quuIT jB2kC6HS7Yj4Dv2ogLqEsI45/rCnkdYtW9i+Zpbtm/h/xAK402Qe/tmEsp8zWECgZ88I sYRJpsFwkkOQAmkiWsnTdA/REpMSkfhhh+AumUe/01ZCRnwnvcuMPfFyvroatFtc7BXv BA77RCPQnzzvfxZ173+5r/YNW+ca3jpV/1556NZLYBxNw2I5ofXIsC/0gFlxWhlgaebJ 2u1Q== 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=FP5vrqphm7lrNRWTL8h0eTEP1JIZQhEYEXtXCIYQpCg=; fh=DgmPBOqxfGsYzr51ghNvawng7Aj1spTz/f7Wg4/F2JI=; b=i3K8z6dmfCHoy7ZF527Ok9HB8jucm8NWlrLMelIWPJnMHaspp+8IzRHJBwoA1jX8uT V5vPXcYDnu0cXkZsNMt8vqJoY4cf97j3XaNm/3FJ588kI4VsvFDskLoStgbY8fLlKOWd Gg5Jl4AU7vBojoKP+YXwg0icYlFmG7ZBr8ZepUVyLFb4/Vk6yldAE0rcUKVFj9nEJdBf kA7qDaL4b4uXpeowslcXf+rOIN9Ukkt+bOQeVED/RFIU2lirfclQse3v97EFAtnOypFH 0r9gP0YEURP2eVRfb/aiHwoM4ka+6qQ96KzZgK3M2C/LUM9pI9q5jObboEJd+rlPYTJH ZqfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tTQ2s5dF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197783-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c769f0si1839721a12.408.2024.06.01.02.08.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 02:08:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197783-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tTQ2s5dF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197783-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197783-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 509191F23254 for ; Sat, 1 Jun 2024 09:08:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32A8214E2D8; Sat, 1 Jun 2024 09:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tTQ2s5dF" 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 574B2111AD; Sat, 1 Jun 2024 09:08:47 +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=1717232927; cv=none; b=BTzfoW22w3/H8AeGT6CV3mStkpukLZSPkaTyeaJlQtTYx82A1FSyd31kwVmSgWWB0LUQlaUTNjRNPT5S6teHnf38Liu4JwNAzEIEAjcqrlWp09coJbpi41CAsetMdXGq7kYI4kVVaGi9IRG39zkIEojnkFRVRTNvxUUwjpGBcDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717232927; c=relaxed/simple; bh=h6AQp5HLvjkO9wvYFVJXTPoumQQtZPBpKKF3YIzdJKg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aBg3Zv5gLxCOjg0vB3AuTBNhlqQnC7jptUb1wUdrO2Mvuh4ddoxqez90LsHAKlF7nlH9xjSVGQqpxZWMLh4VufmLQEeml0WWkYbkO4pCpfkbvCcnFeuVp0N03CvAXaLRi8THBqHm5UNGmogF4SnourEov2HvxKySz0XhP1mLSr8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tTQ2s5dF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74123C116B1; Sat, 1 Jun 2024 09:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717232927; bh=h6AQp5HLvjkO9wvYFVJXTPoumQQtZPBpKKF3YIzdJKg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tTQ2s5dFr/GugcK3CbwhywDOpEVAtHJNGU9YAnPAUzWTAFiRVj3ZiC9Pzr1zszFCD WnVldec/W9TDLZX+1ZtNVEmiOTgx1Qnjl1OLQCjcIuFprUzcJO7p8uhpfMdZ3hjFAX Hx6RW/VBRHdYXp1oFxcKCEakd6RuY4vYYUzg57jQc3o9EXom/bJe/UZVHtEgUC+1ZF 2svOXpBiDvjHUKNpq2EgY+wRtaEKC3KOa4vbgEK33oy/ajbmF1UntJzhbSZ9Mw18Yi Nhz584MG7oMj2v7BPxOymUda20jbqFC/89SUUta4eqyb2R/dXeVbT6Egx9bWFDokO+ qHgILGYk5S1LQ== Date: Sat, 1 Jun 2024 10:08:42 +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: <20240601090842.GZ491852@kernel.org> References: <20240528134846.148890-1-aleksander.lobakin@intel.com> <20240528134846.148890-13-aleksander.lobakin@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: <20240528134846.148890-13-aleksander.lobakin@intel.com> + 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? ...