Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Dec 2016 19:29:04 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r310616 - head/sys/vm
Message-ID:  <201612261929.uBQJT4Y8067526@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Dec 26 19:29:04 2016
New Revision: 310616
URL: https://svnweb.freebsd.org/changeset/base/310616

Log:
  Remove redundancy in vmtotal().
  
  There are two instances of inlined unlocks + continue in vmtotal()
  switch statements, which are ordinary expressed with break from the
  switch case and code after the switch.  Also, the combination of
  continue and break statement is redundand.
  
  Reviewed by:	alc
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/vm/vm_meter.c

Modified: head/sys/vm/vm_meter.c
==============================================================================
--- head/sys/vm/vm_meter.c	Mon Dec 26 19:28:10 2016	(r310615)
+++ head/sys/vm/vm_meter.c	Mon Dec 26 19:29:04 2016	(r310616)
@@ -121,15 +121,10 @@ vmtotal(SYSCTL_HANDLER_ARGS)
 	 */
 	sx_slock(&allproc_lock);
 	FOREACH_PROC_IN_SYSTEM(p) {
-		if (p->p_flag & P_SYSTEM)
+		if ((p->p_flag & P_SYSTEM) != 0)
 			continue;
 		PROC_LOCK(p);
-		switch (p->p_state) {
-		case PRS_NEW:
-			PROC_UNLOCK(p);
-			continue;
-			break;
-		default:
+		if (p->p_state != PRS_NEW) {
 			FOREACH_THREAD_IN_PROC(p, td) {
 				thread_lock(td);
 				switch (td->td_state) {
@@ -146,15 +141,13 @@ vmtotal(SYSCTL_HANDLER_ARGS)
 							total.t_pw++;
 					}
 					break;
-
 				case TDS_CAN_RUN:
 					total.t_sw++;
 					break;
 				case TDS_RUNQ:
 				case TDS_RUNNING:
 					total.t_rq++;
-					thread_unlock(td);
-					continue;
+					break;
 				default:
 					break;
 				}



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