]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Display ECS module memory usage.
authorRalph Dolmans <ralph@nlnetlabs.nl>
Tue, 11 Apr 2017 13:10:30 +0000 (13:10 +0000)
committerRalph Dolmans <ralph@nlnetlabs.nl>
Tue, 11 Apr 2017 13:10:30 +0000 (13:10 +0000)
git-svn-id: file:///svn/unbound/trunk@4106 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/remote.c
daemon/worker.c
doc/Changelog
edns-subnet/subnetmod.c

index d9f5bcf3105093e710e0346a87821a0f59500b93..c15967c2088886e96fcd977d924816adeaf05439 100644 (file)
@@ -864,6 +864,9 @@ print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon)
 {
        int m;
        size_t msg, rrset, val, iter, respip;
+#ifdef CLIENT_SUBNET
+       size_t subnet = 0;
+#endif /* CLIENT_SUBNET */
        msg = slabhash_get_mem(daemon->env->msg_cache);
        rrset = slabhash_get_mem(&daemon->env->rrset_cache->table);
        val=0;
@@ -890,6 +893,15 @@ print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon)
                respip = (*worker->env.mesh->mods.mod[m]->get_mem)
                        (&worker->env, m);
        }
+#ifdef CLIENT_SUBNET
+       m = modstack_find(&worker->env.mesh->mods, "subnet");
+       if(m != -1) {
+               fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->
+                       mods.mod[m]->get_mem));
+               subnet = (*worker->env.mesh->mods.mod[m]->get_mem)
+                       (&worker->env, m);
+       }
+#endif /* CLIENT_SUBNET */
 
        if(!print_longnum(ssl, "mem.cache.rrset"SQ, rrset))
                return 0;
@@ -901,6 +913,10 @@ print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon)
                return 0;
        if(!print_longnum(ssl, "mem.mod.respip"SQ, respip))
                return 0;
+#ifdef CLIENT_SUBNET
+       if(!print_longnum(ssl, "mem.mod.subnet"SQ, subnet))
+               return 0;
+#endif /* CLIENT_SUBNET */
        return 1;
 }
 
index b8cc2a0cdea02caccecf4b0c4f931d1b0200162b..b1cc974aa2e255ac05d267fe36a776ef1f182536 100644 (file)
@@ -117,6 +117,9 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
        size_t total, front, back, mesh, msg, rrset, infra, ac, superac;
        size_t me, iter, val, anch;
        int i;
+#ifdef CLIENT_SUBNET
+       size_t subnet = 0;
+#endif /* CLIENT_SUBNET */
        if(verbosity < VERB_ALGO) 
                return;
        front = listen_get_mem(worker->front);
@@ -136,6 +139,12 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
                if(strcmp(worker->env.mesh->mods.mod[i]->name, "validator")==0)
                        val += (*worker->env.mesh->mods.mod[i]->get_mem)
                                (&worker->env, i);
+#ifdef CLIENT_SUBNET
+               else if(strcmp(worker->env.mesh->mods.mod[i]->name,
+                       "subnet")==0)
+                       subnet += (*worker->env.mesh->mods.mod[i]->get_mem)
+                               (&worker->env, i);
+#endif /* CLIENT_SUBNET */
                else    iter += (*worker->env.mesh->mods.mod[i]->get_mem)
                                (&worker->env, i);
        }
@@ -153,6 +162,17 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
                me += serviced_get_mem(cur_serv);
        }
        total = front+back+mesh+msg+rrset+infra+iter+val+ac+superac+me;
