FreeBSD/sys/kern/sched_ule.c
/*
 * Build the CPU topology dump string. Is recursively called to collect
 * the topology tree.
 */
Build the CPU topology dump string. Is recursively called to collect
the topology tree.
Build the CPU topology dump string . Is recursively called to collect the topology tree .
static int
sysctl_kern_sched_topology_spec_internal(struct sbuf *sb, struct cpu_group *cg,
    int indent)
{
	char cpusetbuf[CPUSETBUFSIZ];
	int i, first;
	sbuf_printf(sb, "%*s<group level=\"%d\" cache-level=\"%d\">\n", indent,
	    "", 1 + indent / 2, cg->cg_level);
	sbuf_printf(sb, "%*s <cpu count=\"%d\" mask=\"%s\">", indent, "",
	    cg->cg_count, cpusetobj_strprint(cpusetbuf, &cg->cg_mask));
	first = TRUE;
	for (i = 0; i < MAXCPU; i++) {
		if (CPU_ISSET(i, &cg->cg_mask)) {
			if (!first)
				sbuf_printf(sb, ", ");
			else
				first = FALSE;
			sbuf_printf(sb, "%d", i);
		}
	}
	sbuf_printf(sb, "</cpu>\n");
	if (cg->cg_flags != 0) {
		sbuf_printf(sb, "%*s <flags>", indent, "");
		if ((cg->cg_flags & CG_FLAG_HTT) != 0)
			sbuf_printf(sb, "<flag name=\"HTT\">HTT group</flag>");
		if ((cg->cg_flags & CG_FLAG_THREAD) != 0)
			sbuf_printf(sb, "<flag name=\"THREAD\">THREAD group</flag>");
		if ((cg->cg_flags & CG_FLAG_SMT) != 0)
			sbuf_printf(sb, "<flag name=\"SMT\">SMT group</flag>");
		sbuf_printf(sb, "</flags>\n");
	}
	if (cg->cg_children > 0) {
		sbuf_printf(sb, "%*s <children>\n", indent, "");
		for (i = 0; i < cg->cg_children; i++)
			sysctl_kern_sched_topology_spec_internal(sb, 
			    &cg->cg_child[i], indent+2);
		sbuf_printf(sb, "%*s </children>\n", indent, "");
	}
	sbuf_printf(sb, "%*s</group>\n", indent, "");
	return (0);
}
static int sysctl_kern_sched_topology_spec_internal ( struct sbuf * sb , struct cpu_group * cg , int indent ) { char cpusetbuf [ CPUSETBUFSIZ ] ; int i , first ; sbuf_printf ( sb , " \" \" \" \" \n " , indent , " " , 1 + indent / 2 , cg -> cg_level ) ; sbuf_printf ( sb , " \" \" \" \" " , indent , " " , cg -> cg_count , cpusetobj_strprint ( cpusetbuf , & cg -> cg_mask ) ) ; first = TRUE ; for ( i = 0 ; i < MAXCPU ; i ++ ) { if ( CPU_ISSET ( i , & cg -> cg_mask ) ) { if ( ! first ) sbuf_printf ( sb , " " ) ; else first = FALSE ; sbuf_printf ( sb , " " , i ) ; } } sbuf_printf ( sb , " \n " ) ; if ( cg -> cg_flags != 0 ) { sbuf_printf ( sb , " " , indent , " " ) ; if ( ( cg -> cg_flags & CG_FLAG_HTT ) != 0 ) sbuf_printf ( sb , " \" \" " ) ; if ( ( cg -> cg_flags & CG_FLAG_THREAD ) != 0 ) sbuf_printf ( sb , " \" \" " ) ; if ( ( cg -> cg_flags & CG_FLAG_SMT ) != 0 ) sbuf_printf ( sb , " \" \" " ) ; sbuf_printf ( sb , " \n " ) ; } if ( cg -> cg_children > 0 ) { sbuf_printf ( sb , " \n " , indent , " " ) ; for ( i = 0 ; i < cg -> cg_children ; i ++ ) sysctl_kern_sched_topology_spec_internal ( sb , & cg -> cg_child [ i ] , indent + 2 ) ; sbuf_printf ( sb , " \n " , indent , " " ) ; } sbuf_printf ( sb , " \n " , indent , " " ) ; return ( 0 ) ; }
Build the CPU topology dump string.
Build the CPU topology dump string .