| 177 | #endif |
| 178 | |
| 179 | static int |
| 180 | vmtotal(SYSCTL_HANDLER_ARGS) |
| 181 | { |
| 182 | struct vmtotal total; |
| 183 | #if defined(COMPAT_FREEBSD11) |
| 184 | struct vmtotal11 total11; |
| 185 | #endif |
| 186 | vm_object_t object; |
| 187 | struct proc *p; |
| 188 | struct thread *td; |
| 189 | |
| 190 | if (req->oldptr == NULL) { |
| 191 | #if defined(COMPAT_FREEBSD11) |
| 192 | if (curproc->p_osrel < P_OSREL_VMTOTAL64) |
| 193 | return (SYSCTL_OUT(req, NULL, sizeof(total11))); |
| 194 | #endif |
| 195 | return (SYSCTL_OUT(req, NULL, sizeof(total))); |
| 196 | } |
| 197 | bzero(&total, sizeof(total)); |
| 198 | |
| 199 | /* |
| 200 | * Calculate process statistics. |
| 201 | */ |
| 202 | sx_slock(&allproc_lock); |
| 203 | FOREACH_PROC_IN_SYSTEM(p) { |
| 204 | if ((p->p_flag & P_SYSTEM) != 0) |
| 205 | continue; |
| 206 | PROC_LOCK(p); |
| 207 | if (p->p_state != PRS_NEW) { |
| 208 | FOREACH_THREAD_IN_PROC(p, td) { |
| 209 | thread_lock(td); |
| 210 | switch (td->td_state) { |
| 211 | case TDS_INHIBITED: |
| 212 | if (TD_IS_SWAPPED(td)) |
| 213 | total.t_sw++; |
| 214 | else if (TD_IS_SLEEPING(td)) { |
| 215 | if (td->td_priority <= PZERO) |
| 216 | total.t_dw++; |
| 217 | else |
| 218 | total.t_sl++; |
| 219 | } |
| 220 | break; |
| 221 | case TDS_CAN_RUN: |
| 222 | total.t_sw++; |
| 223 | break; |
| 224 | case TDS_RUNQ: |
| 225 | case TDS_RUNNING: |
| 226 | total.t_rq++; |
| 227 | break; |
| 228 | default: |
| 229 | break; |
| 230 | } |
| 231 | thread_unlock(td); |
| 232 | } |
| 233 | } |
| 234 | PROC_UNLOCK(p); |
| 235 | } |
| 236 | sx_sunlock(&allproc_lock); |
nothing calls this directly
no test coverage detected