[patch] a few linprocfs changes

Alexander Best arundel at freebsd.org
Fri Jan 28 20:41:54 UTC 2011


the following patch includes the following changes:

@@ -176,9 +176,10 @@:
- fix a style(9) issue

@@ -272,7 +273,7 @@
- use CPU_FOREACH() macro rather than iterating over each cpu manually

@@ -282,7 +283,6 @@
- remove comment. we don't gather the vendor, class, model, etc. data per cpu
  in sys/{i386,amd64}/{i386,amd64}/identcpu.c. so there's no way of accessing
  per cpu data in linprocfs.c, which relies on the data that gets gathered at
  boot time by identcpu.c.

@@ -299,9 +299,10 @@
- rather calculate the elements of flags[] at compile time, instead of relying
  on the hardcoded value.

cheers.
alex

-- 
a13x
-------------- next part --------------
Index: linprocfs.c
===================================================================
--- linprocfs.c	(revision 218029)
+++ linprocfs.c	(working copy)
@@ -176,9 +176,10 @@
 	swapfree = swaptotal - swapused;
 	memshared = 0;
 	mtx_lock(&vm_object_list_mtx);
-	TAILQ_FOREACH(object, &vm_object_list, object_list)
+	TAILQ_FOREACH(object, &vm_object_list, object_list) {
 		if (object->shadow_count > 1)
 			memshared += object->resident_page_count;
+	}
 	mtx_unlock(&vm_object_list_mtx);
 	memshared *= PAGE_SIZE;
 	/*
@@ -272,7 +273,7 @@
 	size = sizeof(model);
 	if (kernel_sysctl(td, hw_model, 2, &model, &size, 0, 0, 0, 0) != 0)
 		strcpy(model, "unknown");
-	for (i = 0; i < mp_ncpus; ++i) {
+	CPU_FOREACH(i) {
 		sbuf_printf(sb,
 		    "processor\t: %d\n"
 		    "vendor_id\t: %.20s\n"
@@ -282,7 +283,6 @@
 		    "stepping\t: %u\n\n",
 		    i, cpu_vendor, CPUID_TO_FAMILY(cpu_id),
 		    CPUID_TO_MODEL(cpu_id), model, cpu_id & CPUID_STEPPING);
-		/* XXX per-cpu vendor / class / model / id? */
 	}
 
 	sbuf_cat(sb, "flags\t\t:");
@@ -299,9 +299,10 @@
 	}
 #endif
 
-	for (i = 0; i < 32; i++)
+	for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
 		if (cpu_feature & (1 << i))
 			sbuf_printf(sb, " %s", flags[i]);
+	}
 	sbuf_cat(sb, "\n");
 	if (class >= 5) {
 		fqmhz = (tsc_freq + 4999) / 1000000;


More information about the freebsd-emulation mailing list