| 974 | "nchash chain lengths"); |
| 975 | |
| 976 | static int |
| 977 | sysctl_debug_hashstat_nchash(SYSCTL_HANDLER_ARGS) |
| 978 | { |
| 979 | int error; |
| 980 | struct nchashhead *ncpp; |
| 981 | struct namecache *ncp; |
| 982 | int n_nchash; |
| 983 | int count, maxlength, used, pct; |
| 984 | |
| 985 | if (!req->oldptr) |
| 986 | return SYSCTL_OUT(req, 0, 4 * sizeof(int)); |
| 987 | |
| 988 | cache_lock_all_buckets(); |
| 989 | n_nchash = nchash + 1; /* nchash is max index, not count */ |
| 990 | used = 0; |
| 991 | maxlength = 0; |
| 992 | |
| 993 | /* Scan hash tables for applicable entries */ |
| 994 | for (ncpp = nchashtbl; n_nchash > 0; n_nchash--, ncpp++) { |
| 995 | count = 0; |
| 996 | CK_SLIST_FOREACH(ncp, ncpp, nc_hash) { |
| 997 | count++; |
| 998 | } |
| 999 | if (count) |
| 1000 | used++; |
| 1001 | if (maxlength < count) |
| 1002 | maxlength = count; |
| 1003 | } |
| 1004 | n_nchash = nchash + 1; |
| 1005 | cache_unlock_all_buckets(); |
| 1006 | pct = (used * 100) / (n_nchash / 100); |
| 1007 | error = SYSCTL_OUT(req, &n_nchash, sizeof(n_nchash)); |
| 1008 | if (error) |
| 1009 | return (error); |
| 1010 | error = SYSCTL_OUT(req, &used, sizeof(used)); |
| 1011 | if (error) |
| 1012 | return (error); |
| 1013 | error = SYSCTL_OUT(req, &maxlength, sizeof(maxlength)); |
| 1014 | if (error) |
| 1015 | return (error); |
| 1016 | error = SYSCTL_OUT(req, &pct, sizeof(pct)); |
| 1017 | if (error) |
| 1018 | return (error); |
| 1019 | return (0); |
| 1020 | } |
| 1021 | SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD| |
| 1022 | CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I", |
| 1023 | "nchash statistics (number of total/used buckets, maximum chain length, usage percentage)"); |
nothing calls this directly
no test coverage detected