linux/include/net/netns
Kuniyuki Iwashima b6e8113830 af_unix: Define a per-netns hash table.
This commit adds a per netns hash table for AF_UNIX, which size is fixed
as UNIX_HASH_SIZE for now.

The first implementation defines a per-netns hash table as a single array
of lock and list:

	struct unix_hashbucket {
		spinlock_t		lock;
		struct hlist_head	head;
	};

	struct netns_unix {
		struct unix_hashbucket	*hash;
		...
	};

But, Eric pointed out memory cost that the structure has holes because of
sizeof(spinlock_t), which is 4 (or more if LOCKDEP is enabled). [0]  It
could be expensive on a host with thousands of netns and few AF_UNIX
sockets.  For this reason, a per-netns hash table uses two dense arrays.

	struct unix_table {
		spinlock_t		*locks;
		struct hlist_head	*buckets;
	};

	struct netns_unix {
		struct unix_table	table;
		...
	};

Note the length of the list has a significant impact rather than lock
contention, so having shared locks can be an option.  But, per-netns
locks and lists still perform better than the global locks and per-netns
lists. [1]

Also, this patch adds a change so that struct netns_unix disappears from
struct net if CONFIG_UNIX is disabled.

[0]: https://lore.kernel.org/netdev/CANn89iLVxO5aqx16azNU7p7Z-nz5NrnM5QTqOzueVxEnkVTxyg@mail.gmail.com/
[1]: https://lore.kernel.org/netdev/20220617175215.1769-1-kuniyu@amazon.com/

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-06-22 12:59:43 +01:00
..
bpf.h bpf: Invert the dependency between bpf-netns.h and netns/bpf.h 2021-12-29 20:03:05 -08:00
can.h can: remove obsolete version strings 2020-10-12 10:06:39 +02:00
conntrack.h netfilter: nfnetlink: allow to detect if ctnetlink listeners exist 2022-05-13 18:56:28 +02:00
core.h txhash: Make rethinking txhash behavior configurable via sysctl 2022-01-31 15:05:24 +00:00
generic.h
hash.h netns: provide pure entropy for net_hash_mix() 2019-03-28 17:00:45 -07:00
ieee802154_6lowpan.h net: dynamically allocate fqdir structures 2019-05-26 14:08:05 -07:00
ipv4.h tcp: adjust TSO packet sizes based on min_rtt 2022-03-09 20:05:44 -08:00
ipv6.h ipv6: make ip6_rt_gc_expire an atomic_t 2022-04-15 14:28:50 -07:00
mctp.h mctp: Allow per-netns default networks 2021-07-29 15:06:50 +01:00
mib.h net: reorganize fields in netns_mib 2021-04-02 14:31:44 -07:00
mpls.h
netfilter.h netfilter: conntrack: fix boot failure with nf_conntrack.enable_hooks=1 2021-09-28 13:04:55 +02:00
nexthop.h nexthop: Convert to blocking notification chain 2020-09-15 16:31:17 -07:00
nftables.h net: remove obsolete members from struct net 2021-04-06 00:34:53 +02:00
packet.h
sctp.h sctp: add probe_interval in sysctl and sock/asoc/transport 2021-06-22 11:28:51 -07:00
smc.h net/smc: add sysctl for autocorking 2022-03-01 14:25:12 +00:00
unix.h af_unix: Define a per-netns hash table. 2022-06-22 12:59:43 +01:00
xdp.h net: xsk: track AF_XDP sockets on a per-netns list 2019-01-25 01:50:03 +01:00
xfrm.h xfrm: rework default policy structure 2022-03-18 07:23:12 +01:00