Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1423688lqe; Mon, 8 Apr 2024 08:30:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfwwaZIQx4ZKNMXclJT0ju/YvSzDRmRAxgMhZ+p7hFCVouF87tmIwLNrpK8ij2NrQGcBQq80Oxh5rrxY+XTMUyltRhT1DAsv75VDm7QA== X-Google-Smtp-Source: AGHT+IFjTbr2x0zU9FPbswynAAAa159cqFvjSlIb3eGz+M2zI6HeqCicCa0HRhPVTvjaiPAsgywz X-Received: by 2002:a05:620a:2993:b0:78d:61fe:77c6 with SMTP id r19-20020a05620a299300b0078d61fe77c6mr30102qkp.2.1712590231270; Mon, 08 Apr 2024 08:30:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712590231; cv=pass; d=google.com; s=arc-20160816; b=Nzw8rYKynTazkjveMn5Dq0HNXnVnBay4zuhPftEbPVjyk4KVxjqHiL8Jf5fqSgC/ip DGTRjJJP/VBNCilBgoWuxs/kxQkYWMFEaihLlCUdBBj4s0dnojojaVakwVbLa2dnsiy5 IcRn49pk5B34LqQrv50hTEBNmppZUuR0dvp7CTUIXa3DqFgf6nkjXHmcU/OSz+UeD7Eg L2WMn4O7pljuO7gZ46Jd1u4asqewU9d8dqcz8gB7oLfLYjXES5DNHvYyfKuXtujhb3gp ZhUkqZGdZ2CzMxMtpT/OplCQWEUEULW4M9C/HLmApn/jlxPbzY0m/Wly+Mlj+c5N+44G jTeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=5ASL93255NaCWCo+CYsAiAClfDvlTbN+MqYwKv6ZLMw=; fh=PWid1ShKhcXDJYWi+i3HfsYn1GZN7oL3U2YWFw6DUMs=; b=IjQpju+NKNKzc8MVF/HUTYBliM0Us8VM5n09l5bU/llxuv3STb4K6otKjzERW3Iso6 7zis6CrL4AGxcVrrJWLqpkc39kwgR5uLmYHIwmp0PCv2pIcVL6a5CPc3DBr3WFDTLwdd ICmVYzZ+X1EmknrjgYXrE1WRPSU9nBH+vMS7XInPwTmWkGPQdY7OAKuuxvzPqBMc4yQf +cwZGwHPNLtMuLO/SSYKZ+TNu+0Qwzv9DAcwrvH1RH0gQ0vGWeO4wrLOItvwNTf0jLeD WvDbLFS9LOQB+qGe3c/6QO9qVxej6QAaS81GEV9wm8tJROHoGAvV9NhWGOUHtkGRhkar J9Ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DTY9sboM; arc=pass (i=1 spf=pass spfdomain=flex--almasrymina.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-135602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bj11-20020a05620a190b00b0078beb0772f4si8867864qkb.311.2024.04.08.08.30.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 08:30:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DTY9sboM; arc=pass (i=1 spf=pass spfdomain=flex--almasrymina.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-135602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C61781C23BE4 for ; Mon, 8 Apr 2024 15:30:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01BD01411E1; Mon, 8 Apr 2024 15:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DTY9sboM" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 72730140E29 for ; Mon, 8 Apr 2024 15:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712590208; cv=none; b=PaPt+iOTX5jScWlnPFGbl+9yw281N2Y0xwgmUs9MnpQ0vXrsYE8AGE1CNzG3v9rytE52jGMVQptLG8Qm8IJXuBxL7glYxHO3NfpZ3Z9jYDybuhTZb2nlGfN/ZGfnAS5SNRCUwY5cxGSBXJvbmGmx87Nk/L6ISvONXHXyO8bfgCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712590208; c=relaxed/simple; bh=Smf4aywmigwysrSIcOcqw9bvaWWtvxCh+z00bSuHAcY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hrQut2OPBZM6RJlRFVADZarnYUPdAdLQtKwiIb5ms1eDsDqYXb1QjpJhL7otg5esbvtBY4rq6rvEj3feslCQTuksXwyT8oitLE1RXugRlWqVy3B67xvTKhQyLzpOoZNs+lKMfpdB3/dLdSVYgTNT1JAcY/aD0gf1RmXgkEoiuUw= 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=DTY9sboM; arc=none smtp.client-ip=209.85.128.202 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-617fffab703so20542447b3.0 for ; Mon, 08 Apr 2024 08:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712590205; x=1713195005; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5ASL93255NaCWCo+CYsAiAClfDvlTbN+MqYwKv6ZLMw=; b=DTY9sboMOAOcwqlrn3sZHNftQ2BkhbFHzYAvsZNA/gLR7+w4BOI1usMRk2TOG3vLDT WMFLaxI6BX+4faSeTIDZ85Cdo+yQRjh2qKCGyjXbU/LQSMWaMAFdn+VjUB2/9J+8ml4P yAlAZSxHDbvFukxxhi/MmGf5JBYIVixyvVB+S1TvFJHQBtt7dkK2kId6bbwQGsl2TOsM TYC1qoTbIzjL1kLz2KFjP/kyLGRKi5byYkUMrvNt4LFWakFGD4yxYlCBYsYyUb0mqxSB FvDHv3Ktug+l3RMjq2y2GBwG0xrFbhEpGnEeQlqnBqJnBrkhX6LHLoOKNrQWxYxfe3Lz 3jXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712590205; x=1713195005; h=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; bh=5ASL93255NaCWCo+CYsAiAClfDvlTbN+MqYwKv6ZLMw=; b=ITaX0hB/IeXbULZz32GV1QUfjaP7tk4r4mzz3+SBThs34uhWtxxt33TzKQ0kE2EWf0 Vmbm827Krfa5fp17IYjF8qEVkC8gAuFZj0bae9NgHRKl3WkJR+k2n+2cSwr5PzmYGg+u W11KDTMU/52K54ltOlChtx+Eohjg4YH8p+bZGNVT6mKupbHxZtEMOt68pWxE2UPM0qsp OnB9l3BrHuoI52bqedtOMJQI6X9L+m/RXVmZe/b6QYD9ri3Dyfdn0cQ/79F116yHZM2j DsF5cwTTRS0GlJf7f6GIqQE7lf8pAx7yts46A9oLGWcvoVQWwJXpFTXuub4EHHMftir/ wSuQ== X-Forwarded-Encrypted: i=1; AJvYcCXIp4JXmOd79jlA8R2SJuQ6El/z0ONl5d6sYdpwEmLPYAueNkoRBlP2nr+GhcDNkhMNVntgMvN8nISMUG7j2/ZfM3Xr7oZ+Z++UnUTq X-Gm-Message-State: AOJu0Ywhqc/AySo4xUfhSOrYU/TUdgsP/ymaanIfN+AwdaQz78Jokoy5 lPmgd5jq7carG9Zc27z43/K9prYMCpxo4oxAP+LpT5IF6B6gZwfQAjmQwLkLSPtkkkeZsgRDZ+Q K4SM+bS/RrSAy5MH7zWFDyw== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:ca23:d62d:de32:7c93]) (user=almasrymina job=sendgmr) by 2002:a05:6902:1108:b0:dc7:865b:22c6 with SMTP id o8-20020a056902110800b00dc7865b22c6mr721592ybu.8.1712590205499; Mon, 08 Apr 2024 08:30:05 -0700 (PDT) Date: Mon, 8 Apr 2024 08:29:56 -0700 In-Reply-To: <20240408153000.2152844-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: <20240408153000.2152844-1-almasrymina@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240408153000.2152844-2-almasrymina@google.com> Subject: [PATCH net-next v5 1/3] net: make napi_frag_unref reuse skb_page_unref From: Mina Almasry To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mina Almasry , Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Ilias Apalodimas , Steffen Klassert , Herbert Xu , David Ahern , Boris Pismenny , John Fastabend , Dragos Tatulea Content-Type: text/plain; charset="UTF-8" The implementations of these 2 functions are almost identical. Remove the implementation of napi_frag_unref, and make it a call into skb_page_unref so we don't duplicate the implementation. Signed-off-by: Mina Almasry Reviewed-by: Eric Dumazet --- include/linux/skbuff.h | 12 +++--------- net/ipv4/esp4.c | 2 +- net/ipv6/esp6.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 7dfb906d92f7..c0ff85bb087a 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3522,10 +3522,10 @@ int skb_cow_data_for_xdp(struct page_pool *pool, struct sk_buff **pskb, bool napi_pp_put_page(struct page *page); static inline void -skb_page_unref(const struct sk_buff *skb, struct page *page) +skb_page_unref(struct page *page, bool recycle) { #ifdef CONFIG_PAGE_POOL - if (skb->pp_recycle && napi_pp_put_page(page)) + if (recycle && napi_pp_put_page(page)) return; #endif put_page(page); @@ -3534,13 +3534,7 @@ skb_page_unref(const struct sk_buff *skb, struct page *page) static inline void napi_frag_unref(skb_frag_t *frag, bool recycle) { - struct page *page = skb_frag_page(frag); - -#ifdef CONFIG_PAGE_POOL - if (recycle && napi_pp_put_page(page)) - return; -#endif - put_page(page); + skb_page_unref(skb_frag_page(frag), recycle); } /** diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 3d647c9a7a21..40330253f076 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -114,7 +114,7 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb) */ if (req->src != req->dst) for (sg = sg_next(req->src); sg; sg = sg_next(sg)) - skb_page_unref(skb, sg_page(sg)); + skb_page_unref(sg_page(sg), skb->pp_recycle); } #ifdef CONFIG_INET_ESPINTCP diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index fe8d53f5a5ee..fb431d0a3475 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -131,7 +131,7 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb) */ if (req->src != req->dst) for (sg = sg_next(req->src); sg; sg = sg_next(sg)) - skb_page_unref(skb, sg_page(sg)); + skb_page_unref(sg_page(sg), skb->pp_recycle); } #ifdef CONFIG_INET6_ESPINTCP -- 2.44.0.478.gd926399ef9-goog