Skip to contentSkip to conversation

lighten uapi/bpf.h rebuilds

PATCH Applied Jakub Kicinski 3 participants 5 messages Dec 30, 2021 – Jan 6, 2022

Subsystems (12)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

v2 cover lighten uapi/bpf.h rebuilds

Last change in the bpf headers - disentangling BPF uapi from netdevice.h. Both linux/bpf.h and uapi/bpf.h changes should now rebuild ~1k objects down from the original ~18k. There's probably more that can be done but it's diminishing returns.

Split into two patches for ease of review.

Jakub Kicinski (2):
net: add includes masked by netdevice.h including uapi/bpf.h
bpf: invert the dependency between bpf-netns.h and netns/bpf.h

 drivers/net/ethernet/amazon/ena/ena_netdev.h       | 1 +
 drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 1 +
 drivers/net/ethernet/microsoft/mana/mana_en.c      | 2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       | 1 +
 drivers/net/ethernet/ti/cpsw_priv.h                | 2 ++
 include/linux/bpf-netns.h                          | 8 +-------
 include/net/ip6_fib.h                              | 1 +
 include/net/netns/bpf.h                            | 9 ++++++++-
 kernel/bpf/net_namespace.c                         | 1 +
 9 files changed, 18 insertions(+), 8 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH v2 1/2 net: add includes masked by netdevice.h including uapi/bpf.h

Add missing includes unmasked by the subsequent change.

Mostly network drivers missing an include for XDP_PACKET_HEADROOM.

---
v2:
- fix buildbot's randconfig failure in ipv6

---
 drivers/net/ethernet/amazon/ena/ena_netdev.h       | 1 +
 drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 1 +
 drivers/net/ethernet/microsoft/mana/mana_en.c      | 2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       | 1 +
 drivers/net/ethernet/ti/cpsw_priv.h                | 2 ++
 include/net/ip6_fib.h                              | 1 +
 kernel/bpf/net_namespace.c                         | 1 +
 7 files changed, 9 insertions(+)
drivers/net/ethernet/amazon/ena/ena_netdev.h +1 -0
index 0c39fc2fa345..9391c7101fba 100644
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <uapi/linux/bpf.h>
 
 #include "ena_com.h"
 #include "ena_eth_com.h"
drivers/net/ethernet/cavium/thunder/nicvf_queues.c +1 -0
index 50bbe79fb93d..4367edbdd579 100644
@@ -10,6 +10,7 @@
 #include <linux/iommu.h>
 #include <net/ip.h>
 #include <net/tso.h>
+#include <uapi/linux/bpf.h>
 
 #include "nic_reg.h"
 #include "nic.h"
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -0
index c1d5a374b967..2ece9e90dc50 100644
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /* Copyright (c) 2021, Microsoft Corporation. */
 
+#include <uapi/linux/bpf.h>
+
 #include <linux/inetdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
drivers/net/ethernet/stmicro/stmmac/stmmac.h +1 -0
index 4f5292cadf54..d42b6af32d6e 100644
@@ -22,6 +22,7 @@
 #include <linux/net_tstamp.h>
 #include <linux/reset.h>
 #include <net/page_pool.h>
