From 12a7cdaeee1c9e31aafda4708bbdb309cac619d6 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 30 Jun 2017 09:23:57 +0800 Subject: [PATCH] route: Cache align statistics. Though these statistics are rarely updated; better safe the sorry. Since it changes userland visible structure size, bump __DragonFly_version. --- sys/net/route.c | 2 +- sys/net/route.h | 7 ++++++- sys/sys/param.h | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index cf376b88ec..0fbc7b4c80 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -92,7 +92,7 @@ #include #endif -static struct rtstatistics rtstatistics_percpu[MAXCPU]; +static struct rtstatistics rtstatistics_percpu[MAXCPU] __cachealign; #define rtstat rtstatistics_percpu[mycpuid] struct radix_node_head *rt_tables[MAXCPU][AF_MAX+1]; diff --git a/sys/net/route.h b/sys/net/route.h index cf73803216..6ee8b5835d 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -209,13 +209,18 @@ struct ortentry { /* * Routing statistics. */ -struct rtstatistics { +struct rtstatistics { u_long rts_badredirect; /* bogus redirect calls */ u_long rts_dynamic; /* routes created by redirects */ u_long rts_newgateway; /* routes modified by redirects */ u_long rts_unreach; /* lookups which failed */ u_long rts_wildcard; /* lookups satisfied by a wildcard */ + u_long rts_pad[3]; /* pad to cache line size (64B) */ }; +#ifdef _KERNEL +CTASSERT((sizeof(struct rtstatistics) & __VM_CACHELINE_MASK) == 0); +#endif + /* * Structures for routing messages. */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 6ce0753d30..49bbe40b75 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -153,9 +153,10 @@ * 400901 - moved sigtramp, NX protection + associated sysctls * 400902 - change CPU_SETSIZE to signed; allow proc to change self affinity * 400903 - malloc_type cleanup + * 400904 - pad rtstatistics */ #undef __DragonFly_version -#define __DragonFly_version 400903 /* propagated to newvers */ +#define __DragonFly_version 400904 /* propagated to newvers */ #include -- 2.11.4.GIT