Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp345539lqj; Wed, 10 Apr 2024 12:08:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnsnQJEk2EyCspxPQFP+xpaadAb6kT761HMbrvUZAeO1Ihqg6tX65QxlsxVdMotxnJIvKwmSnefDuofhavaUrst+9yoGAJcjYaVzK9EQ== X-Google-Smtp-Source: AGHT+IH6xVzWspRYph/eTNoLwqnpdpYVRUr6MX4zUADHucfTbcH/sbhrC0iowVHWbj7wdI6uMSfp X-Received: by 2002:a17:903:1206:b0:1dc:cf38:3a77 with SMTP id l6-20020a170903120600b001dccf383a77mr3950469plh.55.1712776089646; Wed, 10 Apr 2024 12:08:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712776089; cv=pass; d=google.com; s=arc-20160816; b=eCH26kTOPkEngqfm6zCQ2iS2VxF6qa3yo+LCwkoQAxP8U+6EMo8pI+138K+Zd+uNuC 97fKyn4u2akm21OWrmqdd/GxMWH2nqu6g1LctKXZS/bryJKT1TXM7w5xcfZn+RADHYx3 ylZFZ+d6Upq/dnr3G2YhyWVvuxzg6wY+z1XKFChaURyZbpknNJiQwYqPBsX+dzfK70iN Bmed2FR8klzKUCw8/jsVcJMD8Aq4aw5eZKFrFBhad5x3BKo28/iswoTyO8HVT23ImxXG ctL8FT5ogXuIP+9dDxlUxKmPcMDh8osSWA0iM6buTz6xisIkXMBax/jeDwhCcIozgr3F eFZw== 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=oxaQI4auo1SjFFAAP72+VqUzLxxPiXgE3B3SX2nH8O4=; fh=ja8DoAg2gvQ63hE5c3emsmyllHFchGvyu1popbW+rTo=; b=OYsBJU+KP8ai5nIXQ9oJKYarKwe8ITqVMch9JoKCJwgmNLenLmCfLcaRrfh+XS7aki 1hk8MkumEVFsEeTEqKp0Swz7DFrUykc4xrRdXMj0in5tw5jMU9PoN4WKETAcQjqLFj9O htgr8e0r2bgMxlKthvhwsY+PqEWIts3ZxxNwtwLxOPhh/oYqB6Q0Gt8/iRnVwATvqPgh PksDOaIBTbI3DM09E+SOqC/sHYouRsPUwi8MofymZV/3+KS5UAW7rUBPS/VWj2HFyl45 M1yPIZ/BEmxW+1jDNxo41+VKTvd1NUL/G+/KHiWc4t/+a0MN2CU2NWfiK9C/BaJQ5VsY /KMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PVjYyAk6; 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-139241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 2-20020a170902ee4200b001e0d65a7fcbsi10821948plo.631.2024.04.10.12.08.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 12:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PVjYyAk6; 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-139241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139241-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9F30928CAFE for ; Wed, 10 Apr 2024 19:06:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E7A0181D0A; Wed, 10 Apr 2024 19:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PVjYyAk6" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 3B0AA181B83 for ; Wed, 10 Apr 2024 19:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775914; cv=none; b=Etl18YFJIuvzFRbuF+/tCx6MCwGhNkt/A8Ybn4Wk0GUlj+xsT7Ehi+Xgdu12mp6IOZSicrYACe4eC/Bv5BN+28I6/f7q+ziVWOWgkIEak3paAedgfu39dbQNTOFKqItDut3Jy6X0fHdhZTaihYjVkt4xbz5gAgQ4G9R02+QKZpk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775914; c=relaxed/simple; bh=QDCl4WcLdseIaPiDbfAkSfJlsOce2p8xYiRqYQl+B04=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Qb3ze0z9MUN79J5klfxD1peakb98GtHz2RKN/r/vu+ywrI9RJSbrBqwaft8gnjs9wcbQQrhx+T2tJuiyf1ArSeigxfwjvPuCpA/QNwb4UGefsHMjGORJsYNcLFu1hbdvt51n5QH2pN0rFAZtMQDo517z7P1RG7NqRj9GngTEWXo= 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=PVjYyAk6; arc=none smtp.client-ip=209.85.219.201 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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc693399655so12514125276.1 for ; Wed, 10 Apr 2024 12:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712775911; x=1713380711; 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=oxaQI4auo1SjFFAAP72+VqUzLxxPiXgE3B3SX2nH8O4=; b=PVjYyAk6vStsIcGW8m+a5kM7iA0y8QkQxnE8TnWaoepZMtZLX80HfPmyFhzFhncMwn 6kFU1LIfQnxv/v2vq4k+W9xVBwGj8/RgarXDM9l14EjnykMME72t30LgAYx2X4TS52YG O2uRXtGQJZda+cuXP3H/N36EOnYHz9UpSw8oI34+4IPkrgAOhUl62s+mOvzk3SjobsUr /iUfl3nJHXKwDjpz5MrC5IVxowfRgSnKzoMzncvydG636KApyEgsUP659tERIAkOZN09 XzOF71ZJpHZrvfhGGD23AZU9934Yb9we9HCfw/5TVPIRi0eJ2EXFnzP4NGSf9R+V/IZ2 LmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712775911; x=1713380711; 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=oxaQI4auo1SjFFAAP72+VqUzLxxPiXgE3B3SX2nH8O4=; b=KIWB7Vn1mOUbrqFqmglI4jZaU9MwmHtbgH4/8xdj5zT5ypjsw91zZZjkXiDcDGzA4y CrU5iHRLzacX32LdxW7gK0bcfraEk7E56B2P3bG4Nwl8fES8Ehc0OCHzLw7F9B5RhZAk 6qohPgzpUzQ9ClfphuRL8VAZ3/7H5mthUNbdH0/3+vBujHP9q2/2+PGpmacwaOzM4HZx eSoEwLPMFUQlMwpiXRVNCVXvHsN8DWqRV/tcXnJHHp8iPjsKCUcTlnPT9DAze6oeqwXU 2+eDOzsolyVa2p75slGM7U+y4xi5Fw+MVuKerzBKsahYkDAufGGRPFQe1gJ6lPlmeeSb iP3w== X-Gm-Message-State: AOJu0YxdTdvsJjC9MYCGOQLF3nh5x8OPYEfCG6F3vEEgx4iBJjKiKvB3 cDLDwV9bRT40ABTSPNZUaByN2Hz26Ecf85NZvRI7D4aaiUWRf5iDvq1NCj8J8LL4k3JUYfSWV3O Xrey9mQeI1YgcrJNBDIIqf1VgRBUA4kwjfOejMwVbcbk+RPmP+f98zDksZcO/KMcGfbndt72Imm JqnOiJez+H0MgWv0sfkBdE4S6Sd+YyQGK7XIMHJbS65pYbcJ+9DQSGTrbWHAfez9I82ic= X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:21f0:1a3a:493e:cf21]) (user=almasrymina job=sendgmr) by 2002:a05:6902:1081:b0:dc7:8e30:e2e3 with SMTP id v1-20020a056902108100b00dc78e30e2e3mr1011516ybu.2.1712775910843; Wed, 10 Apr 2024 12:05:10 -0700 (PDT) Date: Wed, 10 Apr 2024 12:05:01 -0700 In-Reply-To: <20240410190505.1225848-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: <20240410190505.1225848-1-almasrymina@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240410190505.1225848-2-almasrymina@google.com> Subject: [PATCH net-next v6 1/2] net: move skb ref helpers to new header From: Mina Almasry To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Mina Almasry , Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mirko Lindner , Stephen Hemminger , Tariq Toukan , Wei Liu , Paul Durrant , Steffen Klassert , Herbert Xu , David Ahern , Boris Pismenny , John Fastabend , Dragos Tatulea Content-Type: text/plain; charset="UTF-8" Add a new header, linux/skbuff_ref.h, which contains all the skb_*_ref() helpers. Many of the consumers of skbuff.h do not actually use any of the skb ref helpers, and we can speed up compilation a bit by minimizing this header file. Additionally in the later patch in the series we add page_pool support to skb_frag_ref(), which requires some page_pool dependencies. We can now add these dependencies to skbuff_ref.h instead of a very ubiquitous skbuff.h Signed-off-by: Mina Almasry --- .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 1 + drivers/net/ethernet/marvell/sky2.c | 1 + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 1 + drivers/net/ethernet/sun/cassini.c | 1 + drivers/net/veth.c | 1 + drivers/net/xen-netback/netback.c | 1 + include/linux/skbuff.h | 63 ---------------- include/linux/skbuff_ref.h | 75 +++++++++++++++++++ net/core/gro.c | 1 + net/core/skbuff.c | 1 + net/ipv4/esp4.c | 1 + net/ipv4/tcp_output.c | 1 + net/ipv6/esp6.c | 1 + net/tls/tls_device.c | 1 + net/tls/tls_device_fallback.c | 1 + net/tls/tls_strp.c | 1 + 16 files changed, 89 insertions(+), 63 deletions(-) create mode 100644 include/linux/skbuff_ref.h diff --git a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c index 6482728794dd..e8e460a92e0e 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "chcr_ktls.h" static LIST_HEAD(uld_ctx_list); diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 07720841a8d7..f3f7f4cc27b3 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -34,6 +34,7 @@ #include #include #include +#include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index eac49657bd07..8328df8645d5 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #if IS_ENABLED(CONFIG_IPV6) diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index bfb903506367..8f1f43dbb76d 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/veth.c b/drivers/net/veth.c index bcdfbf61eb66..426e68a95067 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #define DRV_NAME "veth" diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index ef76850d9bcd..48254fc07d64 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -38,6 +38,7 @@ #include #include #include +#include #include diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 7135a3e94afd..4072a7ee3859 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3492,73 +3492,10 @@ static inline struct page *skb_frag_page(const skb_frag_t *frag) return netmem_to_page(frag->netmem); } -/** - * __skb_frag_ref - take an addition reference on a paged fragment. - * @frag: the paged fragment - * - * Takes an additional reference on the paged fragment @frag. - */ -static inline void __skb_frag_ref(skb_frag_t *frag) -{ - get_page(skb_frag_page(frag)); -} - -/** - * skb_frag_ref - take an addition reference on a paged fragment of an skb. - * @skb: the buffer - * @f: the fragment offset. - * - * Takes an additional reference on the @f'th paged fragment of @skb. - */ -static inline void skb_frag_ref(struct sk_buff *skb, int f) -{ - __skb_frag_ref(&skb_shinfo(skb)->frags[f]); -} - int skb_pp_cow_data(struct page_pool *pool, struct sk_buff **pskb, unsigned int headroom); int skb_cow_data_for_xdp(struct page_pool *pool, struct sk_buff **pskb, struct bpf_prog *prog); -bool napi_pp_put_page(struct page *page); - -static inline void -skb_page_unref(struct page *page, bool recycle) -{ -#ifdef CONFIG_PAGE_POOL - if (recycle && napi_pp_put_page(page)) - return; -#endif - put_page(page); -} - -/** - * __skb_frag_unref - release a reference on a paged fragment. - * @frag: the paged fragment - * @recycle: recycle the page if allocated via page_pool - * - * Releases a reference on the paged fragment @frag - * or recycles the page via the page_pool API. - */ -static inline void __skb_frag_unref(skb_frag_t *frag, bool recycle) -{ - skb_page_unref(skb_frag_page(frag), recycle); -} - -/** - * skb_frag_unref - release a reference on a paged fragment of an skb. - * @skb: the buffer - * @f: the fragment offset - * - * Releases a reference on the @f'th paged fragment of @skb. - */ -static inline void skb_frag_unref(struct sk_buff *skb, int f) -{ - struct skb_shared_info *shinfo = skb_shinfo(skb); - - if (!skb_zcopy_managed(skb)) - __skb_frag_unref(&shinfo->frags[f], skb->pp_recycle); -} - /** * skb_frag_address - gets the address of the data contained in a paged fragment * @frag: the paged fragment buffer diff --git a/include/linux/skbuff_ref.h b/include/linux/skbuff_ref.h new file mode 100644 index 000000000000..11f0a4063403 --- /dev/null +++ b/include/linux/skbuff_ref.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Skb ref helpers. + * + */ + +#ifndef _LINUX_SKBUFF_REF_H +#define _LINUX_SKBUFF_REF_H + +#include + +/** + * __skb_frag_ref - take an addition reference on a paged fragment. + * @frag: the paged fragment + * + * Takes an additional reference on the paged fragment @frag. + */ +static inline void __skb_frag_ref(skb_frag_t *frag) +{ + get_page(skb_frag_page(frag)); +} + +/** + * skb_frag_ref - take an addition reference on a paged fragment of an skb. + * @skb: the buffer + * @f: the fragment offset. + * + * Takes an additional reference on the @f'th paged fragment of @skb. + */ +static inline void skb_frag_ref(struct sk_buff *skb, int f) +{ + __skb_frag_ref(&skb_shinfo(skb)->frags[f]); +} + +bool napi_pp_put_page(struct page *page); + +static inline void +skb_page_unref(struct page *page, bool recycle) +{ +#ifdef CONFIG_PAGE_POOL + if (recycle && napi_pp_put_page(page)) + return; +#endif + put_page(page); +} + +/** + * __skb_frag_unref - release a reference on a paged fragment. + * @frag: the paged fragment + * @recycle: recycle the page if allocated via page_pool + * + * Releases a reference on the paged fragment @frag + * or recycles the page via the page_pool API. + */ +static inline void __skb_frag_unref(skb_frag_t *frag, bool recycle) +{ + skb_page_unref(skb_frag_page(frag), recycle); +} + +/** + * skb_frag_unref - release a reference on a paged fragment of an skb. + * @skb: the buffer + * @f: the fragment offset + * + * Releases a reference on the @f'th paged fragment of @skb. + */ +static inline void skb_frag_unref(struct sk_buff *skb, int f) +{ + struct skb_shared_info *shinfo = skb_shinfo(skb); + + if (!skb_zcopy_managed(skb)) + __skb_frag_unref(&shinfo->frags[f], skb->pp_recycle); +} + +#endif /* _LINUX_SKBUFF_REF_H */ diff --git a/net/core/gro.c b/net/core/gro.c index 83f35d99a682..2459ab697f7f 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -3,6 +3,7 @@ #include #include #include +#include #define MAX_GRO_SKBS 8 diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 888874ef8566..38c09a70adc1 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -51,6 +51,7 @@ #endif #include #include +#include #include #include #include diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 40330253f076..dff04580318f 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 9282fafc0e61..61119d42b0fd 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -44,6 +44,7 @@ #include #include #include +#include #include diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index fb431d0a3475..6bc0a84c8d05 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -36,6 +36,7 @@ #include #include #include +#include #include diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index bf8ed36b1ad6..ab6e694f7bc2 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "tls.h" #include "trace.h" diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c index 4e7228f275fa..f9e3d3d90dcf 100644 --- a/net/tls/tls_device_fallback.c +++ b/net/tls/tls_device_fallback.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "tls.h" diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c index ca1e0e198ceb..58c4b06f4f0c 100644 --- a/net/tls/tls_strp.c +++ b/net/tls/tls_strp.c @@ -2,6 +2,7 @@ /* Copyright (c) 2016 Tom Herbert */ #include +#include #include #include #include -- 2.44.0.478.gd926399ef9-goog