+#include <uapi/linux/bpf.h>
 
 struct stmmac_resources {
 	void __iomem *addr;
drivers/net/ethernet/ti/cpsw_priv.h +2 -0
index f33c882eb70e..74555970730c 100644
@@ -6,6 +6,8 @@
 #ifndef DRIVERS_NET_ETHERNET_TI_CPSW_PRIV_H_
 #define DRIVERS_NET_ETHERNET_TI_CPSW_PRIV_H_
 
+#include <uapi/linux/bpf.h>
+
 #include "davinci_cpdma.h"
 
 #define CPSW_DEBUG	(NETIF_MSG_HW		| NETIF_MSG_WOL		| \
include/net/ip6_fib.h +1 -0
index 83b8070d1cc9..a9a4ccc0cdb5 100644
@@ -20,6 +20,7 @@
 #include <net/inetpeer.h>
 #include <net/fib_notifier.h>
 #include <linux/indirect_call_wrapper.h>
+#include <uapi/linux/bpf.h>
 
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
 #define FIB6_TABLE_HASHSZ 256
kernel/bpf/net_namespace.c +1 -0
index 542f275bf252..868cc2c43899 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include <linux/bpf.h>
+#include <linux/bpf-netns.h>
 #include <linux/filter.h>
 #include <net/net_namespace.h>
 
Signature · 1 line
2.31.1
maintainer Acked-by on v2 1/2
#2 lore raw

Re: [PATCH bpf-next v2 1/2] net: add includes masked by netdevice.h including uapi/bpf.h

Quoted 5 lines · Jakub Kicinski

Add missing includes unmasked by the subsequent change.

Mostly network drivers missing an include for XDP_PACKET_HEADROOM.

[...]

Quoted 1 line
 drivers/net/ethernet/microsoft/mana/mana_en.c      | 2 ++

This seems trivially correct, so in case an ack is needed:

Quoted 13 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -0
index c1d5a374b967..2ece9e90dc50 100644
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /* Copyright (c) 2021, Microsoft Corporation. */
 
+#include <uapi/linux/bpf.h>
+
 #include <linux/inetdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
author maintainer
#3 lore raw

PATCH v2 2/2 bpf: invert the dependency between bpf-netns.h and netns/bpf.h

In reply to Jakub Kicinski

netns/bpf.h gets included by netdevice.h (thru net_namespace.h) which in turn gets included in a lot of places. We should keep netns/bpf.h as light-weight as possible.

bpf-netns.h seems to contain more implementation details than deserves to be included in a netns header. It needs to pull in uapi/bpf.h to get various enum types.

Move enum netns_bpf_attach_type to netns/bpf.h and invert the dependency. This makes netns/bpf.h fit the mold of a struct definition header more clearly, and drops the number of objects rebuilt when uapi/bpf.h is touched from 7.7k to 1.1k.

---
 include/linux/bpf-netns.h | 8 +-------
 include/net/netns/bpf.h   | 9 ++++++++-
 2 files changed, 9 insertions(+), 8 deletions(-)
include/linux/bpf-netns.h +1 -7
index 722f799c1a2e..413cfa5e4b07 100644
@@ -3,15 +3,9 @@
 #define _BPF_NETNS_H
 
 #include <linux/mutex.h>
+#include <net/netns/bpf.h>
 #include <uapi/linux/bpf.h>
 
-enum netns_bpf_attach_type {
-	NETNS_BPF_INVALID = -1,
-	NETNS_BPF_FLOW_DISSECTOR = 0,
-	NETNS_BPF_SK_LOOKUP,
-	MAX_NETNS_BPF_ATTACH_TYPE
-};
-
 static inline enum netns_bpf_attach_type
 to_netns_bpf_attach_type(enum bpf_attach_type attach_type)
 {
include/net/netns/bpf.h +8 -1
index 0ca6a1b87185..2c01a278d1eb 100644
@@ -6,11 +6,18 @@
 #ifndef __NETNS_BPF_H__
 #define __NETNS_BPF_H__
 
-#include <linux/bpf-netns.h>
+#include <linux/list.h>
 
 struct bpf_prog;
 struct bpf_prog_array;
 
+enum netns_bpf_attach_type {
+	NETNS_BPF_INVALID = -1,
+	NETNS_BPF_FLOW_DISSECTOR = 0,
+	NETNS_BPF_SK_LOOKUP,
+	MAX_NETNS_BPF_ATTACH_TYPE
+};
+
 struct netns_bpf {
 	/* Array of programs to run compiled from progs or links */
 	struct bpf_prog_array __rcu *run_array[MAX_NETNS_BPF_ATTACH_TYPE];
Signature · 1 line
2.31.1
#4 lore raw
In reply to Jakub Kicinski
Quoted 7 lines · Jakub Kicinski

Last change in the bpf headers - disentangling BPF uapi from netdevice.h. Both linux/bpf.h and uapi/bpf.h changes should now rebuild ~1k objects down from the original ~18k. There's probably more that can be done but it's diminishing returns.

Split into two patches for ease of review.

Applied. Thanks