From: Ondřej Surý Date: Tue, 4 Feb 2025 17:02:29 +0000 (+0100) Subject: Rely on call_rcu() to destroy the qpzone outside of locks X-Git-Tag: v9.21.5~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fa5219fdfdec78d71b9fc270f87fa068a98f2a6;p=thirdparty%2Fbind9.git Rely on call_rcu() to destroy the qpzone outside of locks 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. --- diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 74bdba0223b..c59d4e0f95c 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 97071b6019c..a1b7b97a207 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -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