Deleted Added
full compact
vm_meter.c (171633) vm_meter.c (177085)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/vm/vm_meter.c 171633 2007-07-27 20:01:22Z alc $");
33__FBSDID("$FreeBSD: head/sys/vm/vm_meter.c 177085 2008-03-12 06:31:06Z jeff $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/mutex.h>
40#include <sys/proc.h>
41#include <sys/resource.h>

--- 48 unchanged lines hidden (view full) ---

90 return SYSCTL_OUT(req, &averunnable, sizeof(averunnable));
91}
92SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD,
93 NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history");
94
95static int
96vmtotal(SYSCTL_HANDLER_ARGS)
97{
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/mutex.h>
40#include <sys/proc.h>
41#include <sys/resource.h>

--- 48 unchanged lines hidden (view full) ---

90 return SYSCTL_OUT(req, &averunnable, sizeof(averunnable));
91}
92SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD,
93 NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history");
94
95static int
96vmtotal(SYSCTL_HANDLER_ARGS)
97{
98/* XXXKSE almost completely broken */
99 struct proc *p;
100 struct vmtotal total;
101 vm_map_entry_t entry;
102 vm_object_t object;
103 vm_map_t map;
104 int paging;
105 struct thread *td;
106 struct vmspace *vm;

--- 27 unchanged lines hidden (view full) ---

134 PROC_SLOCK(p);
135 switch (p->p_state) {
136 case PRS_NEW:
137 PROC_SUNLOCK(p);
138 continue;
139 break;
140 default:
141 FOREACH_THREAD_IN_PROC(p, td) {
98 struct proc *p;
99 struct vmtotal total;
100 vm_map_entry_t entry;
101 vm_object_t object;
102 vm_map_t map;
103 int paging;
104 struct thread *td;
105 struct vmspace *vm;

--- 27 unchanged lines hidden (view full) ---

133 PROC_SLOCK(p);
134 switch (p->p_state) {
135 case PRS_NEW:
136 PROC_SUNLOCK(p);
137 continue;
138 break;
139 default:
140 FOREACH_THREAD_IN_PROC(p, td) {
142 /* Need new statistics XXX */
143 thread_lock(td);
144 switch (td->td_state) {
145 case TDS_INHIBITED:
141 thread_lock(td);
142 switch (td->td_state) {
143 case TDS_INHIBITED:
146 /*
147 * XXX stats no longer synchronized.
148 */
149 if (TD_ON_LOCK(td) ||
150 (td->td_inhibitors ==
151 TDI_SWAPPED)) {
144 if (TD_IS_SWAPPED(td))
152 total.t_sw++;
145 total.t_sw++;
153 } else if (TD_IS_SLEEPING(td) ||
154 TD_AWAITING_INTR(td) ||
155 TD_IS_SUSPENDED(td)) {
156 if (td->td_priority <= PZERO)
157 total.t_dw++;
158 else
159 total.t_sl++;
160 }
146 else if (TD_IS_SLEEPING(td) &&
147 td->td_priority <= PZERO)
148 total.t_dw++;
149 else
150 total.t_sl++;
161 break;
162
163 case TDS_CAN_RUN:
164 total.t_sw++;
165 break;
166 case TDS_RUNQ:
167 case TDS_RUNNING:
168 total.t_rq++;

--- 220 unchanged lines hidden ---
151 break;
152
153 case TDS_CAN_RUN:
154 total.t_sw++;
155 break;
156 case TDS_RUNQ:
157 case TDS_RUNNING:
158 total.t_rq++;

--- 220 unchanged lines hidden ---