Commit c60c34a9 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-better-packing-of-global-vars'

Eric Dumazet says:

====================
net: better packing of global vars

First two patches avoid holes in data section,
and last patch makes sure some siphash keys are contained
in a single cache line.
====================

Link: https://lore.kernel.org/r/20211115172303.3732746-1-eric.dumazet@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 62803fec 49ecc2e9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4942,7 +4942,7 @@ void netdev_info(const struct net_device *dev, const char *format, ...);

#define netdev_level_once(level, dev, fmt, ...)			\
do {								\
	static bool __print_once __read_mostly;			\
	static bool __section(".data.once") __print_once;	\
								\
	if (!__print_once) {					\
		__print_once = true;				\
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ void __do_once_done(bool *done, struct static_key_true *once_key,
#define DO_ONCE(func, ...)						     \
	({								     \
		bool ___ret = false;					     \
		static bool ___done = false;				     \
		static bool __section(".data.once") ___done = false;	     \
		static DEFINE_STATIC_KEY_TRUE(___once_key);		     \
		if (static_branch_unlikely(&___once_key)) {		     \
			unsigned long ___flags;				     \
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ typedef struct {
	u64 key[2];
} siphash_key_t;

#define siphash_aligned_key_t siphash_key_t __aligned(16)

static inline bool siphash_key_is_zero(const siphash_key_t *key)
{
	return !(key->key[0] | key->key[1]);
+1 −1
Original line number Diff line number Diff line
@@ -1460,7 +1460,7 @@ bool __skb_flow_dissect(const struct net *net,
}
EXPORT_SYMBOL(__skb_flow_dissect);

static siphash_key_t hashrnd __read_mostly;
static siphash_aligned_key_t hashrnd;
static __always_inline void __flow_hash_secret_init(void)
{
	net_get_random_once(&hashrnd, sizeof(hashrnd));
+2 −2
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@
#include <linux/in6.h>
#include <net/tcp.h>

static siphash_key_t net_secret __read_mostly;
static siphash_key_t ts_secret __read_mostly;
static siphash_aligned_key_t net_secret;
static siphash_aligned_key_t ts_secret;

static __always_inline void net_secret_init(void)
{
Loading