View | Details | Raw Unified | Return to bug 188911 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/kern/kern_proc.c (-32 / +53 lines)
Lines 141-146 uma_zone_t proc_zone; Link Here
141
int kstack_pages = KSTACK_PAGES;
141
int kstack_pages = KSTACK_PAGES;
142
SYSCTL_INT(_kern, OID_AUTO, kstack_pages, CTLFLAG_RD, &kstack_pages, 0,
142
SYSCTL_INT(_kern, OID_AUTO, kstack_pages, CTLFLAG_RD, &kstack_pages, 0,
143
    "Kernel stack size in pages");
143
    "Kernel stack size in pages");
144
static int vmmap_skip_res_cnt = 1;
145
SYSCTL_INT(_kern, OID_AUTO, proc_vmmap_skip_resident_count, CTLFLAG_RW,
146
    &vmmap_skip_res_cnt, 0,
147
    "Skip calculation of the pages resident count in kern.proc.vmmap");
144
148
145
CTASSERT(sizeof(struct kinfo_proc) == KINFO_PROC_SIZE);
149
CTASSERT(sizeof(struct kinfo_proc) == KINFO_PROC_SIZE);
146
#ifdef COMPAT_FREEBSD32
150
#ifdef COMPAT_FREEBSD32
Lines 2136-2150 int Link Here
2136
kern_proc_vmmap_out(struct proc *p, struct sbuf *sb)
2140
kern_proc_vmmap_out(struct proc *p, struct sbuf *sb)
2137
{
2141
{
2138
	vm_map_entry_t entry, tmp_entry;
2142
	vm_map_entry_t entry, tmp_entry;
2139
	unsigned int last_timestamp;
2143
	struct vattr va;
2144
	vm_map_t map;
2145
	vm_page_t m;
2146
	vm_object_t obj, tobj, lobj;
2140
	char *fullpath, *freepath;
2147
	char *fullpath, *freepath;
2141
	struct kinfo_vmentry *kve;
2148
	struct kinfo_vmentry *kve;
2142
	struct vattr va;
2143
	struct ucred *cred;
2149
	struct ucred *cred;
2144
	int error;
2145
	struct vnode *vp;
2150
	struct vnode *vp;
2146
	struct vmspace *vm;
2151
	struct vmspace *vm;
2147
	vm_map_t map;
2152
	vm_pindex_t pindex;
2153
	vm_offset_t addr, clp;
2154
	unsigned int last_timestamp;
2155
	int error;
2148
2156
2149
	PROC_LOCK_ASSERT(p, MA_OWNED);
2157
	PROC_LOCK_ASSERT(p, MA_OWNED);
2150
2158
Lines 2162-2205 kern_proc_vmmap_out(struct proc *p, struct sbuf *sb) Link Here
2162
	vm_map_lock_read(map);
2170
	vm_map_lock_read(map);
2163
	for (entry = map->header.next; entry != &map->header;
2171
	for (entry = map->header.next; entry != &map->header;
2164
	    entry = entry->next) {
2172
	    entry = entry->next) {
2165
		vm_object_t obj, tobj, lobj;
2166
		vm_offset_t addr;
2167
		vm_paddr_t locked_pa;
2168
		int mincoreinfo;
2169
2170
		if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
2173
		if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
2171
			continue;
2174
			continue;
2172
2175
2173
		bzero(kve, sizeof(*kve));
2176
		bzero(kve, sizeof(*kve));
2174
2177
2175
		kve->kve_private_resident = 0;
2178
		kve->kve_private_resident = 0;
2179
		kve->kve_resident = 0;
2176
		obj = entry->object.vm_object;
2180
		obj = entry->object.vm_object;
2177
		if (obj != NULL) {
2181
		if (obj != NULL) {
2178
			VM_OBJECT_RLOCK(obj);
2182
			for (tobj = obj; tobj != NULL;
2183
			    tobj = tobj->backing_object) {
2184
				VM_OBJECT_RLOCK(tobj);
2185
				lobj = tobj;
2186
			}
2179
			if (obj->shadow_count == 1)
2187
			if (obj->shadow_count == 1)
2180
				kve->kve_private_resident =
2188
				kve->kve_private_resident =
2181
				    obj->resident_page_count;
2189
				    obj->resident_page_count;
2182
		}
2190
			if (vmmap_skip_res_cnt)
2183
		kve->kve_resident = 0;
2191
				goto skip_resident_count;
2184
		addr = entry->start;
2192
			for (addr = entry->start; addr < entry->end;) {
2185
		while (addr < entry->end) {
2193
				pindex = OFF_TO_IDX(entry->offset + addr -
2186
			locked_pa = 0;
2194
				    entry->start);
2187
			mincoreinfo = pmap_mincore(map->pmap, addr, &locked_pa);
2195
				for (tobj = obj;;) {
2188
			if (locked_pa != 0)
2196
					m = vm_page_lookup(tobj, pindex);
2189
				vm_page_unlock(PHYS_TO_VM_PAGE(locked_pa));
2197
					if (m != NULL)
2190
			if (mincoreinfo & MINCORE_INCORE)
2198
						break;
2191
				kve->kve_resident++;
2199
					if (tobj->backing_object == NULL)
2192
			if (mincoreinfo & MINCORE_SUPER)
2200
						break;
2193
				kve->kve_flags |= KVME_FLAG_SUPER;
2201
					pindex += OFF_TO_IDX(
2194
			addr += PAGE_SIZE;
2202
					    tobj->backing_object_offset);
2195
		}
2203
					tobj = tobj->backing_object;
2196
2204
				}
2197
		for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) {
2205
				if (m == NULL) {
2198
			if (tobj != obj)
2206
					addr += PAGE_SIZE;
2199
				VM_OBJECT_RLOCK(tobj);
2207
					continue;
2200
			if (lobj != obj)
2208
				}
2201
				VM_OBJECT_RUNLOCK(lobj);
2209
				if (m->psind != 0)
2202
			lobj = tobj;
2210
					kve->kve_flags |= KVME_FLAG_SUPER;
2211
				clp = addr + pagesizes[m->psind] <= entry->end ?
2212
				    pagesizes[m->psind] : entry->end - addr;
2213
				kve->kve_resident += clp / PAGE_SIZE;
2214
				addr += pagesizes[m->psind];
2215
			}
2216
skip_resident_count:
2217
			for (tobj = obj; tobj != NULL;
2218
			    tobj = tobj->backing_object) {
2219
				if (tobj != obj && tobj != lobj)
2220
					VM_OBJECT_RUNLOCK(tobj);
2221
			}
2222
		} else {
2223
			lobj = NULL;
2203
		}
2224
		}
2204
2225
2205
		kve->kve_start = entry->start;
2226
		kve->kve_start = entry->start;
Lines 2229-2235 kern_proc_vmmap_out(struct proc *p, struct sbuf *sb) Link Here
2229
2250
2230
		freepath = NULL;
2251
		freepath = NULL;
2231
		fullpath = "";
2252
		fullpath = "";
2232
		if (lobj) {
2253
		if (lobj != NULL) {
2233
			vp = NULL;
2254
			vp = NULL;
2234
			switch (lobj->type) {
2255
			switch (lobj->type) {
2235
			case OBJT_DEFAULT:
2256
			case OBJT_DEFAULT:

Return to bug 188911