1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

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
This commit is contained in:
Attilio Rao 2012-08-30 21:22:47 +00:00
parent 1b1a53cf46
commit d4a2ab8c07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=239923
4 changed files with 21 additions and 17 deletions

View File

@ -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
#

View File

@ -651,12 +651,12 @@ cpusetobj_strprint(char *buf, const cpuset_t *set)
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 char *buf)
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);

View File

@ -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.

View File

@ -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_ */