]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Rely on call_rcu() to destroy the qpzone outside of locks
authorOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2025 17:02:29 +0000 (18:02 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2025 20:37:46 +0000 (21:37 +0100)
Reduce the number of qpzone_ref() and qpzone_unref() calls in
qpzone_detachnode() by relying on the call_rcu to delay
the destruction of the lock buckets.

lib/dns/qpcache.c
lib/dns/qpzone.c

index 74bdba0223b13084ea18070766ab19d4fc3af163..c59d4e0f95c4978a66d85d708790e14543402a64 100644 (file)
@@ -28,7 +28,7 @@
 #include <isc/loop.h>
 #include <isc/mem.h>
 #include <isc/mutex.h>
-#include <isc/once.h>
+#include <isc/os.h>
 #include <isc/queue.h>
 #include <isc/random.h>
 #include <isc/refcount.h>
index 97071b6019c2f5122913d3acddd9044d3572d607..a1b7b97a207cff2312f52eee471b00d61fb8ef1f 100644 (file)
@@ -28,7 +28,7 @@
 #include <isc/loop.h>
 #include <isc/mem.h>
 #include <isc/mutex.h>
-#include <isc/once.h>
+#include <isc/os.h>
 #include <isc/random.h>
 #include <isc/refcount.h>
 #include <isc/result.h>
@@ -3939,17 +3939,15 @@ detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) {
        nlock = &qpdb->buckets[node->locknum].lock;
 
        /*
-        * We can't destroy qpzonedb while holding a nodelock, so
-        * we need to reference it before acquiring the lock
-        * and release it afterward.
+        * qpzone_destroy() uses call_rcu() API to destroy the node locks,
+        * so it is safe to call it in the middle of NODE_LOCK.
         */
-       qpzonedb_ref(qpdb);
 
+       rcu_read_lock();
        NODE_RDLOCK(nlock, &nlocktype);
        qpznode_release(qpdb, node, 0, &nlocktype DNS__DB_FLARG_PASS);
        NODE_UNLOCK(nlock, &nlocktype);
-
-       qpzonedb_detach(&qpdb);
+       rcu_read_unlock();
 }
 
 static unsigned int