| 941 | "hash table stats"); |
| 942 | |
| 943 | static int |
| 944 | sysctl_debug_hashstat_rawnchash(SYSCTL_HANDLER_ARGS) |
| 945 | { |
| 946 | struct nchashhead *ncpp; |
| 947 | struct namecache *ncp; |
| 948 | int i, error, n_nchash, *cntbuf; |
| 949 | |
| 950 | retry: |
| 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 | } |
| 972 | SYSCTL_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"); |
nothing calls this directly
no test coverage detected