svn commit: r239923 - in head/sys: conf kern sys

Attilio Rao attilio at FreeBSD.org
Thu Aug 30 21:22:48 UTC 2012


Author: attilio
Date: Thu Aug 30 21:22:47 2012
New Revision: 239923
URL: http://svn.freebsd.org/changeset/base/239923

Log:
  Post r222812 KTR_CPUMASK started being initialized only as a tunable
  handler and not more statically.
  
  Unfortunately, it seems that this is not ideal for new platform bringup
  and boot low level development (which needs ktr_cpumask to be effective
  before tunables can be setup).
  
  Because of this, add a way to statically initialize cpusets, by passing
  an list of initializers, divided by commas. Also, provide a way to enforce
  an all-set mask, for above mentioned initializers.
  
  This imposes some differences on how KTR_CPUMASK is setup now as a
  kernel option, and in particular this makes the words specifications
  backward wrt. what is currently in -CURRENT. In order to avoid mismatches
  between KTR_CPUMASK definition and other way to setup the mask
  (tunable, sysctl) and to print it, change the ordering how
  cpusetobj_print() and cpusetobj_scan() acquire the words belonging
  to the set.
  Please give a look to sys/conf/NOTES in order to understand how the
  new format is supposed to work.
  
  Also, ktr manpages will be updated shortly by gjb which volountereed
  for this.
  
  This patch won't be merged because it changes a POLA (at least
  from the theoretical standpoint) and this is however a patch that
  proves to be effective only in development environments.
  
  Requested by:	rpaulo
  Reviewed by:	jeff, rpaulo

Modified:
  head/sys/conf/NOTES
  head/sys/kern/kern_cpuset.c
  head/sys/kern/kern_ktr.c
  head/sys/sys/_cpuset.h

Modified: head/sys/conf/NOTES
==============================================================================
--- head/sys/conf/NOTES	Thu Aug 30 20:59:37 2012	(r239922)
+++ head/sys/conf/NOTES	Thu Aug 30 21:22:47 2012	(r239923)
@@ -442,8 +442,8 @@ options 	KTRACE_REQUEST_POOL=101
 # what events to trace.  KTR_CPUMASK determines which CPU's log
 # events, with bit X corresponding to CPU X.  The layout of the string
 # passed as KTR_CPUMASK must match a series of bitmasks each of them
-# separated by the ", " characters (ie:
-# KTR_CPUMASK=("0xAF, 0xFFFFFFFFFFFFFFFF")).  KTR_VERBOSE enables
+# separated by the "," character (ie:
+# KTR_CPUMASK=0xAF,0xFFFFFFFFFFFFFFFF).  KTR_VERBOSE enables
 # dumping of KTR events to the console by default.  This functionality
 # can be toggled via the debug.ktr_verbose sysctl and defaults to off
 # if KTR_VERBOSE is not defined.  See ktr(4) and ktrdump(8) for details.
@@ -452,7 +452,7 @@ options 	KTR
 options 	KTR_ENTRIES=1024
 options 	KTR_COMPILE=(KTR_INTR|KTR_PROC)
 options 	KTR_MASK=KTR_INTR
-options 	KTR_CPUMASK=("0x3")
+options 	KTR_CPUMASK=0x3
 options 	KTR_VERBOSE
 
 #

Modified: head/sys/kern/kern_cpuset.c
==============================================================================
--- head/sys/kern/kern_cpuset.c	Thu Aug 30 20:59:37 2012	(r239922)
+++ head/sys/kern/kern_cpuset.c	Thu Aug 30 21:22:47 2012	(r239923)
@@ -651,12 +651,12 @@ cpusetobj_strprint(char *buf, const cpus
 	bytesp = 0;
 	bufsiz = CPUSETBUFSIZ;
 
-	for (i = _NCPUWORDS - 1; i > 0; i--) {
-		bytesp = snprintf(tbuf, bufsiz, "%lx, ", set->__bits[i]);
+	for (i = 0; i < (_NCPUWORDS - 1); i++) {
+		bytesp = snprintf(tbuf, bufsiz, "%lx,", set->__bits[i]);
 		bufsiz -= bytesp;
 		tbuf += bytesp;
 	}
-	snprintf(tbuf, bufsiz, "%lx", set->__bits[0]);
+	snprintf(tbuf, bufsiz, "%lx", set->__bits[_NCPUWORDS - 1]);
 	return (buf);
 }
 
@@ -682,16 +682,16 @@ cpusetobj_strscan(cpuset_t *set, const c
 		return (-1);
 
 	CPU_ZERO(set);
-	for (i = nwords - 1; i > 0; i--) {
-		ret = sscanf(buf, "%lx, ", &set->__bits[i]);
+	for (i = 0; i < (nwords - 1); i++) {
+		ret = sscanf(buf, "%lx,", &set->__bits[i]);
 		if (ret == 0 || ret == -1)
 			return (-1);
-		buf = strstr(buf, " ");
+		buf = strstr(buf, ",");
 		if (buf == NULL)
 			return (-1);
 		buf++;
 	}
-	ret = sscanf(buf, "%lx", &set->__bits[0]);
+	ret = sscanf(buf, "%lx", &set->__bits[nwords - 1]);
 	if (ret == 0 || ret == -1)
 		return (-1);
 	return (0);

Modified: head/sys/kern/kern_ktr.c
==============================================================================
--- head/sys/kern/kern_ktr.c	Thu Aug 30 20:59:37 2012	(r239922)
+++ head/sys/kern/kern_ktr.c	Thu Aug 30 21:22:47 2012	(r239923)
@@ -70,6 +70,10 @@ __FBSDID("$FreeBSD$");
 #define	KTR_MASK	(0)
 #endif
 
+#ifndef KTR_CPUMASK
+#define	KTR_CPUMASK	CPUSET_FSET
+#endif
+
 #ifndef KTR_TIME
 #define	KTR_TIME	get_cyclecount()
 #endif
@@ -99,7 +103,7 @@ int	ktr_version = KTR_VERSION;
 SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD,
     &ktr_version, 0, "Version of the KTR interface");
 
-cpuset_t ktr_cpumask;
+cpuset_t ktr_cpumask = CPUSET_T_INITIALIZER(KTR_CPUMASK);
 static char ktr_cpumask_str[CPUSETBUFSIZ];
 TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str));
 
@@ -107,12 +111,6 @@ static void
 ktr_cpumask_initializer(void *dummy __unused)
 {
 
-	CPU_FILL(&ktr_cpumask);
-#ifdef KTR_CPUMASK
-	if (cpusetobj_strscan(&ktr_cpumask, KTR_CPUMASK) == -1)
-		CPU_FILL(&ktr_cpumask);
-#endif
-
 	/*
 	 * TUNABLE_STR() runs with SI_ORDER_MIDDLE priority, thus it must be
 	 * already set, if necessary.

Modified: head/sys/sys/_cpuset.h
==============================================================================
--- head/sys/sys/_cpuset.h	Thu Aug 30 20:59:37 2012	(r239922)
+++ head/sys/sys/_cpuset.h	Thu Aug 30 21:22:47 2012	(r239923)
@@ -49,4 +49,10 @@ typedef	struct _cpuset {
 	long	__bits[howmany(CPU_SETSIZE, _NCPUBITS)];
 } cpuset_t;
 
+#define	CPUSET_FSET							\
+	[ 0 ... (_NCPUWORDS - 1) ] = (-1L)
+
+#define	CPUSET_T_INITIALIZER(x)						\
+	{ .__bits = { x } }
+
 #endif /* !_SYS__CPUSET_H_ */


More information about the svn-src-all mailing list