From: Alessio Podda Date: Mon, 19 Jan 2026 09:36:53 +0000 (+0100) Subject: Align zone refcount and dblock X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0189255211c30863fec5c3dcfbe13aa841e5c49;p=thirdparty%2Fbind9.git Align zone refcount and dblock The zone refcount and the dblock are pretty contended in setups serving few big zones, such as TLDs. We add alignment to both in order to prevent false sharing between the two. --- diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 104199c2255..78f40729708 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -475,7 +475,8 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, isc_tid_t tid) { REQUIRE(mctx != NULL); now = isc_time_now(); - zone = isc_mem_get(mctx, sizeof(*zone)); + zone = isc_mem_getx(mctx, sizeof(*zone), + ISC_MEM_ALIGN(ISC_OS_CACHELINE_SIZE)); *zone = (dns_zone_t){ .masterformat = dns_masterformat_none, .journalsize = -1, @@ -730,7 +731,10 @@ dns__zone_free(dns_zone_t *zone) { ZONEDB_DESTROYLOCK(&zone->dblock); isc_mutex_destroy(&zone->lock); zone->magic = 0; - isc_mem_putanddetach(&zone->mctx, zone, sizeof(*zone)); + isc_mem_t *mctx = zone->mctx; + isc_mem_putx(mctx, zone, sizeof(*zone), + ISC_MEM_ALIGN(ISC_OS_CACHELINE_SIZE)); + isc_mem_detach(&mctx); } /* diff --git a/lib/dns/zone_p.h b/lib/dns/zone_p.h index d7cc14d65f3..bf0a8c0255a 100644 --- a/lib/dns/zone_p.h +++ b/lib/dns/zone_p.h @@ -17,6 +17,8 @@ #include +#include + #include #include #include @@ -366,9 +368,10 @@ struct dns_zone { bool locked; #endif /* ifdef DNS_ZONE_CHECKLOCK */ isc_mem_t *mctx; - isc_refcount_t references; + __attribute__(( + aligned(ISC_OS_CACHELINE_SIZE))) isc_refcount_t references; - isc_rwlock_t dblock; + __attribute__((aligned(ISC_OS_CACHELINE_SIZE))) isc_rwlock_t dblock; dns_db_t *db; /* Locked by dblock */ isc_tid_t tid;