From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9984646D555 for ; Mon, 12 Oct 2026 08:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791793318; cv=none; b=lhsx9Tq1xbIvvgScJlu1fFa3XiudxODfPN/3TMterEJ0JXABIbZpJa/vwb2dQHvvBWcaQHcOwG7wo2JjFkxUZR1t0fIPihxL223Pw94/YoPyxZvwip/8wKTEaiiCoM6vVlujhSES/WwG2xlrmsiRfyszQ6HFQhhTr+3QSJg/TP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791793318; c=relaxed/simple; bh=57Zei123p9xWRFdldkMP4W3UF50+eUNVP3R3eVd94K0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RGp+xd09X9TFCWtsNPOLb47QLIzcUOV9Re80EM3Dh/gGwYnMup5ZsaZva56KhRzqPxk1tuxKRnheQyJFWWmfN6U68iuUWhqf5d4K5WsRi+/HCD8yP7gDLKiZrLG4473zDG5Su6jhTeNjgFtt9IqWeFuPgaOYBsO0PB66bgKyRS8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NZMqYmTV; arc=none smtp.client-ip=74.125.82.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NZMqYmTV" Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-3515266f6eeso3219879eec.0 for ; Mon, 12 Oct 2026 01:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1791793316; x=1792398116; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XSfzsz0eu9DYJ9q7ruuuzGdJdAhI+2e1gpy8B2gxhXU=; b=NZMqYmTV7H1a6TlVGHC8JlbaTaE78cBuG3sGCaImWNIqEMfa06aYMvNK8CPiUhOfrA K+TKqQfO+JYHAbrhv8ZsqixAxVEsdRBIndS5YNYwrZ1sx6dMHCJubS3YYa4T18PMYaCS 8Kgt+V4Q0ZUFsRgEtQw7sMovWzuOR+g4lZ0TnbNlzyIcoIq42tPmARoLiXPbqJuLyVx3 S0ULBsBY2G0SBdDfjBLu04knsB3YLWbXWEsCAccJqN71CTxD2l49e1+Tq6TH3YqCXkGv 6z1s/RB6Hb5muy8DOWmcWCdAKjLxisleqowYxPnYVg4Ws+R8SzS4wmXqX5+X1jX2VII/ bCNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791793316; x=1792398116; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XSfzsz0eu9DYJ9q7ruuuzGdJdAhI+2e1gpy8B2gxhXU=; b=zLL/JUeL7c7SttoI2DJoeIs78gMl38PkN6kKiec4wK1HTt3gqhK+D1+nZh+L63/fKi 1PRThL3qhy43eIqV85QlKsQKW79ketKpXds7Ek+4UQZAF4ScWG6fcXjDb5vvgZKMQpGk qVAoO16ennYLoWEc+KeQl2g3icb2YdWFoem2cP82g5qKpuXEfPBlkj9WECyFtr8GNc0l IdtDO0IPbrQjxouZ2R/ycx8wcOH/V73vilTojHx/BNGh8hw0ck3UBa2Ms/oiZjHk4boX lTqTFwQYGjuNNiXvRA4DBMQxs827Wwyobp2kWu58Fra/uxRMiQH+AIA+cysgD99WQXS0 gxqg== X-Forwarded-Encrypted: i=1; AKwUvBx6E3E0dFCw3q9aBm3gUMHqPbYlsw4SEDF/rlq7Oq4/S/H7XhQ8i5gnOeOhsSY5GB1CcEIdWfkx0IDlf8M=@vger.kernel.org X-Gm-Message-State: AFq9FYJOFTRbMErBbFTEJ52lXs7OXKCd97EGcsECaZgBoJpfMXyl0V1K IgXavTASJ6ZY5xkAJpdh9NW3qL2ut7Epw7VjJxRWdVprpgM8p3vcM+ErbJQ4U71mbPhtDXRTDRt f+KpYJ0nqk5pF7HEbKBhWMCth7g== X-Received: from dyay4.prod.google.com ([2002:a05:693c:62c4:b0:342:cdb2:3e44]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:152f:b0:351:7dc1:7aba with SMTP id 5a478bee46e88-3537e12becbmr10861813eec.32.1791793315255; Mon, 12 Oct 2026 01:21:55 -0700 (PDT) Date: Mon, 12 Oct 2026 08:21:47 +0000 In-Reply-To: <20261012082148.1698596-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20261012082148.1698596-1-almasrymina@google.com> X-Mailer: git-send-email 2.56.0.385.gd3acb90ef8-goog Message-ID: <20261012082148.1698596-6-almasrymina@google.com> Subject: [PATCH net-next v2 5/6] net: skbuff: use skb_frag_ref() in skb_try_coalesce() From: Mina Almasry To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org Cc: Mina Almasry , Ayush Sawal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tariq Toukan , Simon Horman , Steffen Klassert , Herbert Xu , Neal Cardwell , Kuniyuki Iwashima , John Fastabend , Sabrina Dubroca , Eric Biggers , Kees Cook , Aleksandr Loktionov , "=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?=" , Jijie Shao , Michael Grzeschik , Jakub Raczynski Content-Type: text/plain; charset="UTF-8" skb_pp_frag_ref() was introduced solely to work around skb_frag_ref() ignoring skb->pp_recycle and incrementing the non-pp backing refcount. Now that skb_frag_ref() handles both pp_recycle=1 and pp_recycle=0 symmetrically, call skb_frag_ref() directly in skb_try_coalesce() and remove skb_pp_frag_ref(). Assisted-by: LLM Signed-off-by: Mina Almasry --- net/core/skbuff.c | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index fe73f6e8d2b3e..20fca895d7090 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1078,37 +1078,6 @@ static bool skb_pp_recycle(struct sk_buff *skb, void *data) return napi_pp_put_page(page_to_netmem(virt_to_page(data))); } -/** - * skb_pp_frag_ref() - Increase fragment references of a page pool aware skb - * @skb: page pool aware skb - * - * Increase the fragment reference count (pp_ref_count) of a skb. This is - * intended to gain fragment references only for page pool aware skbs, - * i.e. when skb->pp_recycle is true, and not for fragments in a - * non-pp-recycling skb. It has a fallback to increase references on normal - * pages, as page pool aware skbs may also have normal page fragments. - */ -static int skb_pp_frag_ref(struct sk_buff *skb) -{ - struct skb_shared_info *shinfo; - netmem_ref head_netmem; - int i; - - if (!skb->pp_recycle) - return -EINVAL; - - shinfo = skb_shinfo(skb); - - for (i = 0; i < shinfo->nr_frags; i++) { - head_netmem = netmem_compound_head(shinfo->frags[i].netmem); - if (likely(netmem_is_pp(head_netmem))) - page_pool_ref_netmem(head_netmem); - else - page_ref_inc(netmem_to_page(head_netmem)); - } - return 0; -} - static void skb_kfree_head(void *head) { kfree(head); @@ -6309,10 +6278,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, /* if the skb is not cloned this does nothing * since we set nr_frags to 0. */ - if (skb_pp_frag_ref(from)) { - for (i = 0; i < from_shinfo->nr_frags; i++) - get_netmem(skb_frag_netmem(&from_shinfo->frags[i])); - } + for (i = 0; i < from_shinfo->nr_frags; i++) + skb_frag_ref(from, i); to->truesize += delta; to->len += len; -- 2.56.0.385.gd3acb90ef8-goog