MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sysctl_debug_hashstat_rawnchash

Function sysctl_debug_hashstat_rawnchash

freebsd/kern/vfs_cache.c:943–971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

941 "hash table stats");
942
943static int
944sysctl_debug_hashstat_rawnchash(SYSCTL_HANDLER_ARGS)
945{
946 struct nchashhead *ncpp;
947 struct namecache *ncp;
948 int i, error, n_nchash, *cntbuf;
949
950retry:
951 n_nchash = nchash + 1; /* nchash is max index, not count */
952 if (req->oldptr == NULL)
953 return SYSCTL_OUT(req, 0, n_nchash * sizeof(int));
954 cntbuf = malloc(n_nchash * sizeof(int), M_TEMP, M_ZERO | M_WAITOK);
955 cache_lock_all_buckets();
956 if (n_nchash != nchash + 1) {
957 cache_unlock_all_buckets();
958 free(cntbuf, M_TEMP);
959 goto retry;
960 }
961 /* Scan hash tables counting entries */
962 for (ncpp = nchashtbl, i = 0; i < n_nchash; ncpp++, i++)
963 CK_SLIST_FOREACH(ncp, ncpp, nc_hash)
964 cntbuf[i]++;
965 cache_unlock_all_buckets();
966 for (error = 0, i = 0; i < n_nchash; i++)
967 if ((error = SYSCTL_OUT(req, &cntbuf[i], sizeof(int))) != 0)
968 break;
969 free(cntbuf, M_TEMP);
970 return (error);
971}
972SYSCTL_PROC(_debug_hashstat, OID_AUTO, rawnchash, CTLTYPE_INT|CTLFLAG_RD|
973 CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_rawnchash, "S,int",
974 "nchash chain lengths");

Callers

nothing calls this directly

Calls 4

mallocFunction · 0.85
cache_lock_all_bucketsFunction · 0.85
cache_unlock_all_bucketsFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected