Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jan 2018 11:49:33 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r327547 - in stable/11/sys: kern sys
Message-ID:  <201801041149.w04BnXCJ038386@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Jan  4 11:49:32 2018
New Revision: 327547
URL: https://svnweb.freebsd.org/changeset/base/327547

Log:
  MFC r327285:
  Make kern_proc_vmmap_resident() externally accesible, and move the
  vmmap_skip_res_cnt control check inside it.

Modified:
  stable/11/sys/kern/kern_proc.c
  stable/11/sys/sys/proc.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/kern_proc.c
==============================================================================
--- stable/11/sys/kern/kern_proc.c	Thu Jan  4 11:44:58 2018	(r327546)
+++ stable/11/sys/kern/kern_proc.c	Thu Jan  4 11:49:32 2018	(r327547)
@@ -2256,9 +2256,9 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
 CTASSERT(sizeof(struct kinfo_vmentry) == KINFO_VMENTRY_SIZE);
 #endif
 
-static void
+void
 kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t entry,
-    struct kinfo_vmentry *kve)
+    int *resident_count, bool *super)
 {
 	vm_object_t obj, tobj;
 	vm_page_t m, m_adv;
@@ -2266,6 +2266,11 @@ kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t 
 	vm_paddr_t locked_pa;
 	vm_pindex_t pi, pi_adv, pindex;
 
+	*super = false;
+	*resident_count = 0;
+	if (vmmap_skip_res_cnt)
+		return;
+
 	locked_pa = 0;
 	obj = entry->object.vm_object;
 	addr = entry->start;
@@ -2298,7 +2303,7 @@ kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t 
 		    (addr & (pagesizes[1] - 1)) == 0 &&
 		    (pmap_mincore(map->pmap, addr, &locked_pa) &
 		    MINCORE_SUPER) != 0) {
-			kve->kve_flags |= KVME_FLAG_SUPER;
+			*super = true;
 			pi_adv = atop(pagesizes[1]);
 		} else {
 			/*
@@ -2310,7 +2315,7 @@ kern_proc_vmmap_resident(vm_map_t map, vm_map_entry_t 
 			 */
 			pi_adv = 1;
 		}
-		kve->kve_resident += pi_adv;
+		*resident_count += pi_adv;
 next:;
 	}
 	PA_UNLOCK_COND(locked_pa);
@@ -2334,6 +2339,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s
 	vm_offset_t addr;
 	unsigned int last_timestamp;
 	int error;
+	bool super;
 
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 
@@ -2366,8 +2372,10 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s
 			if (obj->backing_object == NULL)
 				kve->kve_private_resident =
 				    obj->resident_page_count;
-			if (!vmmap_skip_res_cnt)
-				kern_proc_vmmap_resident(map, entry, kve);
+			kern_proc_vmmap_resident(map, entry,
+			    &kve->kve_resident, &super);
+			if (super)
+				kve->kve_flags |= KVME_FLAG_SUPER;
 			for (tobj = obj; tobj != NULL;
 			    tobj = tobj->backing_object) {
 				if (tobj != obj && tobj != lobj)
@@ -3077,6 +3085,7 @@ resume_all_proc(void)
 
 	cp = curproc;
 	sx_xlock(&allproc_lock);
+again:
 	LIST_REMOVE(cp, p_list);
 	LIST_INSERT_HEAD(&allproc, cp, p_list);
 	for (;;) {
@@ -3096,6 +3105,12 @@ resume_all_proc(void)
 		} else {
 			PROC_UNLOCK(p);
 		}
+	}
+	/*  Did the loop above missed any stopped process ? */
+	LIST_FOREACH(p, &allproc, p_list) {
+		/* No need for proc lock. */
+		if ((p->p_flag & P_TOTAL_STOP) != 0)
+			goto again;
 	}
 	sx_xunlock(&allproc_lock);
 }

Modified: stable/11/sys/sys/proc.h
==============================================================================
--- stable/11/sys/sys/proc.h	Thu Jan  4 11:44:58 2018	(r327546)
+++ stable/11/sys/sys/proc.h	Thu Jan  4 11:49:32 2018	(r327547)
@@ -182,6 +182,8 @@ struct td_sched;
 struct thread;
 struct trapframe;
 struct turnstile;
+struct vm_map;
+struct vm_map_entry;
 
 /*
  * XXX: Does this belong in resource.h or resourcevar.h instead?
@@ -1002,6 +1004,8 @@ void	fork_exit(void (*)(void *, struct trapframe *), v
 	    struct trapframe *);
 void	fork_return(struct thread *, struct trapframe *);
 int	inferior(struct proc *p);
+void	kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry,
+	    int *resident_count, bool *super);
 void	kern_yield(int);
 void 	kick_proc0(void);
 void	killjobc(void);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801041149.w04BnXCJ038386>