]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Align zone refcount and dblock
authorAlessio Podda <alessio@isc.org>
Mon, 19 Jan 2026 09:36:53 +0000 (10:36 +0100)
committerAlessio Podda <alessio@isc.org>
Thu, 13 Aug 2026 17:06:27 +0000 (19:06 +0200)
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.

lib/dns/zone.c
lib/dns/zone_p.h

index 104199c22555916bc54379a215e6b1bc4a611cba..78f40729708c228604b7544c1dd13ef7d49e8301 100644 (file)
@@ -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);
 }
 
 /*
index d7cc14d65f3ac493f43441f9f40fb4d7f1d59c84..bf0a8c0255a294e2bf1fd3d56f818f938794cd7b 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <stdbool.h>
 
+#include <isc/os.h>
+
 #include <dns/adb.h>
 #include <dns/db.h>
 #include <dns/notify.h>
@@ -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;