+#ifdef CLIENT_SUBNET
+       total += subnet;
+       log_info("Memory conditions: %u front=%u back=%u mesh=%u msg=%u "
+               "rrset=%u infra=%u iter=%u val=%u subnet=%u anchors=%u "
+               "alloccache=%u globalalloccache=%u me=%u",
+               (unsigned)total, (unsigned)front, (unsigned)back, 
+               (unsigned)mesh, (unsigned)msg, (unsigned)rrset, (unsigned)infra,
+               (unsigned)iter, (unsigned)val,
+               (unsigned)subnet, (unsigned)anch, (unsigned)ac,
+               (unsigned)superac, (unsigned)me);
+#else /* no CLIENT_SUBNET */
        log_info("Memory conditions: %u front=%u back=%u mesh=%u msg=%u "
                "rrset=%u infra=%u iter=%u val=%u anchors=%u "
                "alloccache=%u globalalloccache=%u me=%u",
@@ -160,11 +180,15 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
                (unsigned)mesh, (unsigned)msg, (unsigned)rrset, 
                (unsigned)infra, (unsigned)iter, (unsigned)val, (unsigned)anch,
                (unsigned)ac, (unsigned)superac, (unsigned)me);
+#endif /* CLIENT_SUBNET */
        log_info("Total heap memory estimate: %u  total-alloc: %u  "
                "total-free: %u", (unsigned)total, 
                (unsigned)unbound_mem_alloc, (unsigned)unbound_mem_freed);
 #else /* no UNBOUND_ALLOC_STATS */
        size_t val = 0;
+#ifdef CLIENT_SUBNET
+       size_t subnet = 0;
+#endif /* CLIENT_SUBNET */
        int i;
        if(verbosity < VERB_QUERY)
                return;
@@ -174,12 +198,27 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
                if(strcmp(worker->env.mesh->mods.mod[i]->name, "validator")==0)
                        val += (*worker->env.mesh->mods.mod[i]->get_mem)
                                (&worker->env, i);
+#ifdef CLIENT_SUBNET
+               else if(strcmp(worker->env.mesh->mods.mod[i]->name,
+                       "subnet")==0)
+                       subnet += (*worker->env.mesh->mods.mod[i]->get_mem)
+                               (&worker->env, i);
+#endif /* CLIENT_SUBNET */
        }
+#ifdef CLIENT_SUBNET
+       verbose(VERB_QUERY, "cache memory msg=%u rrset=%u infra=%u val=%u "
+               "subnet=%u",
+               (unsigned)slabhash_get_mem(worker->env.msg_cache),
+               (unsigned)slabhash_get_mem(&worker->env.rrset_cache->table),
+               (unsigned)infra_get_mem(worker->env.infra_cache),
+               (unsigned)val, (unsigned)subnet);
+#else /* no CLIENT_SUBNET */
        verbose(VERB_QUERY, "cache memory msg=%u rrset=%u infra=%u val=%u",
                (unsigned)slabhash_get_mem(worker->env.msg_cache),
                (unsigned)slabhash_get_mem(&worker->env.rrset_cache->table),
                (unsigned)infra_get_mem(worker->env.infra_cache),
                (unsigned)val);
+#endif /* CLIENT_SUBNET */
 #endif /* UNBOUND_ALLOC_STATS */
 }
 
index cece161581426a44f4774af3bb398a29a988d1f1..443cf22cc878ed54446fe862170a8f4319fed82c 100644 (file)
@@ -1,3 +1,6 @@
+11 April 2017: Ralph
+       - Display ECS module memory usage.
+
 10 April 2017: Wouter
        - harden-algo-downgrade: no also makes unbound more lenient about
          digest algorithms in DS records.
index b786c2869b29f7fc0288310bf759a0df56bc5e4d..464d9d826f24870e6057abfa3a778a7abbba2bef 100644 (file)
@@ -761,7 +761,8 @@ subnetmod_get_mem(struct module_env *env, int id)
        struct subnet_env *sn_env = env->modinfo[id];
        if (!sn_env) return 0;
        return sizeof(*sn_env) + 
-               slabhash_get_mem(sn_env->subnet_msg_cache);
+               slabhash_get_mem(sn_env->subnet_msg_cache) +
+               upstream_get_mem(sn_env->edns_subnet_upstreams);
 }
 
 /**